Skip to content

Commit 60b4965

Browse files
committed
Stop using .settings.pep_base_url in various places
1 parent f174c6a commit 60b4965

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

pep_sphinx_extensions/pep_processor/parsing/pep_role.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ class PEPRole(roles.PEP):
88

99
def build_uri(self) -> str:
1010
"""Get PEP URI from role text."""
11-
base_url = self.inliner.document.settings.pep_base_url
1211
pep_num, _, fragment = self.target.partition("#")
13-
pep_base = base_url + pep_url.format(int(pep_num))
12+
pep_base = pep_url.format(int(pep_num))
1413
if fragment:
1514
return f"{pep_base}#{fragment}"
1615
return pep_base

pep_sphinx_extensions/pep_processor/transforms/pep_contents.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,12 @@ def __init__(self, document, startnode=None):
4444
self.backlinks = None
4545

4646
def apply(self) -> None:
47-
48-
# let the writer (or output software) build the contents list?
49-
if getattr(self.document.settings, "use_latex_toc", False):
50-
# move customisation settings to the parent node
51-
self.startnode.parent.attributes.update(self.startnode.details)
52-
self.startnode.parent.remove(self.startnode)
47+
contents = self.build_contents(self.document[0][4:]) # skip PEP title, headers, <hr/>, and contents
48+
if contents:
49+
self.startnode.replace_self(contents)
5350
else:
54-
contents = self.build_contents(self.document[0][4:]) # skip PEP title, headers, <hr/>, and contents
55-
if contents:
56-
self.startnode.replace_self(contents)
57-
else:
58-
# if no contents, remove the empty placeholder
59-
self.startnode.parent.parent.remove(self.startnode.parent)
51+
# if no contents, remove the empty placeholder
52+
self.startnode.parent.parent.remove(self.startnode.parent)
6053

6154
def build_contents(self, node, level=0):
6255
level += 1

pep_sphinx_extensions/pep_processor/transforms/pep_headers.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,9 @@ def apply(self) -> None:
7979
elif name in {"replaces", "superseded-by", "requires"}:
8080
# replace PEP numbers with normalised list of links to PEPs
8181
new_body = []
82-
space = nodes.Text(" ")
8382
for ref_pep in re.split(r",?\s+", body.astext()):
84-
new_body.append(nodes.reference(
85-
ref_pep, ref_pep,
86-
refuri=(self.document.settings.pep_base_url + pep_url.format(int(ref_pep)))))
87-
new_body.append(space)
83+
new_body += [nodes.reference("", ref_pep, refuri=pep_url.format(int(ref_pep)))]
84+
new_body += [nodes.Text(", ")]
8885
para[:] = new_body[:-1] # drop trailing space
8986
elif name in {"last-modified", "content-type", "version"}:
9087
# Mark unneeded fields

pep_sphinx_extensions/pep_processor/transforms/pep_zero.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def visit_entry(self, node: nodes.entry) -> None:
6868
if isinstance(para, nodes.paragraph) and len(para) == 1:
6969
pep_str = para.astext()
7070
try:
71-
ref = self.document.settings.pep_base_url + pep_url.format(int(pep_str))
71+
ref = pep_url.format(int(pep_str))
7272
para[0] = nodes.reference(pep_str, pep_str, refuri=ref)
7373
except ValueError:
7474
pass

0 commit comments

Comments
 (0)