Produce text documentation for a function or method object.
(self, object, name=None, mod=None, cl=None, homecls=None)
| 1565 | return '=' + self.repr(object) |
| 1566 | |
| 1567 | def docroutine(self, object, name=None, mod=None, cl=None, homecls=None): |
| 1568 | """Produce text documentation for a function or method object.""" |
| 1569 | realname = object.__name__ |
| 1570 | name = name or realname |
| 1571 | if homecls is None: |
| 1572 | homecls = cl |
| 1573 | note = '' |
| 1574 | skipdocs = False |
| 1575 | imfunc = None |
| 1576 | if _is_bound_method(object): |
| 1577 | imself = object.__self__ |
| 1578 | if imself is cl: |
| 1579 | imfunc = getattr(object, '__func__', None) |
| 1580 | elif inspect.isclass(imself): |
| 1581 | note = ' class method of %s' % classname(imself, mod) |
| 1582 | else: |
| 1583 | note = ' method of %s instance' % classname( |
| 1584 | imself.__class__, mod) |
| 1585 | elif (inspect.ismethoddescriptor(object) or |
| 1586 | inspect.ismethodwrapper(object)): |
| 1587 | try: |
| 1588 | objclass = object.__objclass__ |
| 1589 | except AttributeError: |
| 1590 | pass |
| 1591 | else: |
| 1592 | if cl is None: |
| 1593 | note = ' unbound %s method' % classname(objclass, mod) |
| 1594 | elif objclass is not homecls: |
| 1595 | note = ' from ' + classname(objclass, mod) |
| 1596 | else: |
| 1597 | imfunc = object |
| 1598 | if inspect.isfunction(imfunc) and homecls is not None and ( |
| 1599 | imfunc.__module__ != homecls.__module__ or |
| 1600 | imfunc.__qualname__ != homecls.__qualname__ + '.' + realname): |
| 1601 | pname = parentname(imfunc, mod) |
| 1602 | if pname: |
| 1603 | note = ' from %s' % pname |
| 1604 | |
| 1605 | if (inspect.iscoroutinefunction(object) or |
| 1606 | inspect.isasyncgenfunction(object)): |
| 1607 | asyncqualifier = 'async ' |
| 1608 | else: |
| 1609 | asyncqualifier = '' |
| 1610 | |
| 1611 | if name == realname: |
| 1612 | title = self.bold(realname) |
| 1613 | else: |
| 1614 | if (cl is not None and |
| 1615 | inspect.getattr_static(cl, realname, []) is object): |
| 1616 | skipdocs = True |
| 1617 | if note.startswith(' from '): |
| 1618 | note = '' |
| 1619 | title = self.bold(name) + ' = ' + realname |
| 1620 | argspec = None |
| 1621 | |
| 1622 | if inspect.isroutine(object): |
| 1623 | argspec = _getargspec(object) |
| 1624 | if argspec and realname == '<lambda>': |
nothing calls this directly
no test coverage detected