summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-07-20 01:15:29 +0900
committerGitHub <noreply@github.com>2021-07-20 01:15:29 +0900
commit9ebdc987b08a52e857fee5a4099d64baadfae729 (patch)
tree813806b7dd345c8a0d08ee35ccbd271aaf1f8ef6
parent60617cb1e6d6d5fa2198c2e309e9d97cbbcce8ea (diff)
parenta35b009adcdedd37fa53929238ffea0b9abb78d1 (diff)
downloadsphinx-git-9ebdc987b08a52e857fee5a4099d64baadfae729.tar.gz
Merge pull request #9467 from tk0miya/9435_disable_rewrite_github_anchor
Fix #9435: linkcheck: Failed to check anchors in github.com
-rw-r--r--CHANGES5
-rw-r--r--sphinx/builders/linkcheck.py5
-rw-r--r--tests/roots/test-linkcheck/links.txt3
-rw-r--r--tests/test_build_linkcheck.py10
4 files changed, 13 insertions, 10 deletions
diff --git a/CHANGES b/CHANGES
index 0f221e081..8fa1a09d0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,9 @@ Dependencies
Incompatible changes
--------------------
+* #9435: linkcheck: Disable checking automatically generated anchors on
+ github.com (ex. anchors in reST/Markdown documents)
+
Deprecated
----------
@@ -16,6 +19,8 @@ Features added
Bugs fixed
----------
+* #9435: linkcheck: Failed to check anchors in github.com
+
Testing
--------
diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py
index 6819bd3df..58e5da94b 100644
--- a/sphinx/builders/linkcheck.py
+++ b/sphinx/builders/linkcheck.py
@@ -714,7 +714,10 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.add_event('linkcheck-process-uri')
app.connect('config-inited', compile_linkcheck_allowed_redirects, priority=800)
- app.connect('linkcheck-process-uri', rewrite_github_anchor)
+
+ # FIXME: Disable URL rewrite handler for github.com temporarily.
+ # ref: https://github.com/sphinx-doc/sphinx/issues/9435
+ # app.connect('linkcheck-process-uri', rewrite_github_anchor)
return {
'version': 'builtin',
diff --git a/tests/roots/test-linkcheck/links.txt b/tests/roots/test-linkcheck/links.txt
index c21968250..4ff0c9f52 100644
--- a/tests/roots/test-linkcheck/links.txt
+++ b/tests/roots/test-linkcheck/links.txt
@@ -13,8 +13,7 @@ Some additional anchors to exercise ignore code
* `Complete nonsense <https://localhost:7777/doesnotexist>`_
* `Example valid local file <conf.py>`_
* `Example invalid local file <path/to/notfound>`_
-* https://github.com/sphinx-doc/sphinx#documentation
-* https://github.com/sphinx-doc/sphinx#user-content-testing
+* https://github.com/sphinx-doc/sphinx/blob/4.x/sphinx/__init__.py#L2
.. image:: https://www.google.com/image.png
.. figure:: https://www.google.com/image2.png
diff --git a/tests/test_build_linkcheck.py b/tests/test_build_linkcheck.py
index 6db0e7512..2c6244b0a 100644
--- a/tests/test_build_linkcheck.py
+++ b/tests/test_build_linkcheck.py
@@ -66,8 +66,8 @@ def test_defaults_json(app):
"info"]:
assert attr in row
- assert len(content.splitlines()) == 12
- assert len(rows) == 12
+ assert len(content.splitlines()) == 11
+ assert len(rows) == 11
# the output order of the rows is not stable
# due to possible variance in network latency
rowsby = {row["uri"]: row for row in rows}
@@ -88,7 +88,7 @@ def test_defaults_json(app):
assert dnerow['uri'] == 'https://localhost:7777/doesnotexist'
assert rowsby['https://www.google.com/image2.png'] == {
'filename': 'links.txt',
- 'lineno': 20,
+ 'lineno': 19,
'status': 'broken',
'code': 0,
'uri': 'https://www.google.com/image2.png',
@@ -102,10 +102,6 @@ def test_defaults_json(app):
# images should fail
assert "Not Found for url: https://www.google.com/image.png" in \
rowsby["https://www.google.com/image.png"]["info"]
- # The anchor of the URI for github.com is automatically modified
- assert 'https://github.com/sphinx-doc/sphinx#documentation' not in rowsby
- assert 'https://github.com/sphinx-doc/sphinx#user-content-documentation' in rowsby
- assert 'https://github.com/sphinx-doc/sphinx#user-content-testing' in rowsby
@pytest.mark.sphinx(