Process the ``pending_task_xref`` nodes during the ``doctree-resolved``
    event to insert links to the locations of ``lsst-task-topic`` directives.

def process_pending_task_xref_nodes(app, doctree, fromdocname):
    """Process the ``pending_task_xref`` nodes during the ``doctree-resolved``
    event to insert links to the locations of ``lsst-task-topic`` directives.
    """
    logger = getLogger(__name__)
    env = app.builder.env

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

        # The source of the node is the class name the user entered via the
        # lsst-task-topic role. For example:
        # lsst.pipe.tasks.processCcd.ProcessCcdTask
        role_parts = split_role_content(node.rawsource)
        task_id = format_task_id(role_parts['ref'])
        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_task_topics') and \
                task_id in env.lsst_task_topics:
            # A task topic, marked up with the lsst-task-topic directive is
            # available
            task_data = env.lsst_task_topics[task_id]

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

            ref_node += link_label

            content.append(ref_node)

        else:
            # Fallback if the task topic isn't known. Just print the label text
            content.append(link_label)

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

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