code: def build_api_toc(source_path: Path, docs_root: Path):
      nav_entries: List[Any] = []
  
      for child in source_path.iterdir():
          if child.is_dir():
              nav_subsection = build_api_toc(child, docs_root)
          elif child.suffix == ".md":
              nav_subsection = str(child.relative_to(docs_root))
          nav_entries.append({child.stem: nav_subsection})
  
      nav_entries.sort(key=lambda x: list(x)[0], reverse=False)
      return nav_entries
  
file_path: allennlp/scripts/build_docs_config.py
imports: import argparse
  from pathlib import Path
  from typing import Any, List
  from ruamel.yaml import YAML
  from allennlp.version import VERSION
label_desc: Use image node_id 2 for calling a global function with example usage: build_api_toc(source_path, docs_root) and returns: nav_entries