Skip to content

Commit 5f06b74

Browse files
committed
Add/update build and run
1 parent 8d8360b commit 5f06b74

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

build.py

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import argparse
44
from pathlib import Path
5+
import shutil
56

67
from sphinx.application import Sphinx
78

@@ -22,6 +23,16 @@ def create_parser():
2223
return parser.parse_args()
2324

2425

26+
def create_index_file(html_content: Path):
27+
pep_zero_html = html_content / "pep-0000.html"
28+
pep_zero_dir = html_content / "pep-0000" / "index.html"
29+
30+
if pep_zero_html.is_file():
31+
shutil.copy(pep_zero_html, html_content / "index.html")
32+
elif pep_zero_dir.is_file():
33+
shutil.copy(pep_zero_dir, html_content / "index.html")
34+
35+
2536
if __name__ == "__main__":
2637
args = create_parser()
2738

@@ -52,3 +63,6 @@ def create_parser():
5263
)
5364
app.builder.copysource = False # Prevent unneeded source copying - we link direct to GitHub
5465
app.build()
66+
67+
if args.index_file:
68+
create_index_file(build_directory)

conf.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
"""Configuration for building PEPs using Sphinx."""
22

3+
import sys
4+
from pathlib import Path
5+
6+
sys.path.append(str(Path("pep_sphinx_extensions").absolute()))
7+
38
# -- Project information -----------------------------------------------------
49

510
project = "PEPs"
611
master_doc = "contents"
712

813
# -- General configuration ---------------------------------------------------
914

15+
# Add any Sphinx extension module names here, as strings.
16+
extensions = ["pep_sphinx_extensions"]
17+
1018
# The file extensions of source files. Sphinx uses these suffixes as sources.
1119
source_suffix = {
1220
".rst": "restructuredtext",

pep_sphinx_extensions/__init__.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Sphinx extensions for performant PEP processing"""
2+
3+
from sphinx.application import Sphinx
4+
5+
from pep_sphinx_extensions.pep_zero_generator.pep_index_generator import create_pep_zero
6+
7+
8+
def setup(app: Sphinx) -> dict:
9+
"""Initialise Sphinx extension."""
10+
11+
app.connect("env-before-read-docs", create_pep_zero) # PEP 0 hook
12+
13+
return {"parallel_read_safe": True, "parallel_write_safe": True}

0 commit comments

Comments
 (0)