Skip to content

Commit

Permalink
Add/update build and run
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed May 7, 2021
1 parent 8d8360b commit 5f06b74
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
14 changes: 14 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import argparse
from pathlib import Path
import shutil

from sphinx.application import Sphinx

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


def create_index_file(html_content: Path):
pep_zero_html = html_content / "pep-0000.html"
pep_zero_dir = html_content / "pep-0000" / "index.html"

if pep_zero_html.is_file():
shutil.copy(pep_zero_html, html_content / "index.html")
elif pep_zero_dir.is_file():
shutil.copy(pep_zero_dir, html_content / "index.html")


if __name__ == "__main__":
args = create_parser()

Expand Down Expand Up @@ -52,3 +63,6 @@ def create_parser():
)
app.builder.copysource = False # Prevent unneeded source copying - we link direct to GitHub
app.build()

if args.index_file:
create_index_file(build_directory)
8 changes: 8 additions & 0 deletions conf.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
"""Configuration for building PEPs using Sphinx."""

import sys
from pathlib import Path

sys.path.append(str(Path("pep_sphinx_extensions").absolute()))

# -- Project information -----------------------------------------------------

project = "PEPs"
master_doc = "contents"

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings.
extensions = ["pep_sphinx_extensions"]

# The file extensions of source files. Sphinx uses these suffixes as sources.
source_suffix = {
".rst": "restructuredtext",
Expand Down
13 changes: 13 additions & 0 deletions pep_sphinx_extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Sphinx extensions for performant PEP processing"""

from sphinx.application import Sphinx

from pep_sphinx_extensions.pep_zero_generator.pep_index_generator import create_pep_zero


def setup(app: Sphinx) -> dict:
"""Initialise Sphinx extension."""

app.connect("env-before-read-docs", create_pep_zero) # PEP 0 hook

return {"parallel_read_safe": True, "parallel_write_safe": True}

0 comments on commit 5f06b74

Please sign in to comment.