'Resolve reference generated by the "any" role.'

def resolve_anyref(self, refdoc, node, contnode):

    stddomain = self.env.get_domain('std')
    target = node['reftarget']
    results = []
    doc_ref = stddomain.resolve_xref(self.env, refdoc, self.app.builder, 'doc', target, node, contnode)
    if doc_ref:
        results.append(('doc', doc_ref))
    results.extend(stddomain.resolve_any_xref(self.env, refdoc, self.app.builder, target, node, contnode))
    for domain in self.env.domains.values():
        if (domain.name == 'std'):
            continue
        try:
            results.extend(domain.resolve_any_xref(self.env, refdoc, self.app.builder, target, node, contnode))
        except NotImplementedError:
            for role in domain.roles:
                res = domain.resolve_xref(self.env, refdoc, self.app.builder, role, target, node, contnode)
                if (res and isinstance(res[0], nodes.Element)):
                    results.append((('%s:%s' % (domain.name, role)), res))
    if (not results):
        return None
    if (len(results) > 1):
        nice_results = '    or    '.join(((':%s:' % r[0]) for r in results))
        logger.warning(__("more    than    one    target    found    for    'any'    cross-reference    %r:    could    be    %s"), target, nice_results, location=node)
    (res_role, newnode) = results[0]
    res_domain = res_role.split(':')[0]
    if (newnode and newnode[0].get('classes')):
        newnode[0]['classes'].append(res_domain)
        newnode[0]['classes'].append(res_role.replace(':', '-'))
    return newnode
