Infra: Fix Replaces/Superseded-By/Requires links for dirhtml (#2981)

After #2972, when building dirhtml,
we need to re-add the initial / for the links to PEPs
in the Replaces/Superseded-By/Requires headers.
This commit is contained in:
Hugo van Kemenade 2023-01-24 05:26:36 +02:00 committed by GitHub
parent b4a610bce9
commit 2f277a0a2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -131,6 +131,8 @@ class PEPHeaders(transforms.Transform):
new_body = []
for pep_str in re.split(r",?\s+", body.astext()):
target = self.document.settings.pep_url.format(int(pep_str))
if self.document.settings.builder == "dirhtml":
target = f"../{target}"
new_body += [nodes.reference("", pep_str, refuri=target), nodes.Text(", ")]
para[:] = new_body[:-1] # drop trailing space
elif name == "topic":