diff --git a/pep_sphinx_extensions/pep_processor/transforms/pep_zero.py b/pep_sphinx_extensions/pep_processor/transforms/pep_zero.py index a9b0a074ca1..6673f11ece3 100644 --- a/pep_sphinx_extensions/pep_processor/transforms/pep_zero.py +++ b/pep_sphinx_extensions/pep_processor/transforms/pep_zero.py @@ -18,10 +18,10 @@ def apply(self) -> None: class PEPZeroSpecial(nodes.SparseNodeVisitor): - """Perform the special processing needed by PEP 0: + """Perform the special processing needed by PEP 0. - Mask email addresses. - - Link PEP numbers in the second column of 4-column tables to the PEPs themselves. + - Link PEP numbers and PEP titles in the table to the PEPs themselves. """ @@ -29,6 +29,7 @@ def __init__(self, document: nodes.document): super().__init__(document) self.pep_table: int = 0 self.entry: int = 0 + self.ref: str | None = None def unknown_visit(self, node: nodes.Node) -> None: """No processing for undefined node types.""" @@ -57,10 +58,13 @@ def visit_colspec(self, node: nodes.colspec) -> None: def visit_row(self, _node: nodes.row) -> None: self.entry = 0 # reset column number + self.ref = None # Reset PEP URL def visit_entry(self, node: nodes.entry) -> None: self.entry += 1 - if self.pep_table and self.entry == 2 and len(node) == 1: + if not self.pep_table: + return + if self.entry == 2 and len(node) == 1: node["classes"].append("num") # if this is the PEP number column, replace the number with a link to the PEP para = node[0] @@ -70,8 +74,14 @@ def visit_entry(self, node: nodes.entry) -> None: pep_num = int(pep_str) except ValueError: return - ref = self.document.settings.pep_url.format(pep_num) - para[0] = nodes.reference("", pep_str, refuri=ref) + self.ref = self.document.settings.pep_url.format(pep_num) + para[0] = nodes.reference("", pep_str, refuri=self.ref) + elif self.entry == 3 and len(node) == 1 and self.ref: + # If this is the PEP title column, add a link to the PEP + para = node[0] + if isinstance(para, nodes.paragraph) and len(para) == 1: + pep_title = para.astext() + para[0] = nodes.reference("", pep_title, refuri=self.ref) def _mask_email(ref: nodes.reference) -> nodes.reference: