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:
- tests.test_sphinx_crossrefs.page_file(name)[source]¶
Name the file the builder writes for the document
name.- Return type:
- tests.test_sphinx_crossrefs.read_html(built_docs, name)[source]¶
Read the built HTML page of the document
name.- Return type:
- 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
#id94names another release after each new one. Theclick_extra_release_anchorssetting ofdocs/conf.pygives that section#v3-6-0instead, and the release in preparation the anchor it ships with.
- tests.test_sphinx_crossrefs.test_summary_tables_link_to_their_sections(built_docs, page, anchor)[source]¶
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.csslands 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.htmlunderhtml,tests/underdirhtml. A selector naming a shape the build never writes draws no icon, and nothing else reports it.