Skip to content

Commit

Permalink
Include trailing / in PEP URL to avoid 301 redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Mar 24, 2022
1 parent a432bf8 commit 6586894
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions sphinx/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ def build_uri(self) -> str:
base_url = self.inliner.document.settings.pep_base_url
ret = self.target.split('#', 1)
if len(ret) == 2:
return base_url + 'pep-%04d#%s' % (int(ret[0]), ret[1])
return base_url + 'pep-%04d/#%s' % (int(ret[0]), ret[1])
else:
return base_url + 'pep-%04d' % int(ret[0])
return base_url + 'pep-%04d/' % int(ret[0])


class RFC(ReferenceRole):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_build_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ def test_html4_output(app, status, warning):
(".//li/p/code/span[@class='pre']", '^a/$'),
(".//li/p/code/em/span[@class='pre']", '^varpart$'),
(".//li/p/code/em/span[@class='pre']", '^i$'),
(".//a[@href='https://peps.python.org/pep-0008']"
(".//a[@href='https://peps.python.org/pep-0008/']"
"[@class='pep reference external']/strong", 'PEP 8'),
(".//a[@href='https://peps.python.org/pep-0008']"
(".//a[@href='https://peps.python.org/pep-0008/']"
"[@class='pep reference external']/strong",
'Python Enhancement Proposal #8'),
(".//a[@href='https://datatracker.ietf.org/doc/html/rfc1.html']"
Expand Down
8 changes: 4 additions & 4 deletions tests/test_markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,23 @@ def get(name):
'verify',
':pep:`8`',
('<p><span class="target" id="index-0"></span><a class="pep reference external" '
'href="https://peps.python.org/pep-0008"><strong>PEP 8</strong></a></p>'),
'href="https://peps.python.org/pep-0008/"><strong>PEP 8</strong></a></p>'),
('\\sphinxAtStartPar\n'
'\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}'
'!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{https://peps.python.org/pep-0008}'
'!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{https://peps.python.org/pep-0008/}'
'{\\sphinxstylestrong{PEP 8}}')
),
(
# pep role with anchor
'verify',
':pep:`8#id1`',
('<p><span class="target" id="index-0"></span><a class="pep reference external" '
'href="https://peps.python.org/pep-0008#id1">'
'href="https://peps.python.org/pep-0008/#id1">'
'<strong>PEP 8#id1</strong></a></p>'),
('\\sphinxAtStartPar\n'
'\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}'
'!PEP 8\\#id1@\\spxentry{PEP 8\\#id1}}\\sphinxhref'
'{https://peps.python.org/pep-0008\\#id1}'
'{https://peps.python.org/pep-0008/\\#id1}'
'{\\sphinxstylestrong{PEP 8\\#id1}}')
),
(
Expand Down

0 comments on commit 6586894

Please sign in to comment.