Produce HTML documentation for a module object.
(self, object, name=None, mod=None, *ignored)
| 835 | return '<dl>\n%s</dl>\n' % result |
| 836 | |
| 837 | def docmodule(self, object, name=None, mod=None, *ignored): |
| 838 | """Produce HTML documentation for a module object.""" |
| 839 | name = object.__name__ # ignore the passed-in name |
| 840 | try: |
| 841 | all = object.__all__ |
| 842 | except AttributeError: |
| 843 | all = None |
| 844 | parts = name.split('.') |
| 845 | links = [] |
| 846 | for i in range(len(parts)-1): |
| 847 | links.append( |
| 848 | '<a href="%s.html" class="white">%s</a>' % |
| 849 | ('.'.join(parts[:i+1]), parts[i])) |
| 850 | linkedname = '.'.join(links + parts[-1:]) |
| 851 | head = '<strong class="title">%s</strong>' % linkedname |
| 852 | try: |
| 853 | path = inspect.getabsfile(object) |
| 854 | url = urllib.parse.quote(path) |
| 855 | filelink = self.filelink(url, path) |
| 856 | except TypeError: |
| 857 | filelink = '(built-in)' |
| 858 | info = [] |
| 859 | if hasattr(object, '__version__'): |
| 860 | version = str(object.__version__) |
| 861 | if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': |
| 862 | version = version[11:-1].strip() |
| 863 | info.append('version %s' % self.escape(version)) |
| 864 | if hasattr(object, '__date__'): |
| 865 | info.append(self.escape(str(object.__date__))) |
| 866 | if info: |
| 867 | head = head + ' (%s)' % ', '.join(info) |
| 868 | docloc = self.getdocloc(object) |
| 869 | if docloc is not None: |
| 870 | docloc = '<br><a href="%(docloc)s">Module Reference</a>' % locals() |
| 871 | else: |
| 872 | docloc = '' |
| 873 | result = self.heading(head, '<a href=".">index</a><br>' + filelink + docloc) |
| 874 | |
| 875 | modules = inspect.getmembers(object, inspect.ismodule) |
| 876 | |
| 877 | classes, cdict = [], {} |
| 878 | for key, value in inspect.getmembers(object, inspect.isclass): |
| 879 | # if __all__ exists, believe it. Otherwise use old heuristic. |
| 880 | if (all is not None or |
| 881 | (inspect.getmodule(value) or object) is object): |
| 882 | if visiblename(key, all, object): |
| 883 | classes.append((key, value)) |
| 884 | cdict[key] = cdict[value] = '#' + key |
| 885 | for key, value in classes: |
| 886 | for base in value.__bases__: |
| 887 | key, modname = base.__name__, base.__module__ |
| 888 | module = sys.modules.get(modname) |
| 889 | if modname != name and module and hasattr(module, key): |
| 890 | if getattr(module, key) is base: |
| 891 | if not key in cdict: |
| 892 | cdict[key] = cdict[base] = modname + '.html#' + key |
| 893 | funcs, fdict = [], {} |
| 894 | for key, value in inspect.getmembers(object, inspect.isroutine): |