Skip to content

docs: auto-generated API reference site - #20

Merged
adilfaisal01 merged 1 commit into
mainfrom
docs/api-reference
Sep 15, 2026
Merged

adilfaisal01 merged 1 commit into
mainfrom
docs/api-reference

Conversation

@adilfaisal01

Copy link
Copy Markdown
Member

What

An mkdocs-material API reference site whose pages are generated from source, not hand-maintained, plus a GitHub Pages deploy workflow.

The zero-maintenance mechanism

scripts/gen_api.py walks each subpackage's __all__ and emits one page per subpackage plus the nav:

7 exports -> 8 exports, 0 config edits

Verified by temporarily injecting a class into controllers/, confirming it rendered end-to-end in the built HTML, then reverting. Subpackages without __all__ (components.py, utils/) fall back to an AST scan of their source files. Adding an export is all it takes for it to show up in the docs.

The non-obvious part

The source mixes Google param sections (Args: / Returns:) with Sphinx roles (:class:, :meth:, :func:) and math (:math:, .. math::). griffe's Google parser doesn't understand the Sphinx half, so out of the box:

  • 86 Sphinx markers leak as literal text
  • every formula renders as raw markup (:math: u = -K(x - x_t))

scripts/sphinx_compat.py is a griffe extension normalizing all three forms -> 0 leaks, 28 rendered MathJax blocks.

Removing it does not fail the build — you silently get broken math. Also: the extensions: key must sit under options: in mkdocs.yml, not at handler level, or it is ignored.

Verification

Check Result
Build exit 0, 6.9s, 18 pages
Leaked markers (rendered prose) 0
MathJax blocks 28
Auto-update 7 -> 8 exports, 0 config edits

Deliberate choices worth reviewing

  • --strict is omitted. griffe reports unannotated public params as warnings (204 today), so --strict is red out of the box. Add it once annotations improve.
  • Generated output is gitignored (docs/reference/, docs/SUMMARY.md, site/) — CI regenerates on every run, so nothing stale can be committed.
  • GitHub Pages is now enabled on the repo with build_type: workflow; this workflow deploys to https://shinro-xyz.github.io/shinro-python-modules/ on merge to main.

Honest limitation

53% of public symbols have docstrings (~281 render as bare signatures; codegen/ is weakest, and only 121 functions are fully annotated). No generator fixes this — it's a source-coverage limit, not a tooling one. Widening pyright's coverage past its current 5 subpaths would improve the docs for free.

Sphinx alternative, if preferred

A Sphinx + napoleon + Furo POC was also built: 0 normalization glue needed, since the docstrings already are Sphinx-flavored. Trade-off is RST config surface, ~40s builds, and a less polished theme.

Commands

make docs         # install docs toolchain
make docs-serve   # regenerate + serve at :8000
make docs-build   # regenerate + build site/

Generated with Hermes Agent

Adds an mkdocs-material site whose API reference is generated from source
rather than hand-maintained, plus a Pages deploy workflow.

The reference is derived from each subpackage's __all__:

  scripts/gen_api.py walks __all__ -> one page per subpackage + the nav.
  Subpackages without __all__ (components.py, utils/) fall back to an AST
  scan of their source files.

Adding an export is therefore all it takes for it to appear in the docs; no
config, nav, or symbol-list edit is needed. Verified by injecting a class
into controllers/ and observing the page grow from 7 to 8 exports.

scripts/sphinx_compat.py is a griffe extension handling the Sphinx-flavored
docstring markup used throughout the source (:class:, :meth:, :func:, :math:,
and .. math:: blocks), which griffe's Google parser does not understand and
would otherwise render as literal text. Without it the docs build still
succeeds but every formula is broken, so the key must stay under `options:`
in mkdocs.yml rather than at handler level.

Generated output (docs/reference/, docs/SUMMARY.md, site/) is gitignored; CI
regenerates it on every run.

Notes:
- The workflow deliberately omits --strict: griffe reports the unannotated
  public parameters as warnings (204 today), so --strict fails out of the box.
  Worth adding once annotation coverage improves.
- 53% of public symbols have docstrings, so roughly 281 render as bare
  signatures. This is a source-coverage limit, not a tooling one.
- Prose pages remain hand-written and are ordered in docs/_nav_prose.md.

Commands: make docs, make docs-serve, make docs-build.
@adilfaisal01
adilfaisal01 merged commit a50a2cb into main Sep 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant