Process the ``pending_configfield_xref`` nodes during the
    ``doctree-resolved`` event to insert links to the locations of
    configuration field nodes.

    See also
    --------
    `format_configfield_id`
    `configfield_ref_role`
    `pending_configfield_xref`

def process_pending_configfield_xref_nodes(app, doctree, fromdocname):
    """Process the ``pending_configfield_xref`` nodes during the
    ``doctree-resolved`` event to insert links to the locations of
    configuration field nodes.

    See also
    --------
    `format_configfield_id`
    `configfield_ref_role`
    `pending_configfield_xref`
    """
    logger = getLogger(__name__)
    env = app.builder.env

    for node in doctree.traverse(pending_configfield_xref):
        content = []

        # The source is the text the user entered into the role, which is
        # the importable name of the config class's and the attribute
        role_parts = split_role_content(node.rawsource)
        namespace_components = role_parts['ref'].split('.')
        field_name = namespace_components[-1]
        class_namespace = namespace_components[:-1]
        configfield_id = format_configfield_id(class_namespace, field_name)
        if role_parts['display']:
            # user's custom display text
            display_text = role_parts['display']
        elif role_parts['last_component']:
            # just the name of the class
            display_text = role_parts['ref'].split('.')[-1]
        else:
            display_text = role_parts['ref']
        link_label = nodes.literal()
        link_label += nodes.Text(display_text, display_text)

        if hasattr(env, 'lsst_configfields') \
                and configfield_id in env.lsst_configfields:
            # A config field topic is available
            configfield_data = env.lsst_configfields[configfield_id]

            ref_node = nodes.reference('', '')
            ref_node['refdocname'] = configfield_data['docname']
            ref_node['refuri'] = app.builder.get_relative_uri(
                fromdocname, configfield_data['docname'])
            ref_node['refuri'] += '#' + configfield_id

            ref_node += link_label

            content.append(ref_node)

        else:
            # Fallback if the config field isn't known. Just print the Config
            # field attribute name
            literal_node = nodes.literal()
            link_label = nodes.Text(field_name, field_name)
            literal_node += link_label

            content.append(literal_node)

            message = 'lsst-config-field could not find a reference to %s'
            logger.warning(message, role_parts['ref'], location=node)

        # replacing the pending_configfield_xref node with this reference
        node.replace_self(content)