File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import argparse
4
4
from pathlib import Path
5
- import shutil
6
5
7
6
from sphinx .application import Sphinx
8
7
@@ -25,11 +24,16 @@ def create_parser():
25
24
return parser .parse_args ()
26
25
27
26
28
- def create_index_file (html_root : Path , builder : str ):
27
+ def create_index_file (html_root : Path , builder : str ) -> None :
29
28
"""Copies PEP 0 to the root index.html so that /peps/ works."""
30
- pep_zero_path = html_root / ("pep-0000.html" if builder == "html" else "pep-0000/index.html" )
31
- if pep_zero_path .is_file ():
32
- shutil .copy (pep_zero_path , html_root / "index.html" )
29
+ pep_zero_file = "pep-0000.html" if builder == "html" else "pep-0000/index.html"
30
+ try :
31
+ pep_zero_text = html_root .joinpath (pep_zero_file ).read_text (encoding = "utf-8" )
32
+ except FileNotFoundError :
33
+ return None
34
+ if builder == "dirhtml" :
35
+ pep_zero_text = pep_zero_text .replace ('="../' , '="' ) # remove relative directory links
36
+ html_root .joinpath ("index.html" ).write_text (pep_zero_text , encoding = "utf-8" )
33
37
34
38
35
39
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments