{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Recursively build a nested toctree dict rooted at "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "current_path"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Walks the flat toctree adjacency map "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "unnest"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " ("
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "node -> list of child references as written in the source"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") and returns a nested "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "{child_path: {grandchild_path: {...}}}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " dict describing the tree reachable from "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "current_path"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "DefList",
          "__tag": 4033,
          "children": [
            {
              "__type": "DefListItem",
              "__tag": 4037,
              "dt": {
                "__type": "Paragraph",
                "__tag": 4045,
                "children": [
                  {
                    "__type": "Text",
                    "__tag": 4046,
                    "value": "Path model:"
                  }
                ]
              },
              "dd": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Nodes are addressed with "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": ":"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "-separated keys (e.g.     "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "pkg:sub:page"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "); the last segment is the page name and the prefix     is its \"directory\". Child references in "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "unnest"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " are written in     source form using "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "/"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and may be relative ("
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "../sibling"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ",     "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "sub/page"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "). For each child reference this function:"
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "drops empty entries,"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "skips absolute ("
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "/..."
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ") and external ("
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "https://"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ") refs,"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "rewrites a trailing "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "/"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " to "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "/index"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " (Sphinx directory-index       convention),"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "resolves "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": ".."
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " segments against "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "current_path"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "'s directory       via "
                            },
                            {
                              "__type": "CrossRef",
                              "__tag": 4002,
                              "value": "dotdotcount",
                              "reference": {
                                "__type": "LocalRef",
                                "__tag": 4022,
                                "kind": "module",
                                "path": "papyri.toc:dotdotcount"
                              },
                              "kind": "module"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ","
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "strips a trailing "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": ".rst"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ","
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "then recurses."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DefListItem",
              "__tag": 4037,
              "dt": {
                "__type": "Paragraph",
                "__tag": 4045,
                "children": [
                  {
                    "__type": "Text",
                    "__tag": 4046,
                    "value": "Side effects / bookkeeping:"
                  }
                ]
              },
              "dd": [
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "counter"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " maps every known node to a visit count. It is       incremented for "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "current_path"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " on entry, so callers can detect       nodes referenced 0 times (orphans) or >1 times (multi-parent).       A reference whose resolved path is not in "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "counter"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " is treated       as dangling and skipped with a printed warning."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "Asserts that the resolved child path is neither "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "current_path"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "       itself nor already present among siblings — i.e. the input must       describe a tree, not a DAG with duplicate edges."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "depth"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is informational only (used by the commented-out debug prints); it does not affect the result."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/papyri/toc.py",
  "item_line": 25,
  "item_type": "function",
  "aliases": [
    "papyri.toc._tree"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "current_path",
        "annotation": "str",
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "unnest",
        "annotation": "dict[str, list[str]]",
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "counter",
        "annotation": "dict[str, int]",
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "depth",
        "annotation": "int",
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "0"
      }
    ],
    "return_annotation": "dict[str, Any]",
    "target_name": "_tree"
  },
  "references": null,
  "qa": "papyri.toc:_tree",
  "arbitrary": [],
  "local_refs": []
}