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