5
5
from docutils .transforms import misc
6
6
from docutils .transforms import
F308
references
7
7
8
+ import pep_extensions .config as pep_config
8
9
9
10
class PEPTargetNotes (transforms .Transform ):
10
11
@@ -17,7 +18,8 @@ class PEPTargetNotes(transforms.Transform):
17
18
default_priority = 520
18
19
19
20
def apply (self ):
20
- if not Path (self .document ["source" ]).match ("pep-*" ):
21
+ pep_source_path = Path (self .document ["source" ])
22
+ if not pep_source_path .match ("pep-*" ):
21
23
# not a PEP file
22
24
return
23
25
@@ -49,6 +51,8 @@ def apply(self):
49
51
reference_section .append (pending )
50
52
self .document .note_pending (pending , 1 )
51
53
54
+ self .add_source_link (pep_source_path )
55
+
52
56
@staticmethod
53
57
def cleanup_callback (pending ):
54
58
"""
@@ -58,3 +62,9 @@ def cleanup_callback(pending):
58
62
"""
59
63
if len (pending .parent ) == 2 : # <title> and <pending>
60
64
pending .parent .parent .remove (pending .parent )
65
+
66
+ def add_source_link (self , pep_source_path : Path ) -> None :
67
+ source_link = pep_config .pep_vcs_url .format (pep_source_path .name )
68
+ link_node = nodes .reference ("" , source_link , refuri = source_link )
69
+ span_node = nodes .inline ("" , "Source: " , link_node )
70
+ self .document .append (span_node )
0 commit comments