MCPcopy Index your code
hub / github.com/RustPython/RustPython / docmodule

Method docmodule

Lib/pydoc.py:1311–1411  ·  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

1309 return result
1310
1311 def docmodule(self, object, name=None, mod=None, *ignored):
1312 """Produce text documentation for a given module object."""
1313 name = object.__name__ # ignore the passed-in name
1314 synop, desc = splitdoc(getdoc(object))
1315 result = self.section('NAME', name + (synop and ' - ' + synop))
1316 all = getattr(object, '__all__', None)
1317 docloc = self.getdocloc(object)
1318 if docloc is not None:
1319 result = result + self.section('MODULE REFERENCE', docloc + """
1320
1321The following documentation is automatically generated from the Python
1322source files. It may be incomplete, incorrect or include features that
1323are considered implementation detail and may vary between Python
1324implementations. When in doubt, consult the module reference at the
1325location listed above.
1326""")
1327
1328 if desc:
1329 result = result + self.section('DESCRIPTION', desc)
1330
1331 classes = []
1332 for key, value in inspect.getmembers(object, inspect.isclass):
1333 # if __all__ exists, believe it. Otherwise use old heuristic.
1334 if (all is not None
1335 or (inspect.getmodule(value) or object) is object):
1336 if visiblename(key, all, object):
1337 classes.append((key, value))
1338 funcs = []
1339 for key, value in inspect.getmembers(object, inspect.isroutine):
1340 # if __all__ exists, believe it. Otherwise use a heuristic.
1341 if (all is not None
1342 or inspect.isbuiltin(value)
1343 or (inspect.getmodule(value) or object) is object):
1344 if visiblename(key, all, object):
1345 funcs.append((key, value))
1346 data = []
1347 for key, value in inspect.getmembers(object, isdata):
1348 if visiblename(key, all, object):
1349 data.append((key, value))
1350
1351 modpkgs = []
1352 modpkgs_names = set()
1353 if hasattr(object, '__path__'):
1354 for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
1355 modpkgs_names.add(modname)
1356 if ispkg:
1357 modpkgs.append(modname + ' (package)')
1358 else:
1359 modpkgs.append(modname)
1360
1361 modpkgs.sort()
1362 result = result + self.section(
1363 'PACKAGE CONTENTS', '\n'.join(modpkgs))
1364
1365 # Detect submodules as sometimes created by C extensions
1366 submodules = []
1367 for key, value in inspect.getmembers(object, inspect.ismodule):
1368 if value.__name__.startswith(name + '.') and key not in modpkgs_names:

Callers 2

get_pydoc_textFunction · 0.95

Calls 15

sectionMethod · 0.95
formattreeMethod · 0.95
docotherMethod · 0.95
splitdocFunction · 0.85
getattrFunction · 0.85
visiblenameFunction · 0.85
setFunction · 0.85
hasattrFunction · 0.85
strFunction · 0.85
getdoclocMethod · 0.80
getmembersMethod · 0.80
documentMethod · 0.80

Tested by 2

get_pydoc_textFunction · 0.76