(node, toc, docname)
return toc_reference
Logic that understands maps a specific node to it's part of the toctree.

    It takes a specific incoming ``node``,
    and returns the actual TOC Tree node that is said reference.
Logic that understands maps a specific node to it's part of the toctree.
Logic that understands maps a specific node to it s part of the toctree .
def _get_toc_reference(node, toc, docname):
    """
    Logic that understands maps a specific node to it's part of the toctree.

    It takes a specific incoming ``node``,
    and returns the actual TOC Tree node that is said reference.
    """
    if isinstance(node, nodes.section) and isinstance(node.parent, nodes.document):
        # Top Level Section header
        ref_id = docname
        toc_reference = _find_toc_node(toc, ref_id, nodes.section)
    elif isinstance(node, nodes.section):
        # Nested Section header
        ref_id = node.attributes["ids"][0]
        toc_reference = _find_toc_node(toc, ref_id, nodes.section)
    else:
        # Desc node
        try:
            ref_id = node.children[0].attributes["ids"][0]
            toc_reference = _find_toc_node(toc, ref_id, addnodes.desc)
        except (KeyError, IndexError):
            LOGGER.warning(
                "Invalid desc node",
                exc_info=True,
                type="autoapi",
                subtype="toc_reference",
            )
            toc_reference = None

    return toc_reference
def _get_toc_reference ( node , toc , docname ) : if isinstance ( node , nodes . section ) and isinstance ( node . parent , nodes . document ) : # Top Level Section header ref_id = docname toc_reference = _find_toc_node ( toc , ref_id , nodes . section ) elif isinstance ( node , nodes . section ) : # Nested Section header ref_id = node . attributes [ "ids" ] [ 0 ] toc_reference = _find_toc_node ( toc , ref_id , nodes . section ) else : # Desc node try : ref_id = node . children [ 0 ] . attributes [ "ids" ] [ 0 ] toc_reference = _find_toc_node ( toc , ref_id , addnodes . desc ) except ( KeyError , IndexError ) : LOGGER . warning ( "Invalid desc node" , exc_info = True , type = "autoapi" , subtype = "toc_reference" , ) toc_reference = None return toc_reference