MCPcopy Index your code
hub / github.com/RustPython/RustPython / docclass

Method docclass

Lib/pydoc.py:955–1110  ·  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

953 return result
954
955 def docclass(self, object, name=None, mod=None, funcs={}, classes={},
956 *ignored):
957 """Produce HTML documentation for a class object."""
958 realname = object.__name__
959 name = name or realname
960 bases = object.__bases__
961
962 contents = []
963 push = contents.append
964
965 # Cute little class to pump out a horizontal rule between sections.
966 class HorizontalRule:
967 def __init__(self):
968 self.needone = 0
969 def maybe(self):
970 if self.needone:
971 push('<hr>\n')
972 self.needone = 1
973 hr = HorizontalRule()
974
975 # List the mro, if non-trivial.
976 mro = deque(inspect.getmro(object))
977 if len(mro) > 2:
978 hr.maybe()
979 push('<dl><dt>Method resolution order:</dt>\n')
980 for base in mro:
981 push('<dd>%s</dd>\n' % self.classlink(base,
982 object.__module__))
983 push('</dl>\n')
984
985 def spill(msg, attrs, predicate):
986 ok, attrs = _split_list(attrs, predicate)
987 if ok:
988 hr.maybe()
989 push(msg)
990 for name, kind, homecls, value in ok:
991 try:
992 value = getattr(object, name)
993 except Exception:
994 # Some descriptors may meet a failure in their __get__.
995 # (bug #1785)
996 push(self.docdata(value, name, mod))
997 else:
998 push(self.document(value, name, mod,
999 funcs, classes, mdict, object, homecls))
1000 push('\n')
1001 return attrs
1002
1003 def spilldescriptors(msg, attrs, predicate):
1004 ok, attrs = _split_list(attrs, predicate)
1005 if ok:
1006 hr.maybe()
1007 push(msg)
1008 for name, kind, homecls, value in ok:
1009 push(self.docdata(value, name, mod))
1010 return attrs
1011
1012 def spilldata(msg, attrs, predicate):

Callers 2

documentMethod · 0.45

Calls 15

maybeMethod · 0.95
classlinkMethod · 0.95
markupMethod · 0.95
sectionMethod · 0.95
lenFunction · 0.85
visiblenameFunction · 0.85
getattrFunction · 0.85
_split_listFunction · 0.85
sort_attributesFunction · 0.85
_getargspecFunction · 0.85
popleftMethod · 0.80
escapeMethod · 0.80

Tested by 1