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

Method docroutine

Lib/pydoc.py:1116–1198  ·  view source on GitHub ↗

Produce HTML documentation for a function or method object.

(self, object, name=None, mod=None,
                   funcs={}, classes={}, methods={}, cl=None, homecls=None)

Source from the content-addressed store, hash-verified

1114 return self.grey('=' + self.repr(object))
1115
1116 def docroutine(self, object, name=None, mod=None,
1117 funcs={}, classes={}, methods={}, cl=None, homecls=None):
1118 """Produce HTML documentation for a function or method object."""
1119 realname = object.__name__
1120 name = name or realname
1121 if homecls is None:
1122 homecls = cl
1123 anchor = ('' if cl is None else cl.__name__) + '-' + name
1124 note = ''
1125 skipdocs = False
1126 imfunc = None
1127 if _is_bound_method(object):
1128 imself = object.__self__
1129 if imself is cl:
1130 imfunc = getattr(object, '__func__', None)
1131 elif inspect.isclass(imself):
1132 note = ' class method of %s' % self.classlink(imself, mod)
1133 else:
1134 note = ' method of %s instance' % self.classlink(
1135 imself.__class__, mod)
1136 elif (inspect.ismethoddescriptor(object) or
1137 inspect.ismethodwrapper(object)):
1138 try:
1139 objclass = object.__objclass__
1140 except AttributeError:
1141 pass
1142 else:
1143 if cl is None:
1144 note = ' unbound %s method' % self.classlink(objclass, mod)
1145 elif objclass is not homecls:
1146 note = ' from ' + self.classlink(objclass, mod)
1147 else:
1148 imfunc = object
1149 if inspect.isfunction(imfunc) and homecls is not None and (
1150 imfunc.__module__ != homecls.__module__ or
1151 imfunc.__qualname__ != homecls.__qualname__ + '.' + realname):
1152 pname = self.parentlink(imfunc, mod)
1153 if pname:
1154 note = ' from %s' % pname
1155
1156 if (inspect.iscoroutinefunction(object) or
1157 inspect.isasyncgenfunction(object)):
1158 asyncqualifier = 'async '
1159 else:
1160 asyncqualifier = ''
1161
1162 if name == realname:
1163 title = '<a name="%s"><strong>%s</strong></a>' % (anchor, realname)
1164 else:
1165 if (cl is not None and
1166 inspect.getattr_static(cl, realname, []) is object):
1167 reallink = '<a href="#%s">%s</a>' % (
1168 cl.__name__ + '-' + realname, realname)
1169 skipdocs = True
1170 if note.startswith(' from '):
1171 note = ''
1172 else:
1173 reallink = realname

Callers 1

documentMethod · 0.45

Calls 10

classlinkMethod · 0.95
parentlinkMethod · 0.95
greyMethod · 0.95
markupMethod · 0.95
_is_bound_methodFunction · 0.85
getattrFunction · 0.85
_getargspecFunction · 0.85
escapeMethod · 0.80
getdocFunction · 0.70
startswithMethod · 0.45

Tested by

no test coverage detected