Skip to content

Fix incomplete API reference for versioned (tagged) docs (#190)#240

Merged
rich-iannone merged 14 commits into
posit-dev:mainfrom
has2k1:fix-deep-snapshots
Jun 29, 2026
Merged

Fix incomplete API reference for versioned (tagged) docs (#190)#240
rich-iannone merged 14 commits into
posit-dev:mainfrom
has2k1:fix-deep-snapshots

Conversation

@has2k1

@has2k1 has2k1 commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

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-tags emit 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 example scores.CosineScore and 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:

  • New GreatDocs.documented_symbol_names() resolves the reference: 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_tag capture those exact symbols by walking the griffe tree (submodule classes and methods included); behavior is unchanged when no documented set is supplied.
  • The versioned build and the api-snapshot / api-diff CLI paths feed this set through.
  • The page-validity check collapses to exact snapshot membership, removing the buggy class-prefix heuristic.

Result

Tagged versions now render the full documented API, and per-tag snapshots differ when the API differs.

fixes #190

has2k1 added 9 commits June 29, 2026 12:38
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.
@rich-iannone rich-iannone self-requested a review June 29, 2026 15:30
@rich-iannone

Copy link
Copy Markdown
Member

Thanks for taking on this issue! Prompted by a Claude review, I added a few commits to address:

  • a shallow-snapshot safety net for when the documented set can't be resolved, method pages are now kept via a class-prefix fallback instead of being destructively pruned; deep-snapshot exact-membership is unchanged
  • documented_symbol_names() no longer writes _object_types.json/_constant_values.json into the project, so api-snapshot/api-diff leaves no artifacts behind

@rich-iannone rich-iannone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@rich-iannone rich-iannone merged commit 2dde15c into posit-dev:main Jun 29, 2026
8 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.

Git tag introspection for versioned docs fails

2 participants