mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Allow skipping anchor checking by regex
To avoid needing to turn off anchor checking across the entire documentation allow skipping based on matching the anchor against a regex. Some sites/pages use JavaScript to perform anchor assignment in a webpage, which would require rendering the page to determine whether the anchor exists. Allow fine grain control of whether the anchor is checked based on pattern matching, until such stage as the retrieved URLs can be passed through an engine for deeper checking on the HTML doctree.
This commit is contained in:
@@ -14,12 +14,25 @@ from util import with_app
|
||||
|
||||
|
||||
@with_app('linkcheck', testroot='linkcheck', freshenv=True)
|
||||
def test_all(app, status, warning):
|
||||
def test_defaults(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
assert (app.outdir / 'output.txt').exists()
|
||||
content = (app.outdir / 'output.txt').text()
|
||||
|
||||
# expect all ok
|
||||
assert not content
|
||||
print(content)
|
||||
# looking for #top should fail
|
||||
assert "Anchor 'top' not found" in content
|
||||
assert len(content.splitlines()) == 1
|
||||
|
||||
|
||||
@with_app('linkcheck', testroot='linkcheck', freshenv=True,
|
||||
confoverrides={'linkcheck_anchors_ignore': ["^!", "^top$"]})
|
||||
def test_anchors_ignored(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
assert (app.outdir / 'output.txt').exists()
|
||||
content = (app.outdir / 'output.txt').text()
|
||||
|
||||
# expect all ok when excluding #top
|
||||
assert not content
|
||||
|
||||
Reference in New Issue
Block a user