Fix incomplete API reference for versioned (tagged) docs (#190)#240
Merged
Conversation
Add _symbol_info_for_dotted helper to resolve dotted names by walking the griffe tree. Teach snapshot_from_griffe to capture documented_names (nested symbols via dotted names) when provided; default (no documented_names) preserves existing top-level __all__ behavior for back-compat.
Drop the class-prefix heuristic in _is_valid_ref_name in favour of exact set membership: with deep snapshots, every valid page stem (including method stems like Class.method) is present as a snapshot key, so a two-argument name-in-set check is sufficient. Remove the now-unused valid_classes / snapshot_classes path throughout _prune_reference_index, _prune_quarto_sidebar, and _rebuild_api_from_snapshot.
Add test_resolver_matches_renderer_sections to assert documented_symbol_names output equals the flattened _create_api_sections_from_config contents, so the resolver and renderer can never silently diverge. Add test_deduplication_preserves_first_occurrence_order to exercise the dedup path: a config with the same symbol in two sections asserts the result has no duplicates and preserves first-occurrence order.
`documented_symbol_names` now calls `_create_api_sections_with_config` instead of `_create_api_sections_from_config`, so it consumes the same nodoc-filtered section set the dev renderer uses. Symbols marked with `%nodoc` are therefore excluded from the resolver output, eliminating the over-inclusion bug where a versioned snapshot could render pages the dev build hides. Also routes diagnostic warning prints that appear in the discovery pipeline to `sys.stderr` and suppresses all build-pipeline output inside `documented_symbol_names` (a programmatic query that owns no output stream), keeping the `api-diff --json` CLI path clean.
Member
|
Thanks for taking on this issue! Prompted by a Claude review, I added a few commits to address:
|
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.
Problem
When building versioned docs, the dev version renders the full API, but tagged versions (git_ref:) render an incomplete reference — for packages whose public API lives under submodules, the entire submodule namespace disappears (only top-level classes survive). The same defect also made
great-docs api-snapshot --all-tagsemit byte-identical snapshots across versions.Cause
"The public API" is the symbols the
reference:config (or auto-discovery) tells the renderer to document. The dev build uses that set. But tagged versions are rebuilt from an API snapshot, and the snapshot used a different, shallower definition: the package's top-level__all__. Submodules were captured as opaque modules, so for examplescores.CosineScoreand its methods were never recorded. The page-pruner then deleted every reference page the shallow snapshot couldn't account for!Solution
Make the snapshot consume the same resolved documented set the renderer uses, keyed by the identical dotted page-stem names:
GreatDocs.documented_symbol_names()resolves thereference:config (→ auto-discovery →__all__fallback) into dotted stems, reusing the renderer's own resolution (including the %nodoc filter, so snapshot and dev build stay in lockstep).snapshot_from_griffe/snapshot_at_tagcapture those exact symbols by walking the griffe tree (submodule classes and methods included); behavior is unchanged when no documented set is supplied.api-snapshot/api-diffCLI paths feed this set through.Result
Tagged versions now render the full documented API, and per-tag snapshots differ when the API differs.
fixes #190