tests.test_sphinx_crossrefs module¶
Render tests for Sphinx cross-references in the built documentation.
Build the docs once and assert against the real HTML that the generated
summary tables deep-link to the sections they describe, that each changelog
release is anchored on its version, and that intersphinx references to Click
resolve to the upstream site. This catches drift the moment a
{click:config} or {click:tree} directive stops wiring its anchors, or
an intersphinx_mapping URL goes stale, neither of which a mock-based test
would notice. The same build also shows whether a pickled page carries the
whole build environment.
- tests.test_sphinx_crossrefs.DOCTREES_TO_ENVIRONMENT_RATIO = 10¶
Ceiling on the pickled pages of a build, in sizes of its pickled environment.
A clean build writes its pages in about two such sizes. A page that carries the build environment adds a copy of it, so a leak across every API page takes the ratio past a hundred.
- tests.test_sphinx_crossrefs.built_docs(tmp_path_factory)[source]¶
Build the HTML documentation once and return its output directory.
Builds into a throwaway directory (rather than
docs/_build) so the run is hermetic and never clobbers a developer’s local build. Reads in parallel, like thedocs.yamlbuild these tests stand in for.- Return type:
- tests.test_sphinx_crossrefs.read_html(built_docs, filename)[source]¶
Read a built HTML page.
- Return type:
- tests.test_sphinx_crossrefs.test_changelog_releases_are_anchored_on_their_version(built_docs, source, page)[source]¶
Each release of the changelog has an anchor made from its version.
docutils reduces a release heading to nothing and numbers its section from a per-page counter, so
#id40names another release after each new one.click_extra_release_anchorsindocs/conf.pygives each section an anchor like#v1-4-2instead.
- tests.test_sphinx_crossrefs.test_summary_table_links_to_its_sections(built_docs, page, anchor)[source]¶
Each generated summary table deep-links every row to its own section.
Both directives render a table of contents above the detail sections, so a row whose target never materialized leaves a dead link on the published page rather than failing the build.
- tests.test_sphinx_crossrefs.test_intersphinx_click_resolves(built_docs)[source]¶
Click cross-references resolve to the upstream documentation site.
Read from the API reference rather than the CLI guide: a Click link is emitted by a rendered signature or docstring, and the generated API reference lives only on the
repomatic.*pages. The guide keeps the{click:tree}output, which links within this site and would pass this assertion for the wrong reason. Any API page qualifies, because which module renders a Click type changes as the code moves.
- tests.test_sphinx_crossrefs.test_pickled_pages_carry_no_build_environment(built_docs)[source]¶
The pickled pages stay small next to the build environment.
A node that keeps a throwaway document as its own pickles that document’s settings with the page, build environment included. See
click_extra/sphinx/doctrees.pyin click-extra.