@@ -10,12 +10,6 @@ class PEPFooter(transforms.Transform):
1010 """Footer transforms for PEPs.
1111
1212 - Remove the References/Footnotes section if it is empty when rendered.
13- - Create a link to the (GitHub) source text.
14-
15- Source Link:
16- Create the link to the source file from the document source path,
17- and append the text to the end of the document.
18-
1913 """
2014
2115 # Uses same priority as docutils.transforms.TargetNotes
@@ -44,31 +38,21 @@ def apply(self) -> None:
4438 section .parent .extend (to_hoist )
4539 section .parent .remove (section )
4640
47- # Add link to source text and last modified date
48- if pep_source_path .stem != "pep-0000" :
49- if pep_source_path .stem != "pep-0210" : # 210 is entirely empty, skip
50- self .document += nodes .transition ()
51- self .document += _add_source_link (pep_source_path )
52- self .document += _add_commit_history_info (pep_source_path )
53-
54-
55- def _add_source_link (pep_source_path : Path ) -> nodes .paragraph :
56- """Add link to source text on VCS (GitHub)"""
57- source_link = f"https://github.com/python/peps/blob/main/peps/{ pep_source_path .name } "
58- link_node = nodes .reference ("" , source_link , refuri = source_link )
59- return nodes .paragraph ("" , "Source: " , link_node )
60-
61-
62- def _add_commit_history_info (pep_source_path : Path ) -> nodes .paragraph :
63- """Use local git history to find last modified date."""
64- try :
65- iso_time = _LAST_MODIFIED_TIMES [pep_source_path .stem ]
66- except KeyError :
67- return nodes .paragraph ()
6841
69- commit_link = f"https://github.com/python/peps/commits/main/peps/{ pep_source_path .name } "
70- link_node = nodes .reference ("" , f"{ iso_time } GMT" , refuri = commit_link )
71- return nodes .paragraph ("" , "Last modified: " , link_node )
42+ def get_page_footer_context (pep_stem : str ) -> dict [str , str ]:
43+ """Template context for the page footer, rendered by ``page.html``."""
44+ context = {
45+ "source_link" : (
46+ f"https://github.com/python/peps/blob/main/peps/{ pep_stem } .rst"
47+ ),
48+ }
49+ iso_time = _LAST_MODIFIED_TIMES .get (pep_stem , "" )
50+ if iso_time :
51+ context ["last_modified" ] = iso_time
52+ context ["commit_link" ] = (
53+ f"https://github.com/python/peps/commits/main/peps/{ pep_stem } .rst"
54+ )
55+ return context
7256
7357
7458def _get_last_modified_timestamps ():
0 commit comments