'Produce HTML documentation for a function or method object.'

def docroutine(self, object, name=None, mod=None, funcs={}, classes={}, methods={}, cl=None):

    realname = object.__name__
    name = (name or realname)
    anchor = ((((cl and cl.__name__) or '') + '-') + name)
    note = ''
    skipdocs = 0
    if inspect.ismethod(object):
        imclass = object.im_class
        if cl:
            if (imclass is not cl):
                note = ('    from    ' + self.classlink(imclass, mod))
        elif (object.im_self is not None):
            note = ('    method    of    %s    instance' % self.classlink(object.im_self.__class__, mod))
        else:
            note = ('    unbound    %s    method' % self.classlink(imclass, mod))
        object = object.im_func
    if (name == realname):
        title = ('<a    name="%s"><strong>%s</strong></a>' % (anchor, realname))
    else:
        if (cl and (realname in cl.__dict__) and (cl.__dict__[realname] is object)):
            reallink = ('<a    href="#%s">%s</a>' % (((cl.__name__ + '-') + realname), realname))
            skipdocs = 1
        else:
            reallink = realname
        title = ('<a    name="%s"><strong>%s</strong></a>    =    %s' % (anchor, name, reallink))
    if inspect.isfunction(object):
        (args, varargs, varkw, defaults) = inspect.getargspec(object)
        argspec = inspect.formatargspec(args, varargs, varkw, defaults, formatvalue=self.formatvalue)
        if (realname == '<lambda>'):
            title = ('<strong>%s</strong>    <em>lambda</em>    ' % name)
            argspec = argspec[1:(-1)]
    else:
        argspec = '(...)'
    decl = ((title + argspec) + (note and self.grey(('<font    face="helvetica,    arial">%s</font>' % note))))
    if skipdocs:
        return ('<dl><dt>%s</dt></dl>\n' % decl)
    else:
        doc = self.markup(getdoc(object), self.preformat, funcs, classes, methods)
        doc = (doc and ('<dd><tt>%s</tt></dd>' % doc))
        return ('<dl><dt>%s</dt>%s</dl>\n' % (decl, doc))
