(self, object, name=None, mod=None, cl=None)
Produce text documentation for a function or method object.
Produce text documentation for a function or method object.
Produce text documentation for a function or method object .
def docroutine(self, object, name=None, mod=None, cl=None):
        """Produce text documentation for a function or method object."""
        realname = object.__name__
        name = name or realname
        note = ''
        skipdocs = 0
        if _is_bound_method(object):
            imclass = object.__self__.__class__
            if cl:
                if imclass is not cl:
                    note = ' from ' + classname(imclass, mod)
            else:
                if object.__self__ is not None:
                    note = ' method of %s instance' % classname(
                        object.__self__.__class__, mod)
                else:
                    note = ' unbound %s method' % classname(imclass,mod)

        if (inspect.iscoroutinefunction(object) or
                inspect.isasyncgenfunction(object)):
            asyncqualifier = 'async '
        else:
            asyncqualifier = ''

        if name == realname:
            title = self.bold(realname)
        else:
            if cl and inspect.getattr_static(cl, realname, []) is object:
                skipdocs = 1
            title = self.bold(name) + ' = ' + realname
        argspec = None

        if inspect.isroutine(object):
            try:
                signature = inspect.signature(object)
            except (ValueError, TypeError):
                signature = None
            if signature:
                argspec = str(signature)
                if realname == '<lambda>':
                    title = self.bold(name) + ' lambda '
                    # XXX lambda's won't usually have func_annotations['return']
                    # since the syntax doesn't support but it is possible.
                    # So removing parentheses isn't truly safe.
                    argspec = argspec[1:-1] # remove parentheses
        if not argspec:
            argspec = '(...)'
        decl = asyncqualifier + title + argspec + note

        if skipdocs:
            return decl + '\n'
        else:
            doc = getdoc(object) or ''
            return decl + '\n' + (doc and self.indent(doc).rstrip() + '\n')
def docroutine ( self , object , name = None , mod = None , cl = None ) : realname = object . __name__ name = name or realname note = '' skipdocs = 0 if _is_bound_method ( object ) : imclass = object . __self__ . __class__ if cl : if imclass is not cl : note = ' from ' + classname ( imclass , mod ) else : if object . __self__ is not None : note = ' method of %s instance' % classname ( object . __self__ . __class__ , mod ) else : note = ' unbound %s method' % classname ( imclass , mod ) if ( inspect . iscoroutinefunction ( object ) or inspect . isasyncgenfunction ( object ) ) : asyncqualifier = 'async ' else : asyncqualifier = '' if name == realname : title = self . bold ( realname ) else : if cl and inspect . getattr_static ( cl , realname , [ ] ) is object : skipdocs = 1 title = self . bold ( name ) + ' = ' + realname argspec = None if inspect . isroutine ( object ) : try : signature = inspect . signature ( object ) except ( ValueError , TypeError ) : signature = None if signature : argspec = str ( signature ) if realname == '<lambda>' : title = self . bold ( name ) + ' lambda ' # XXX lambda's won't usually have func_annotations['return'] # since the syntax doesn't support but it is possible. # So removing parentheses isn't truly safe. argspec = argspec [ 1 : - 1 ] # remove parentheses if not argspec : argspec = '(...)' decl = asyncqualifier + title + argspec + note if skipdocs : return decl + '\n' else : doc = getdoc ( object ) or '' return decl + '\n' + ( doc and self . indent ( doc ) . rstrip ( ) + '\n' )