-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Revert "singlehtml: deprecate the 'fix_refuris' helper function (#13037)" #14241
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
Open
jayaddison
wants to merge
16
commits into
sphinx-doc:master
Choose a base branch
from
jayaddison:issue-14221/singlehtml-restore-fix-refuris
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
79d2839
Tests: add reference URI test coverage for `singlehtml` builder
jayaddison d5db938
Revert "singlehtml: deprecate the 'fix_refuris' helper function (#130…
jayaddison c32cf72
singlehtml: retain deprecation notice
jayaddison a9cda59
Tests: fixup: run `ruff check --fix` to resolve import ordering
jayaddison c1ad3ef
Merge branch 'master' into issue-14221/singlehtml-restore-fix-refuris
jdillard 1d50c8b
Add CHANGES.rst entry
jayaddison d93fa09
Revert "singlehtml: deprecate the 'fix_refuris' helper function (#130…
jayaddison 07228e7
Tests: singlehtml: remove deprecation warning expectation
jayaddison 3085b2f
Tests: reduce/simplify the duplicate-definition refuri testroot
jayaddison 800c55a
Tests: singlehtml: add HREF/anchor value test
jdillard 4f37a34
Tests: simplify refuris testroot
jayaddison cf5af53
Tests: cleanup: remove misleading comment
jayaddison 3207ade
Apply suggestion from @jdillard
jdillard 26155d2
Tests: cleanup: remove unnecessary check and misleading comment
jdillard 0b069bb
Tests: refactor / simplify assertion
jayaddison 6658828
Update CHANGES.rst entry: mention withdrawn deprecation of `fix_refuris`
jayaddison File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| project = 'Glossary Test' | ||
| extensions = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Glossary | ||
| ======== | ||
|
|
||
| .. glossary:: | ||
|
jdillard marked this conversation as resolved.
|
||
|
|
||
| API | ||
| Lorem Ipsum. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| Main Documentation | ||
| ================== | ||
|
|
||
| This documentation discusses :term:`API` design. | ||
|
|
||
| We use :term:`API` throughout our application to communicate between | ||
| different services. | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 2 | ||
|
|
||
| glossary/term1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| """Test output of reference URIs when building single-page HTML output.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| import pytest | ||
|
|
||
| from tests.test_builders.xpath_util import check_xpath | ||
|
|
||
| if TYPE_CHECKING: | ||
| from collections.abc import Callable, Sequence | ||
| from pathlib import Path | ||
| from xml.etree.ElementTree import Element, ElementTree | ||
|
|
||
| from sphinx.testing.util import SphinxTestApp | ||
|
|
||
|
|
||
| def _internal_reference_fragment_check(nodes: Sequence[Element]) -> None: | ||
| """Confirm that internal references do not contain duplicate fragment symbols""" | ||
| assert nodes, 'Expected at least one node to check' | ||
| for node in nodes: | ||
| assert node.tag == 'a', 'Attempted to check hyperlink on a non-anchor element' | ||
| href = node.attrib.get('href') | ||
| if not href: | ||
| continue | ||
| assert href.count('#') < 2, 'Hyperlink contains duplicate fragments' | ||
|
|
||
|
|
||
| @pytest.mark.sphinx('singlehtml', testroot='refuris') | ||
| def test_singlehtml_refuris_check_fragments( | ||
| app: SphinxTestApp, | ||
| cached_etree_parse: Callable[[Path], ElementTree], | ||
| ) -> None: | ||
| app.build() | ||
| check_xpath( | ||
| cached_etree_parse(app.outdir / 'index.html'), | ||
| 'index.html', | ||
| ".//a[@class='reference internal']", | ||
| _internal_reference_fragment_check, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.sphinx('singlehtml', testroot='refuris') | ||
| def test_singlehtml_refuris_check_term_anchor( | ||
| app: SphinxTestApp, | ||
| cached_etree_parse: Callable[[Path], ElementTree], | ||
| ) -> None: | ||
| app.build() | ||
| etree = cached_etree_parse(app.outdir / 'index.html') | ||
| api_refs = [ | ||
| node | ||
| for node in etree.findall(".//a[@class='reference internal']") | ||
| if ''.join(node.itertext()) == 'API' | ||
| ] | ||
| assert api_refs # the API term is referenced twice from the document text | ||
| assert all(ref.get('href') == '#term-API' for ref in api_refs) | ||
| assert etree.find(".//*[@id='term-API']") is not None |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.