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

Method docclass

Lib/pydoc.py:910–1065  ·  view source on GitHub ↗

Produce HTML documentation for a class object.

(self, object, name=None, mod=None, funcs={}, classes={},
                 *ignored)

Source from the content-addressed store, hash-verified

908 return result
909
910 def docclass(self, object, name=None, mod=None, funcs={}, classes={},
911 *ignored):
912 """Produce HTML documentation for a class object."""
913 realname = object.__name__
914 name = name or realname
915 bases = object.__bases__
916
917 contents = []
918 push = contents.append
919
920 # Cute little class to pump out a horizontal rule between sections.
921 class HorizontalRule:
922 def __init__(self):
923 self.needone = 0
924 def maybe(self):
925 if self.needone:
926 push('<hr>\n')
927 self.needone = 1
928 hr = HorizontalRule()
929
930 # List the mro, if non-trivial.
931 mro = deque(inspect.getmro(object))
932 if len(mro) > 2:
933 hr.maybe()
934 push('<dl><dt>Method resolution order:</dt>\n')
935 for base in mro:
936 push('<dd>%s</dd>\n' % self.classlink(base,
937 object.__module__))
938 push('</dl>\n')
939
940 def spill(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 try:
947 value = getattr(object, name)
948 except Exception:
949 # Some descriptors may meet a failure in their __get__.
950 # (bug #1785)
951 push(self.docdata(value, name, mod))
952 else:
953 push(self.document(value, name, mod,
954 funcs, classes, mdict, object, homecls))
955 push('\n')
956 return attrs
957
958 def spilldescriptors(msg, attrs, predicate):
959 ok, attrs = _split_list(attrs, predicate)
960 if ok:
961 hr.maybe()
962 push(msg)
963 for name, kind, homecls, value in ok:
964 push(self.docdata(value, name, mod))
965 return attrs
966
967 def spilldata(msg, attrs, predicate):

Callers 2

documentMethod · 0.45

Calls 14

maybeMethod · 0.95
classlinkMethod · 0.95
markupMethod · 0.95
sectionMethod · 0.95
visiblenameFunction · 0.85
_split_listFunction · 0.85
sort_attributesFunction · 0.85
_getargspecFunction · 0.85
escapeMethod · 0.80
HorizontalRuleClass · 0.70
classify_class_attrsFunction · 0.70
getdocFunction · 0.70

Tested by 1