docs: auto-generated API reference site - #20
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.pywalks each subpackage's__all__and emits one page per subpackage plus the nav: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::math: u = -K(x - x_t))scripts/sphinx_compat.pyis a griffe extension normalizing all three forms -> 0 leaks, 28 rendered MathJax blocks.Verification
Deliberate choices worth reviewing
--strictis omitted. griffe reports unannotated public params as warnings (204 today), so--strictis red out of the box. Add it once annotations improve.docs/reference/,docs/SUMMARY.md,site/) — CI regenerates on every run, so nothing stale can be committed.build_type: workflow; this workflow deploys to https://shinro-xyz.github.io/shinro-python-modules/ on merge tomain.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
Generated with Hermes Agent