MCPcopy Create free account
hub / github.com/Distrotech/reportlab / documentModule0

Function documentModule0

tools/docco/docpy.py:1101–1146  ·  view source on GitHub ↗

Generate documentation for one Python file in some format. This handles Python standard modules like string, custom modules on the Python search path like e.g. docpy as well as modules specified with their full path like C:/tmp/junk.py. The doc file will always be saved in the curr

(pathOrName, builder, opts={})

Source from the content-addressed store, hash-verified

1099
1100
1101def documentModule0(pathOrName, builder, opts={}):
1102 """Generate documentation for one Python file in some format.
1103
1104 This handles Python standard modules like string, custom modules
1105 on the Python search path like e.g. docpy as well as modules
1106 specified with their full path like C:/tmp/junk.py.
1107
1108 The doc file will always be saved in the current directory with
1109 a basename equal to that of the module, e.g. docpy.
1110 """
1111
1112 cwd = os.getcwd()
1113
1114 # Append directory to Python search path if we get one.
1115 dirName = os.path.dirname(pathOrName)
1116 if dirName:
1117 sys.path.append(dirName)
1118
1119 # Remove .py extension from module name.
1120 if pathOrName[-3:] == '.py':
1121 modname = pathOrName[:-3]
1122 else:
1123 modname = pathOrName
1124
1125 # Remove directory paths from module name.
1126 if dirName:
1127 modname = os.path.basename(modname)
1128
1129 # Load the module.
1130 try:
1131 module = __import__(modname)
1132 except:
1133 print 'Failed to import %s.' % modname
1134 os.chdir(cwd)
1135 return
1136
1137 # Do the real documentation work.
1138 s = ModuleSkeleton0()
1139 s.inspect(module)
1140 builder.write(s)
1141
1142 # Remove appended directory from Python search path if we got one.
1143 if dirName:
1144 del sys.path[-1]
1145
1146 os.chdir(cwd)
1147
1148
1149def _packageWalkCallback((builder, opts), dirPath, files):

Callers 2

_packageWalkCallbackFunction · 0.70
mainFunction · 0.70

Calls 4

inspectMethod · 0.95
ModuleSkeleton0Class · 0.85
appendMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected