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

Method docmodule

tools/python-3.11.9-amd64/Lib/pydoc.py:775–890  ·  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

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

Callers 1

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
stripMethod · 0.80
getdoclocMethod · 0.80

Tested by

no test coverage detected