MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / docmodule

Method docmodule

tools/python-3.11.9-amd64/Lib/pydoc.py:1259–1358  ·  view source on GitHub ↗

Produce text documentation for a given module object.

(self, object, name=None, mod=None, *ignored)

Source from the content-addressed store, hash-verified

1257 return result
1258
1259 def docmodule(self, object, name=None, mod=None, *ignored):
1260 """Produce text documentation for a given module object."""
1261 name = object.__name__ # ignore the passed-in name
1262 synop, desc = splitdoc(getdoc(object))
1263 result = self.section('NAME', name + (synop and ' - ' + synop))
1264 all = getattr(object, '__all__', None)
1265 docloc = self.getdocloc(object)
1266 if docloc is not None:
1267 result = result + self.section('MODULE REFERENCE', docloc + """
1268
1269The following documentation is automatically generated from the Python
1270source files. It may be incomplete, incorrect or include features that
1271are considered implementation detail and may vary between Python
1272implementations. When in doubt, consult the module reference at the
1273location listed above.
1274""")
1275
1276 if desc:
1277 result = result + self.section('DESCRIPTION', desc)
1278
1279 classes = []
1280 for key, value in inspect.getmembers(object, inspect.isclass):
1281 # if __all__ exists, believe it. Otherwise use old heuristic.
1282 if (all is not None
1283 or (inspect.getmodule(value) or object) is object):
1284 if visiblename(key, all, object):
1285 classes.append((key, value))
1286 funcs = []
1287 for key, value in inspect.getmembers(object, inspect.isroutine):
1288 # if __all__ exists, believe it. Otherwise use old heuristic.
1289 if (all is not None or
1290 inspect.isbuiltin(value) or inspect.getmodule(value) is object):
1291 if visiblename(key, all, object):
1292 funcs.append((key, value))
1293 data = []
1294 for key, value in inspect.getmembers(object, isdata):
1295 if visiblename(key, all, object):
1296 data.append((key, value))
1297
1298 modpkgs = []
1299 modpkgs_names = set()
1300 if hasattr(object, '__path__'):
1301 for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
1302 modpkgs_names.add(modname)
1303 if ispkg:
1304 modpkgs.append(modname + ' (package)')
1305 else:
1306 modpkgs.append(modname)
1307
1308 modpkgs.sort()
1309 result = result + self.section(
1310 'PACKAGE CONTENTS', '\n'.join(modpkgs))
1311
1312 # Detect submodules as sometimes created by C extensions
1313 submodules = []
1314 for key, value in inspect.getmembers(object, inspect.ismodule):
1315 if value.__name__.startswith(name + '.') and key not in modpkgs_names:
1316 submodules.append(key)

Callers

nothing calls this directly

Calls 15

sectionMethod · 0.95
formattreeMethod · 0.95
docotherMethod · 0.95
splitdocFunction · 0.85
visiblenameFunction · 0.85
strFunction · 0.85
getdoclocMethod · 0.80
getmembersMethod · 0.80
iter_modulesMethod · 0.80
startswithMethod · 0.80
documentMethod · 0.80
stripMethod · 0.80

Tested by

no test coverage detected