Produce HTML documentation for a class object.
(self, object, name=None, mod=None, funcs={}, classes={},
*ignored)
| 890 | return result |
| 891 | |
| 892 | def docclass(self, object, name=None, mod=None, funcs={}, classes={}, |
| 893 | *ignored): |
| 894 | """Produce HTML documentation for a class object.""" |
| 895 | realname = object.__name__ |
| 896 | name = name or realname |
| 897 | bases = object.__bases__ |
| 898 | |
| 899 | contents = [] |
| 900 | push = contents.append |
| 901 | |
| 902 | # Cute little class to pump out a horizontal rule between sections. |
| 903 | class HorizontalRule: |
| 904 | def __init__(self): |
| 905 | self.needone = 0 |
| 906 | def maybe(self): |
| 907 | if self.needone: |
| 908 | push('<hr>\n') |
| 909 | self.needone = 1 |
| 910 | hr = HorizontalRule() |
| 911 | |
| 912 | # List the mro, if non-trivial. |
| 913 | mro = deque(inspect.getmro(object)) |
| 914 | if len(mro) > 2: |
| 915 | hr.maybe() |
| 916 | push('<dl><dt>Method resolution order:</dt>\n') |
| 917 | for base in mro: |
| 918 | push('<dd>%s</dd>\n' % self.classlink(base, |
| 919 | object.__module__)) |
| 920 | push('</dl>\n') |
| 921 | |
| 922 | def spill(msg, attrs, predicate): |
| 923 | ok, attrs = _split_list(attrs, predicate) |
| 924 | if ok: |
| 925 | hr.maybe() |
| 926 | push(msg) |
| 927 | for name, kind, homecls, value in ok: |
| 928 | try: |
| 929 | value = getattr(object, name) |
| 930 | except Exception: |
| 931 | # Some descriptors may meet a failure in their __get__. |
| 932 | # (bug #1785) |
| 933 | push(self.docdata(value, name, mod)) |
| 934 | else: |
| 935 | push(self.document(value, name, mod, |
| 936 | funcs, classes, mdict, object, homecls)) |
| 937 | push('\n') |
| 938 | return attrs |
| 939 | |
| 940 | def spilldescriptors(msg, attrs, predicate): |
| 941 | ok, attrs = _split_list(attrs, predicate) |
| 942 | if ok: |
| 943 | hr.maybe() |
| 944 | push(msg) |
| 945 | for name, kind, homecls, value in ok: |
| 946 | push(self.docdata(value, name, mod)) |
| 947 | return attrs |
| 948 | |
| 949 | def spilldata(msg, attrs, predicate): |
no test coverage detected