Produce text documentation for a function or method object.
(self, object, name=None, mod=None, cl=None, homecls=None)
| 1519 | return '=' + self.repr(object) |
| 1520 | |
| 1521 | def docroutine(self, object, name=None, mod=None, cl=None, homecls=None): |
| 1522 | """Produce text documentation for a function or method object.""" |
| 1523 | realname = object.__name__ |
| 1524 | name = name or realname |
| 1525 | if homecls is None: |
| 1526 | homecls = cl |
| 1527 | note = '' |
| 1528 | skipdocs = False |
| 1529 | imfunc = None |
| 1530 | if _is_bound_method(object): |
| 1531 | imself = object.__self__ |
| 1532 | if imself is cl: |
| 1533 | imfunc = getattr(object, '__func__', None) |
| 1534 | elif inspect.isclass(imself): |
| 1535 | note = ' class method of %s' % classname(imself, mod) |
| 1536 | else: |
| 1537 | note = ' method of %s instance' % classname( |
| 1538 | imself.__class__, mod) |
| 1539 | elif (inspect.ismethoddescriptor(object) or |
| 1540 | inspect.ismethodwrapper(object)): |
| 1541 | try: |
| 1542 | objclass = object.__objclass__ |
| 1543 | except AttributeError: |
| 1544 | pass |
| 1545 | else: |
| 1546 | if cl is None: |
| 1547 | note = ' unbound %s method' % classname(objclass, mod) |
| 1548 | elif objclass is not homecls: |
| 1549 | note = ' from ' + classname(objclass, mod) |
| 1550 | else: |
| 1551 | imfunc = object |
| 1552 | if inspect.isfunction(imfunc) and homecls is not None and ( |
| 1553 | imfunc.__module__ != homecls.__module__ or |
| 1554 | imfunc.__qualname__ != homecls.__qualname__ + '.' + realname): |
| 1555 | pname = parentname(imfunc, mod) |
| 1556 | if pname: |
| 1557 | note = ' from %s' % pname |
| 1558 | |
| 1559 | if (inspect.iscoroutinefunction(object) or |
| 1560 | inspect.isasyncgenfunction(object)): |
| 1561 | asyncqualifier = 'async ' |
| 1562 | else: |
| 1563 | asyncqualifier = '' |
| 1564 | |
| 1565 | if name == realname: |
| 1566 | title = self.bold(realname) |
| 1567 | else: |
| 1568 | if (cl is not None and |
| 1569 | inspect.getattr_static(cl, realname, []) is object): |
| 1570 | skipdocs = True |
| 1571 | if note.startswith(' from '): |
| 1572 | note = '' |
| 1573 | title = self.bold(name) + ' = ' + realname |
| 1574 | argspec = None |
| 1575 | |
| 1576 | if inspect.isroutine(object): |
| 1577 | argspec = _getargspec(object) |
| 1578 | if argspec and realname == '<lambda>': |
nothing calls this directly
no test coverage detected