MCPcopy Index your code
hub / github.com/python/cpython / docmodule

Method docmodule

Lib/pydoc.py:792–908  ·  view source on GitHub ↗

Produce HTML documentation for a module object.

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

Source from the content-addressed store, hash-verified

790 return '<dl>\n%s</dl>\n' % result
791
792 def docmodule(self, object, name=None, mod=None, *ignored):
793 """Produce HTML documentation for a module object."""
794 name = object.__name__ # ignore the passed-in name
795 try:
796 all = object.__all__
797 except AttributeError:
798 all = None
799 parts = name.split('.')
800 links = []
801 for i in range(len(parts)-1):
802 links.append(
803 '<a href="%s.html" class="white">%s</a>' %
804 ('.'.join(parts[:i+1]), parts[i]))
805 linkedname = '.'.join(links + parts[-1:])
806 head = '<strong class="title">%s</strong>' % linkedname
807 try:
808 path = inspect.getabsfile(object)
809 url = urllib.parse.quote(path)
810 filelink = self.filelink(url, path)
811 except TypeError:
812 filelink = '(built-in)'
813 info = []
814
815 if version := self._get_version(object):
816 if version[:11] == '$' + 'Revision: ' and version[-1:] == '$':
817 version = version[11:-1].strip()
818 info.append('version %s' % self.escape(version))
819 if hasattr(object, '__date__'):
820 info.append(self.escape(str(object.__date__)))
821 if info:
822 head = head + ' (%s)' % ', '.join(info)
823 docloc = self.getdocloc(object)
824 if docloc is not None:
825 docloc = '<br><a href="%(docloc)s">Module Reference</a>' % locals()
826 else:
827 docloc = ''
828 result = self.heading(head, '<a href=".">index</a><br>' + filelink + docloc)
829
830 modules = inspect.getmembers(object, inspect.ismodule)
831
832 classes, cdict = [], {}
833 for key, value in inspect.getmembers(object, inspect.isclass):
834 # if __all__ exists, believe it. Otherwise use old heuristic.
835 if (all is not None or
836 (inspect.getmodule(value) or object) is object):
837 if visiblename(key, all, object):
838 classes.append((key, value))
839 cdict[key] = cdict[value] = '#' + key
840 for key, value in classes:
841 for base in value.__bases__:
842 key, modname = base.__name__, base.__module__
843 module = sys.modules.get(modname)
844 if modname != name and module and hasattr(module, key):
845 if getattr(module, key) is base:
846 if not key in cdict:
847 cdict[key] = cdict[base] = modname + '.html#' + key
848 funcs, fdict = [], {}
849 for key, value in inspect.getmembers(object, inspect.isroutine):

Callers 3

get_pydoc_htmlFunction · 0.95
documentMethod · 0.45

Calls 15

filelinkMethod · 0.95
headingMethod · 0.95
markupMethod · 0.95
multicolumnMethod · 0.95
bigsectionMethod · 0.95
modulelinkMethod · 0.95
formattreeMethod · 0.95
strFunction · 0.85
visiblenameFunction · 0.85
quoteMethod · 0.80
escapeMethod · 0.80
getdoclocMethod · 0.80

Tested by 2

get_pydoc_htmlFunction · 0.76