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

Function _write_module

scripts/docs/generate_node_library_reference.py:399–426  ·  view source on GitHub ↗
(output_dir: Path, module: ModuleDoc, position: int)

Source from the content-addressed store, hash-verified

397
398
399def _write_module(output_dir: Path, module: ModuleDoc, position: int) -> None:
400 lines = [
401 frontmatter(module.title, module.description, position),
402 f"Generated from `{display_path(module.source, resolve=True)}`.\n\n",
403 f"Import from `{module.import_path}`.\n\n",
404 ]
405 if module.description:
406 lines.append(f"{_escape_text(module.description)}\n\n")
407
408 name_counts: dict[str, int] = {}
409 for item in module.items:
410 name_counts[item.name] = name_counts.get(item.name, 0) + 1
411
412 for kind in SECTION_ORDER:
413 items = [item for item in module.items if item.kind == kind]
414 if not items:
415 continue
416 lines.append(f"## {SECTION_TITLES[kind]}\n\n")
417 for item in items:
418 _write_item(lines, item, disambiguate=name_counts[item.name] > 1)
419
420 if module.reexports:
421 lines.append("## Re-exports\n\n")
422 for name in module.reexports:
423 lines.append(f"- `{name}`\n")
424 lines.append("\n")
425
426 (output_dir / f"{_slug(module.import_path)}.mdx").write_text("".join(lines), encoding="utf-8")
427
428
429def generate(package_root: Path, output_dir: Path) -> int:

Callers 1

generateFunction · 0.70

Calls 7

frontmatterFunction · 0.90
display_pathFunction · 0.90
_write_itemFunction · 0.85
_slugFunction · 0.85
getMethod · 0.80
joinMethod · 0.80
_escape_textFunction · 0.70

Tested by

no test coverage detected