Skip to content

docs: add API reference generators and navigation - #7057

Closed
dagil-nvidia wants to merge 4 commits into
mainfrom
dagil-nvidia/api-generated-docs
Closed

docs: add API reference generators and navigation#7057
dagil-nvidia wants to merge 4 commits into
mainfrom
dagil-nvidia/api-generated-docs

Conversation

@dagil-nvidia

@dagil-nvidia dagil-nvidia commented Mar 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add Python API reference generator (generate_python_api.py) using griffe for static analysis of Python source — no import required
  • Add Rust API reference generator (generate_rust_api.py) producing a crate overview table with docs.rs links
  • Generate and check in the output docs: docs/api/python/README.md (5940 lines) and docs/api/rust/README.md
  • Reorder navigation: API Reference above Documentation, Blog moved to hidden pages
  • Bump Fern SDK version 3.73.0 → 4.15.0
  • Add K8s API reference frontmatter (sidebar-title, max-toc-depth)
  • Add griffe>=2.0 to [dependency-groups] docs in pyproject.toml (removed standalone requirements-apidocs.txt)

Python API Generation Methodology

The Python generator uses griffe's GriffeLoader(docstring_parser="auto") to statically parse Python source files. It auto-detects docstring style (Google, NumPy, Sphinx) and renders a consolidated Markdown page with:

  • Module-level documentation
  • Class hierarchies with inheritance
  • Method signatures with type annotations
  • Docstring sections (parameters, returns, raises, examples)

Docstrings were generated using Claude Opus 4.6 by comparing Python binding stubs (.pyi) against Rust source implementations — see PR #7056. This PR will produce output regardless of whether #7056 has merged, but the generated docs are richer with docstrings present.

