Generate the API reference from the package - #72
Merged
Conversation
Every public estimator needed a one-line stub under docs/api/ and a matching
entry in the nav of mkdocs.yml. Seventeen stubs, each holding nothing but a
`::: ikpykit.X` directive, and 54 lines of nav. Adding an estimator meant two
manual edits, and forgetting either one failed silently: the class simply had
no page, with nothing to catch it.
The package already states what is public, through the __all__ of each module,
so scripts/gen_api_pages.py reads that and writes the pages, the navigation and
an overview at build time. What it cannot derive is the section names and their
order, which are editorial, so those stay in a list of eight entries. Adding an
estimator to a module already in that list now needs no documentation change at
all.
Six pages change URL, because their names were chosen by hand and no longer
match what the class is called:
api/kernel/isolation_kernel -> api/kernel/isokernel
api/kernel/isolation_dis_kernel -> api/kernel/isodiskernel
api/graph/IsoGraphKernel -> api/graph/isographkernel
api/stream/streakhc -> api/stream/streamkhc
api/time_series/iktod -> api/timeseries/iktod
api/trajectory/data_loader/sheep_dogs
-> api/trajectory/dataloader/sheepdogs
mkdocs-redirects keeps links published against v0.3.0 and earlier working. That
map is a fixed list of legacy paths; a new estimator never needs adding to it.
Each generated page carries the first paragraph of the class docstring as its
description, which fills in the meta description, the social card and the
llms.txt entry. Every page had been sharing one generic site description until
now, so the cards were identical apart from the title. The hand-written pages
get descriptions too. The notebook user guide still falls back to the site
description: mkdocs-jupyter does not populate page.meta, so there is nowhere to
put one.
The four plugins this adds all depend on properdocs, which prints a notice
about a possible MkDocs 2.0 on every build. Nothing here acts on it, so the
workflows set DISABLE_MKDOCS_2_WARNING to keep the log readable.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The problem
Every public estimator needed two things written by hand:
docs/api/holding nothing but a directive — 17 files, each exactly one line:navofmkdocs.yml— 54 lines of it.Forgetting either failed silently. The class just had no page, and nothing caught it.
The change
The package already declares what is public, through the
__all__of each module.scripts/gen_api_pages.pyreads that and writes the pages, the navigation and an overview page at build time, viamkdocs-gen-files+mkdocs-literate-nav+mkdocs-section-index.What it cannot derive is the section names (
Point Anomaly Detection,Graph Mining, …) and their order, which are editorial. Those stay, as a list of eight entries. Adding an estimator to a module already in that list now needs no documentation change at all.Net:
docs/api/(17 files) and 54 lines of nav are gone, replaced by one 179-line generator and a 4-line nav entry.New: an API overview page
api/index.htmlis generated too — a table per section listing every estimator with its description.section-indexattaches it to the "API Reference" tab, which previously wasn't clickable.URL changes
Six pages move, because their names were chosen by hand and no longer match the class:
api/kernel/isolation_kernelapi/kernel/isokernelapi/kernel/isolation_dis_kernelapi/kernel/isodiskernelapi/graph/IsoGraphKernelapi/graph/isographkernelapi/stream/streakhcapi/stream/streamkhcapi/time_series/iktodapi/timeseries/iktodapi/trajectory/data_loader/sheep_dogsapi/trajectory/dataloader/sheepdogsThe other 11 are unchanged.
mkdocs-redirectskeeps links published against v0.3.0 and earlier working — verified in the build output, e.g.api/time_series/iktod.htmlnow emits a redirect to../timeseries/iktod.html. That map is a fixed list of legacy paths; a new estimator never needs adding to it.Fixing the social cards
Every card was showing the same generic
site_description, so 27 cards differed only by title. Each generated page now carries the first paragraph of the class docstring as itsdescription, which feeds the meta description, the social card and thellms.txtentry:The docstring's first paragraph turned out to be a usable one-liner for all 17 classes. Longer ones are cut at the last sentence that fits in 160 characters, not mid-word.
The 8 hand-written pages got descriptions written for them. One page still falls back to the site description: the notebook user guide, because
mkdocs-jupyterdoes not populatepage.metaand there is nowhere to put one.After: 27 pages, 27 cards, 27 distinct descriptions.
Two things worth knowing
api/SUMMARY.mdwould have been built as a page. literate-nav reads it and then only marks it not-in-nav, so it still landed in the site, the sitemap and the search index as a bare list of links. The generator sets its inclusion toEXCLUDED; it is an input to the build, not a page.All four new plugins depend on
properdocs, which prints a notice about a possible MkDocs 2.0 on every build. It is by the same author as the plugins and nothing here acts on it, so the workflows setDISABLE_MKDOCS_2_WARNING. Worth flagging since it arrived unannounced with the dependency.Verification
mkdocs build --strictpasses. In the output: 17 class pages at the expected paths, 6 redirect stubs, the overview page, noSUMMARY.html, the nav structure matching the old hand-written one section for section, andllms.txtcovering 18 API pages (the 17 plus the overview — the overview needed listing separately, sinceapi/**/*.mdonly matches pages one directory down).🤖 Generated with Claude Code