-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
singlehtml: Use same-document hyperlinks for internal project referen…
…ces (#12551) Co-authored-by: Bénédikt Tran <[email protected]> Co-authored-by: Adam Turner <[email protected]>
- Loading branch information
1 parent
a3f1383
commit 0bfaadf
Showing
5 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,19 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from collections.abc import Sequence | ||
from xml.etree.ElementTree import Element | ||
|
||
|
||
def _intradocument_hyperlink_check(nodes: Sequence[Element]) -> None: | ||
"""Confirm that a series of nodes are all HTML hyperlinks to the current page""" | ||
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') | ||
# Allow Sphinx index and table hyperlinks to be non-same-document, as exceptions. | ||
if href in {'genindex.html', 'py-modindex.html', 'search.html'}: | ||
continue | ||
assert not href or href.startswith('#'), 'Hyperlink failed same-document check' |