click_extra.sphinx.internal_links moduleΒΆ
Warn about each internal link of the built HTML that leads nowhere.
Sphinx warns about a cross-reference it cannot resolve. A link it does not
resolve itself, it writes as it is: the href of a raw HTML block, a fragment
that names an anchor its page lost, or a link an extension builds from data,
like the [docs] link of a sphinx.ext.viewcode page. Nothing tells when such
a link leads to no page, or to no anchor of its page.
This module reads the HTML pages once the build is over, and logs a
DEAD_LINK_WARNING for each <a href> that leads to no file, or to a
fragment that the page it leads to does not define. A link that names a scheme
or a host leaves the build, and a link that opens on / depends on where the
site is served, so the check skips both. A page that holds the same dead link
several times gets one warning for it. --fail-on-warning then fails the build.
- click_extra.sphinx.internal_links.DEAD_LINK_WARNING = 'click_extra.dead_link'ΒΆ
Type of the warning logged for each internal link that leads nowhere.
Listed in
suppress_warnings, it turns the check off. Listed inFAIL_ON_WARNINGS_CONFIG, it fails a build on a dead link without--fail-on-warning.
- click_extra.sphinx.internal_links.dead_links(outdir)[source]ΒΆ
Return each internal link of the HTML pages under
outdirthat leads nowhere.A link to a folder leads to its
index.html. A fragment is checked on an HTML target only. A link that leavesoutdirthrough..is skipped, like an external one.
- click_extra.sphinx.internal_links.report_dead_links(app, exception)[source]ΒΆ
Warn once about each dead internal link of the pages the build wrote.
Connected to
build-finished, which fires once every page is on disk. The warning has theDEAD_LINK_WARNINGtype, names the page that holds the link, and points at the source of that page when the page has one: a page that an extension writes, like asphinx.ext.viewcodepage, has none. Inert after a failed build, with a builder that writes no HTML, and whensuppress_warningslists the type, which then also spares the reading of every page.- Return type:
- click_extra.sphinx.internal_links.setup(app)[source]ΒΆ
Register the dead-link check on
app.Called from
click_extra.sphinx.setup()so projects only need to list"click_extra.sphinx"in theirextensions. The default priority runs the check beforeclick_extra.sphinx.fail_on_warningscounts the warnings of the build, at priority 900.- Return type: