def markup_func_ref_sphinx3()

in sphinx/automarkup.py [0:0]


def markup_func_ref_sphinx3(docname, app, match):
    class_str = ['c-func', 'c-macro']
    reftype_str = ['function', 'macro']

    cdom = app.env.domains['c']
    #
    # Go through the dance of getting an xref out of the C domain
    #
    base_target = match.group(2)
    target_text = nodes.Text(match.group(0))
    xref = None
    possible_targets = [base_target]
    # Check if this document has a namespace, and if so, try
    # cross-referencing inside it first.
    if c_namespace:
        possible_targets.insert(0, c_namespace + "." + base_target)

    if base_target not in Skipnames:
        for target in possible_targets:
            if target not in Skipfuncs:
                for class_s, reftype_s in zip(class_str, reftype_str):
                    lit_text = nodes.literal(classes=['xref', 'c', class_s])
                    lit_text += target_text
                    pxref = addnodes.pending_xref('', refdomain = 'c',
                                                  reftype = reftype_s,
                                                  reftarget = target, modname = None,
                                                  classname = None)
                    #
                    # XXX The Latex builder will throw NoUri exceptions here,
                    # work around that by ignoring them.
                    #
                    try:
                        xref = cdom.resolve_xref(app.env, docname, app.builder,
                                                 reftype_s, target, pxref,
                                                 lit_text)
                    except NoUri:
                        xref = None

                    if xref:
                        return xref

    return target_text