diff options
author | Hugo van Kemenade <hugovk@users.noreply.github.com> | 2022-03-24 14:31:17 +0300 |
---|---|---|
committer | Hugo van Kemenade <hugovk@users.noreply.github.com> | 2022-03-24 14:31:17 +0300 |
commit | 658689433eacc9ebc0bd69ff175556ff95863239 (patch) | |
tree | 87c392b76b473804c9f94bae282d04d9b24b8d9c | |
parent | a432bf8c1022d5a4f8227c6bf309c3d2820ef9c6 (diff) |
Include trailing / in PEP URL to avoid 301 redirect
-rw-r--r-- | sphinx/roles.py | 4 | ||||
-rw-r--r-- | tests/test_build_html.py | 4 | ||||
-rw-r--r-- | tests/test_markup.py | 8 |
3 files changed, 8 insertions, 8 deletions
diff --git a/sphinx/roles.py b/sphinx/roles.py index 5e467937b..e2564269e 100644 --- a/sphinx/roles.py +++ b/sphinx/roles.py @@ -193,9 +193,9 @@ class PEP(ReferenceRole): 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): diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 77371d002..a1e1018a6 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -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']" diff --git a/tests/test_markup.py b/tests/test_markup.py index 56f797504..8800f5499 100644 --- a/tests/test_markup.py +++ b/tests/test_markup.py @@ -150,10 +150,10 @@ def get_verifier(verify, verify_re): '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}}') ), ( @@ -161,12 +161,12 @@ def get_verifier(verify, verify_re): '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}}') ), ( |