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, that intersphinx references to Click resolve to the upstream site, and that each sidebar icon of the stylesheet lands on its entry. This catches drift the moment a {click:config} or {click:tree} directive stops wiring its anchors, an intersphinx_mapping URL goes stale, or a stylesheet selector names a link the build never writes, none of which a mock-based test would notice.

tests.test_sphinx_crossrefs.built_docs(tmp_path_factory)[source]

Build the 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.

Return type:

Path

tests.test_sphinx_crossrefs.page_file(name)[source]

Name the file the builder writes for the document name.

Return type:

str

tests.test_sphinx_crossrefs.read_html(built_docs, name)[source]

Read the built HTML page of the document name.

Return type:

str

tests.test_sphinx_crossrefs.test_changelog_releases_are_anchored_on_their_version(built_docs)[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 #id94 names another release after each new one. The click_extra_release_anchors setting of docs/conf.py gives that section #v3-6-0 instead, and the release in preparation the anchor it ships with.

A summary table deep-links each option or command to its section.

tests.test_sphinx_crossrefs.test_intersphinx_click_resolves(built_docs)[source]

Click cross-references resolve to the upstream documentation site.

The links land on the API autodoc pages (typed CLI signatures), not the CLI-parameters page, so scan the whole build rather than a single page.

tests.test_sphinx_crossrefs.test_sidebar_icons_match_their_entries(built_docs, page)[source]

Each sidebar icon of custom.css lands on its entry, at every depth.

The stylesheet keys an icon to the href of a toctree entry. That href is relative to the page, so it gains a ../ per level of nesting, and the builder decides its suffix: tests.html under html, tests/ under dirhtml. A selector naming a shape the build never writes draws no icon, and nothing else reports it.