PR Series (split from #6989)

Merge in order:

  1. Docstringsdocs: add docstrings to Python components and bindings #7056 (merge first for richer generated output)
  2. API reference generators + navigationdocs: add API reference generators and navigation #7057 (this PR)
  3. Fernify transform scripts + CIdocs: add Fern MDX transform scripts and CI integration #7058

Test Plan

  • Pre-commit hooks pass
  • python3 docs/scripts/generate_python_api.py produces valid Markdown
  • python3 docs/scripts/generate_rust_api.py produces valid Markdown
  • Navigation renders correctly in Fern preview
  • K8s API reference frontmatter renders correctly

Open in Devin Review

Add static-analysis-based API reference generation for Python and Rust:

- generate_python_api.py: uses griffe to parse Python source and produce
  a consolidated Markdown reference with module/class/function docs
- generate_rust_api.py: generates a crate overview linking to docs.rs
- requirements-apidocs.txt: pip dependencies for the generators

Generated output:
- docs/api/python/README.md (5940 lines, auto-generated)
- docs/api/rust/README.md (crate table with docs.rs links)

Navigation and config:
- docs/index.yml: reorder API Reference above Documentation, hide Blog
- fern/fern.config.json: bump SDK version 3.73.0 -> 4.15.0
- deploy/operator/docs/header.md: add sidebar-title and max-toc-depth
- docs/kubernetes/api-reference.md: add frontmatter from header

Part 2 of 3 (split from #6989):
  1. Docstrings (#7056)
  2. API reference generators + navigation (this PR)
  3. Fernify transform scripts + CI

Signed-off-by: Dan Gil <dagil@nvidia.com>
Made-with: Cursor
@dagil-nvidia
dagil-nvidia requested a review from a team as a code owner March 7, 2026 05:09
@github-actions github-actions Bot added docs documentation Improvements or additions to documentation deployment::k8s Relates to dynamo deployment in kubernetes labels Mar 7, 2026
@github-actions

github-actions Bot commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

dagil-nvidia added a commit that referenced this pull request Mar 7, 2026
Add fernify transform scripts that convert generated API reference
Markdown into Fern MDX components for the documentation site:

- _fern_helpers.py: shared transforms (details->Accordion, tables->Cards,
  slugify, frontmatter injection)
- fernify_python_api.py: transforms Python API reference
- fernify_rust_api.py: transforms Rust API reference
- fernify_k8s_api.py: transforms K8s CRD reference (wraps API groups
  in Tabs, resource lists in CardGroups, type defs in Accordions)

CI integration (.github/workflows/fern-docs.yml):
- Add Python setup + pip install for fernify dependencies
- Run all 3 fernify scripts before syncing to docs-website
- Pin Rust docs.rs links to release version on tag pushes

Part 3 of 3 (split from #6989):
  1. Docstrings (#7056)
  2. API reference generators + navigation (#7057)
  3. Fernify transform scripts + CI (this PR)

Signed-off-by: Dan Gil <dagil@nvidia.com>
Made-with: Cursor
@coderabbitai

coderabbitai Bot commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request adds new API documentation generation infrastructure with Python and Rust API scripts, reorganizes the documentation navigation structure, creates a Rust API reference guide, adds metadata to documentation front matter, updates a requirements file for API documentation dependencies, and bumps the Fern configuration version.

Changes

Cohort / File(s) Summary
Documentation Metadata Updates
deploy/operator/docs/header.md, docs/kubernetes/api-reference.md, fern/fern.config.json
Added YAML front matter fields (sidebar-title, max-toc-depth) to documentation headers and updated Fern version from 3.73.0 to 4.15.0.
Documentation Index Reorganization
docs/index.yml
Renamed multimodal section, flattened API reference structure with Python/Rust/Kubernetes CRD entries, relocated blog subsection under Additional Resources, and removed hidden Kubernetes API reference page.
Rust API Documentation
docs/api/rust/README.md
New documentation file detailing Rust API reference including core and supporting crates with links, development tooling, language bindings, and local build instructions.
Python API Generation Script
docs/scripts/generate_python_api.py
New comprehensive script for generating consolidated Python API documentation using Griffe, including module discovery, signature rendering, docstring processing, and Fern-compatible frontmatter.
Rust API Generation Script
docs/scripts/generate_rust_api.py
New script for generating Rust API reference from workspace Cargo.toml, classifying crates into groups (core, supporting, dev, bindings) and rendering Markdown with docs.rs links and build instructions.
API Documentation Dependencies
docs/scripts/requirements-apidocs.txt
New requirements file specifying dependencies for API documentation generation (griffe>=1.0, toml with Python version constraint).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hops through docs with glee and grace,
New scripts render APIs in their place,
Python, Rust, and Kubernetes align,
Navigation flattened, structure divine!
With frontmatter trimmed and Fern updated bright,
Documentation generation: oh what a sight!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs: add API reference generators and navigation' clearly and concisely summarizes the main changes: adding API reference generators and updating navigation structure.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed PR description covers all required sections: overview (Summary), detailed changes across all modified files, specific guidance on where to start, and related issues/PR series.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
docs/scripts/requirements-apidocs.txt (1)

4-5: Pin the API-doc generator toolchain.

griffe>=1.0 makes the checked-in Python API output depend on whichever 1.x release a contributor or CI happens to install. Since generate_python_api.py relies on Griffe's parsed-docstring APIs, this will eventually cause unnecessary doc churn or break generation unexpectedly. Please lock the validated version here, or pair this file with a constraints/lock file used by the docs generation job.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/scripts/requirements-apidocs.txt` around lines 4 - 5, The requirements
entry for the API docs generator in docs/scripts/requirements-apidocs.txt
currently uses a loose pin ("griffe>=1.0") which can cause unpredictable doc
churn; update that requirement to a fixed, validated version (or add a companion
constraints/lock file used by your docs generation job) so
generate_python_api.py always runs against the exact Griffe release you
validated—modify the griffe line in requirements-apidocs.txt accordingly and
ensure CI/docs scripts reference the lock/constraints file if you choose that
approach.
docs/scripts/generate_rust_api.py (1)

136-145: Consider glob pattern support for workspace members.

While the current Cargo.toml uses only concrete directory paths, Cargo supports glob patterns in workspace.members (e.g., crates/*). The current code treats all members as literal paths and would fail if a glob were added. This is a defensive programming improvement rather than a current issue.

Suggested fix
-    members = list(dict.fromkeys(ws["workspace"]["members"]))
+    members: list[str] = []
+    for entry in ws["workspace"]["members"]:
+        if any(ch in entry for ch in "*?["):
+            members.extend(
+                str(path.parent.relative_to(root))
+                for path in sorted(root.glob(f"{entry}/Cargo.toml"))
+            )
+        else:
+            members.append(entry)
+    members = list(dict.fromkeys(members))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/scripts/generate_rust_api.py` around lines 136 - 145, Workspace member
entries in members can be glob patterns but the current loop treats them as
literal paths; update the expansion before calling _load_toml by detecting glob
patterns in members (e.g., presence of '*', '?', '[') and expanding them with
root.glob(m) to collect matching directories (filter to directories that contain
a Cargo.toml), preserve order/uniqueness (similar to dict.fromkeys behavior) and
then iterate the expanded, filtered list so pkg = _load_toml(root / matched /
"Cargo.toml") works for both literal paths and globs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/scripts/generate_python_api.py`:
- Around line 806-827: The header currently builds cards for every MODULE_ORDER
entry, producing dead anchor links when modules are not present; modify
_render_header to first call _discover_modules() (or accept its returned module
list) and filter MODULE_ORDER to only iterate over discovered modules so the
cards list comprehension uses "for m in MODULE_ORDER if m in
discovered_modules"; ensure you still use _module_display_name, slugify,
MODULE_ICONS, MODULE_DESCRIPTIONS, and render_markdown_table as before; apply
the same filtering change to the similar code block around the section that
corresponds to lines 850-855.

---

Nitpick comments:
In `@docs/scripts/generate_rust_api.py`:
- Around line 136-145: Workspace member entries in members can be glob patterns
but the current loop treats them as literal paths; update the expansion before
calling _load_toml by detecting glob patterns in members (e.g., presence of '*',
'?', '[') and expanding them with root.glob(m) to collect matching directories
(filter to directories that contain a Cargo.toml), preserve order/uniqueness
(similar to dict.fromkeys behavior) and then iterate the expanded, filtered list
so pkg = _load_toml(root / matched / "Cargo.toml") works for both literal paths
and globs.

In `@docs/scripts/requirements-apidocs.txt`:
- Around line 4-5: The requirements entry for the API docs generator in
docs/scripts/requirements-apidocs.txt currently uses a loose pin ("griffe>=1.0")
which can cause unpredictable doc churn; update that requirement to a fixed,
validated version (or add a companion constraints/lock file used by your docs
generation job) so generate_python_api.py always runs against the exact Griffe
release you validated—modify the griffe line in requirements-apidocs.txt
accordingly and ensure CI/docs scripts reference the lock/constraints file if
you choose that approach.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6f78f682-15f8-415f-b138-bf79504a03cc

📥 Commits

Reviewing files that changed from the base of the PR and between f1dbea4 and de5d4cf.

📒 Files selected for processing (9)
  • deploy/operator/docs/header.md
  • docs/api/python/README.md
  • docs/api/rust/README.md
  • docs/index.yml
  • docs/kubernetes/api-reference.md
  • docs/scripts/generate_python_api.py
  • docs/scripts/generate_rust_api.py
  • docs/scripts/requirements-apidocs.txt
  • fern/fern.config.json

Comment thread docs/scripts/generate_python_api.py Outdated
Signed-off-by: Dan Gil <dagil@nvidia.com>
Made-with: Cursor
Move griffe dependency from standalone requirements-apidocs.txt
into [dependency-groups] docs in pyproject.toml, following the
project's standard pattern. Pin to ~=2.0 (compatible release)
since the generator script uses griffe 2.0 APIs.

Signed-off-by: Dan Gil <dagil@nvidia.com>
Made-with: Cursor
Signed-off-by: Dan Gil <dagil@nvidia.com>
Made-with: Cursor
@dagil-nvidia
dagil-nvidia marked this pull request as draft March 12, 2026 21:14
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions Bot added Stale and removed Stale labels Apr 18, 2026
@dagil-nvidia

Copy link
Copy Markdown
Collaborator Author

Closing as stale. This work has been untouched for ~2 months and is superseded or no longer prioritized. Reopen if we pick it back up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deployment::k8s Relates to dynamo deployment in kubernetes docs documentation Improvements or additions to documentation size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant