mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5185 from TimKam/4886-linkcheck-ignore-doc
4886 correct link check ignore doc
This commit is contained in:
commit
a7ea9d7c5b
@ -2488,12 +2488,21 @@ Options for the linkcheck builder
|
|||||||
|
|
||||||
.. confval:: linkcheck_anchors_ignore
|
.. confval:: linkcheck_anchors_ignore
|
||||||
|
|
||||||
A list of regular expressions that match URIs that should skip checking
|
A list of regular expressions that match anchors Sphinx should skip when
|
||||||
the validity of anchors in links. This allows skipping entire sites, where
|
checking the validity of anchors in links. This allows skipping anchors that
|
||||||
anchors are used to control dynamic pages, or just specific anchors within
|
a website's JavaScript adds to control dynamic pages or when triggering an
|
||||||
a page, where JavaScript is used to add anchors dynamically, or use the
|
internal REST request. Default is ``["^!"]``.
|
||||||
fragment as part of to trigger an internal REST request. Default is
|
|
||||||
``["/#!"]``.
|
.. note::
|
||||||
|
|
||||||
|
If you want to ignore anchors of a specific page or of pages that match a
|
||||||
|
specific pattern (but still check occurrences of the same page(s) that
|
||||||
|
don't have anchors), use :confval:`linkcheck_ignore` instead, for example
|
||||||
|
as follows::
|
||||||
|
|
||||||
|
linkcheck_ignore = [
|
||||||
|
'http://www.sphinx-doc.org/en/1.7/intro.html#'
|
||||||
|
]
|
||||||
|
|
||||||
.. versionadded:: 1.5
|
.. versionadded:: 1.5
|
||||||
|
|
||||||
|
@ -9,3 +9,5 @@ Some additional anchors to exercise ignore code
|
|||||||
* `Example Bar invalid <http://example.com/#!bar>`_
|
* `Example Bar invalid <http://example.com/#!bar>`_
|
||||||
* `Example Bar invalid <http://example.com#!bar>`_ tests that default ignore anchor of #! does not need to be prefixed with /
|
* `Example Bar invalid <http://example.com#!bar>`_ tests that default ignore anchor of #! does not need to be prefixed with /
|
||||||
* `Example Bar invalid <http://example.com/#top>`_
|
* `Example Bar invalid <http://example.com/#top>`_
|
||||||
|
* `Example anchor invalid <http://www.sphinx-doc.org/en/1.7/intro.html#does-not-exist>`_
|
||||||
|
* `Complete nonsense <https://localhost:7777/doesnotexist>`_
|
||||||
|
@ -21,14 +21,21 @@ def test_defaults(app, status, warning):
|
|||||||
content = (app.outdir / 'output.txt').text()
|
content = (app.outdir / 'output.txt').text()
|
||||||
|
|
||||||
print(content)
|
print(content)
|
||||||
# looking for #top should fail
|
# looking for '#top' and 'does-not-exist' not found should fail
|
||||||
assert "Anchor 'top' not found" in content
|
assert "Anchor 'top' not found" in content
|
||||||
assert len(content.splitlines()) == 1
|
assert "Anchor 'does-not-exist' not found" in content
|
||||||
|
# looking for non-existent URL should fail
|
||||||
|
assert " Max retries exceeded with url: /doesnotexist" in content
|
||||||
|
assert len(content.splitlines()) == 3
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
'linkcheck', testroot='linkcheck', freshenv=True,
|
'linkcheck', testroot='linkcheck', freshenv=True,
|
||||||
confoverrides={'linkcheck_anchors_ignore': ["^!", "^top$"]})
|
confoverrides={'linkcheck_anchors_ignore': ["^!", "^top$"],
|
||||||
|
'linkcheck_ignore': [
|
||||||
|
'https://localhost:7777/doesnotexist',
|
||||||
|
'http://www.sphinx-doc.org/en/1.7/intro.html#']
|
||||||
|
})
|
||||||
def test_anchors_ignored(app, status, warning):
|
def test_anchors_ignored(app, status, warning):
|
||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user