@@ -18,17 +18,18 @@ def apply(self) -> None:
18
18
19
19
20
20
class PEPZeroSpecial (nodes .SparseNodeVisitor ):
21
- """Perform the special processing needed by PEP 0:
21
+ """Perform the special processing needed by PEP 0.
22
22
23
23
- Mask email addresses.
24
- - Link PEP numbers in the second column of 4-column tables to the PEPs themselves.
24
+ - Link PEP numbers and PEP titles in the table to the PEPs themselves.
25
25
26
26
"""
27
27
28
28
def __init__ (self , document : nodes .document ):
29
29
super ().__init__ (document )
30
30
self .pep_table : int = 0
31
31
self .entry : int = 0
32
+ self .ref : str | None = None
32
33
33
34
def unknown_visit (self , node : nodes .Node ) -> None :
34
35
"""No processing for undefined node types."""
@@ -57,10 +58,13 @@ def visit_colspec(self, node: nodes.colspec) -> None:
57
58
58
59
def visit_row (self , _node : nodes .row ) -> None :
59
60
self .entry = 0 # reset column number
61
+ self .ref = None # Reset PEP URL
60
62
61
63
def visit_entry (self , node : nodes .entry ) -> None :
62
64
self .entry += 1
63
- if self .pep_table and self .entry == 2 and len (node ) == 1 :
65
+ if not self .pep_table :
66
+ return
67
+ if self .entry == 2 and len (node ) == 1 :
64
68
node ["classes" ].append ("num" )
65
69
# if this is the PEP number column, replace the number with a link to the PEP
66
70
para = node [0 ]
@@ -70,8 +74,14 @@ def visit_entry(self, node: nodes.entry) -> None:
70
74
pep_num = int (pep_str )
71
75
except ValueError :
72
76
return
73
- ref = self .document .settings .pep_url .format (pep_num )
74
- para [0 ] = nodes .reference ("" , pep_str , refuri = ref )
77
+ self .ref = self .document .settings .pep_url .format (pep_num )
78
+ para [0 ] = nodes .reference ("" , pep_str , refuri = self .ref )
79
+ elif self .entry == 3 and len (node ) == 1 and self .ref :
80
+ # If this is the PEP title column, add a link to the PEP
81
+ para = node [0 ]
82
+ if isinstance (para , nodes .paragraph ) and len (para ) == 1 :
83
+ pep_title = para .astext ()
84
+ para [0 ] = nodes .reference ("" , pep_title , refuri = self .ref )
75
85
76
86
77
87
def _mask_email (ref : nodes .reference ) -> nodes .reference :
0 commit comments