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

Method docroutine

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

1069 return self.grey('=' + self.repr(object))
1070
1071 def docroutine(self, object, name=None, mod=None,
1072 funcs={}, classes={}, methods={}, cl=None, homecls=None):
1073 """Produce HTML documentation for a function or method object."""
1074 realname = object.__name__
1075 name = name or realname
1076 if homecls is None:
1077 homecls = cl
1078 anchor = ('' if cl is None else cl.__name__) + '-' + name
1079 note = ''
1080 skipdocs = False
1081 imfunc = None
1082 if _is_bound_method(object):
1083 imself = object.__self__
1084 if imself is cl:
1085 imfunc = getattr(object, '__func__', None)
1086 elif inspect.isclass(imself):
1087 note = ' class method of %s' % self.classlink(imself, mod)
1088 else:
1089 note = ' method of %s instance' % self.classlink(
1090 imself.__class__, mod)
1091 elif (inspect.ismethoddescriptor(object) or
1092 inspect.ismethodwrapper(object)):
1093 try:
1094 objclass = object.__objclass__
1095 except AttributeError:
1096 pass
1097 else:
1098 if cl is None:
1099 note = ' unbound %s method' % self.classlink(objclass, mod)
1100 elif objclass is not homecls:
1101 note = ' from ' + self.classlink(objclass, mod)
1102 else:
1103 imfunc = object
1104 if inspect.isfunction(imfunc) and homecls is not None and (
1105 imfunc.__module__ != homecls.__module__ or
1106 imfunc.__qualname__ != homecls.__qualname__ + '.' + realname):
1107 pname = self.parentlink(imfunc, mod)
1108 if pname:
1109 note = ' from %s' % pname
1110
1111 if (inspect.iscoroutinefunction(object) or
1112 inspect.isasyncgenfunction(object)):
1113 asyncqualifier = 'async '
1114 else:
1115 asyncqualifier = ''
1116
1117 if name == realname:
1118 title = '<a name="%s"><strong>%s</strong></a>' % (anchor, realname)
1119 else:
1120 if (cl is not None and
1121 inspect.getattr_static(cl, realname, []) is object):
1122 reallink = '<a href="#%s">%s</a>' % (
1123 cl.__name__ + '-' + realname, realname)
1124 skipdocs = True
1125 if note.startswith(' from '):
1126 note = ''
1127 else:
1128 reallink = realname

Callers 1

documentMethod · 0.45

Calls 9

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

Tested by

no test coverage detected