MCPcopy Create free account
hub / github.com/NVIDIA/NeMo-Relay / _write_index

Function _write_index

scripts/docs/generate_python_library_reference.py:324–347  ·  view source on GitHub ↗
(output_dir: Path, modules: list[ModuleDoc])

Source from the content-addressed store, hash-verified

322
323
324def _write_index(output_dir: Path, modules: list[ModuleDoc]) -> None:
325 lines = [
326 frontmatter("Python Library Reference", "Generated Python API reference for the nemo_relay package.", 1),
327 "Generated from the local `python/nemo_relay` package source.\n\n",
328 "## Modules\n\n",
329 ]
330
331 by_parent: dict[tuple[str, ...], list[ModuleDoc]] = {}
332 for module in modules:
333 nav_parts = _nav_parts(module)
334 parent = tuple(nav_parts[:-1]) if len(_module_parts(module)) > 1 else ()
335 by_parent.setdefault(parent, []).append(module)
336
337 def write_group(parent: tuple[str, ...], depth: int) -> None:
338 for module in sorted(by_parent.get(parent, []), key=_sibling_sort_key):
339 indent = " " * depth
340 lines.append(f"{indent}- [`{_leaf_title(module)}`]({_module_url(module)})")
341 if module.summary:
342 lines.append(f": {module.summary}")
343 lines.append("\n")
344 write_group(tuple(_nav_parts(module)), depth + 1)
345
346 write_group((), 0)
347 (output_dir / "index.mdx").write_text("".join(lines), encoding="utf-8")
348
349
350def _write_module(output_dir: Path, module: ModuleDoc, position: int, modules: list[ModuleDoc]) -> None:

Callers 1

generateFunction · 0.70

Calls 5

frontmatterFunction · 0.90
_nav_partsFunction · 0.85
_module_partsFunction · 0.85
write_groupFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected