Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9435: linkcheck: Failed to check anchors in github.com #9467

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES
Expand Up @@ -7,6 +7,9 @@ Dependencies
Incompatible changes
--------------------

* #9435: linkcheck: Disable checking automatically generated anchors on
github.com (ex. anchors in reST/Markdown documents)

Deprecated
----------

Expand All @@ -16,6 +19,8 @@ Features added
Bugs fixed
----------

* #9435: linkcheck: Failed to check anchors in github.com

Testing
--------

Expand Down
5 changes: 4 additions & 1 deletion sphinx/builders/linkcheck.py
Expand Up @@ -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',
Expand Down
3 changes: 1 addition & 2 deletions tests/roots/test-linkcheck/links.txt
Expand Up @@ -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
10 changes: 3 additions & 7 deletions tests/test_build_linkcheck.py
Expand Up @@ -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}
Expand All @@ -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',
Expand All @@ -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(
Expand Down