'Transform a Python signature into RST nodes.
Return (fully qualified name of the thing, classname if any).
If inside a class, the current class name is handled intelligently:
* it is stripped from the displayed name if present
* it is added to the full name (return value) if not present'

def handle_signature(self, sig, signode):

    m = py_sig_re.match(sig)
    if (m is None):
        raise ValueError
    (name_prefix, name, arglist, retann) = m.groups()
    modname = self.options.get('module', self.env.ref_context.get('py:module'))
    classname = self.env.ref_context.get('py:class')
    if classname:
        add_module = False
        if (name_prefix and name_prefix.startswith(classname)):
            fullname = (name_prefix + name)
            name_prefix = name_prefix[len(classname):].lstrip('.')
        elif name_prefix:
            fullname = (((classname + '.') + name_prefix) + name)
        else:
            fullname = ((classname + '.') + name)
    else:
        add_module = True
        if name_prefix:
            classname = name_prefix.rstrip('.')
            fullname = (name_prefix + name)
        else:
            classname = ''
            fullname = name
    signode['module'] = modname
    signode['class'] = classname
    signode['fullname'] = fullname
    sig_prefix = self.get_signature_prefix(sig)
    if sig_prefix:
        signode += addnodes.desc_annotation(sig_prefix, sig_prefix)
    if name_prefix:
        signode += addnodes.desc_addname(name_prefix, name_prefix)
    elif (add_module and self.env.config.add_module_names):
        modname = self.options.get('module', self.env.ref_context.get('py:module'))
        if (modname and (modname != 'exceptions')):
            nodetext = (modname + '.')
            signode += addnodes.desc_addname(nodetext, nodetext)
    anno = self.options.get('annotation')
    signode += addnodes.desc_name(name, name)
    if (not arglist):
        if self.needs_arglist():
            signode += addnodes.desc_parameterlist()
        if retann:
            signode += addnodes.desc_returns(retann, retann)
        if anno:
            signode += addnodes.desc_annotation(('    ' + anno), ('    ' + anno))
        return (fullname, name_prefix)
    _pseudo_parse_arglist(signode, arglist)
    if retann:
        signode += addnodes.desc_returns(retann, retann)
    if anno:
        signode += addnodes.desc_annotation(('    ' + anno), ('    ' + anno))
    return (fullname, name_prefix)
