Skip to content

Commit

Permalink
support read the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Mar 11, 2022
1 parent ba09f18 commit 6a13d3d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def create_index_file(html_root: Path, builder: str) -> None:
confoverrides=config_overrides,
warningiserror=args.fail_on_warning,
parallel=args.jobs,
tags=["internal_builder"],
)
app.build()

Expand Down
16 changes: 15 additions & 1 deletion pep_sphinx_extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,25 @@ def _depart_maths():
pass # No-op callable for the type checker


def _update_config_for_builder(app: Sphinx):
def _update_config_for_builder(app: Sphinx) -> None:
app.env.document_ids = {} # For PEPReferenceRoleTitleText
if app.builder.name == "dirhtml":
app.env.settings["pep_url"] = "../pep-{:0>4}"

# internal_builder exists if Sphinx is run by build.py
if "internal_builder" not in app.tags:
app.connect("build-finished", _post_build) # Post-build tasks


def _post_build(app: Sphinx, exception: Exception | None) -> None:
from pathlib import Path

from build import create_index_file

if exception is not None:
return
create_index_file(Path(app.outdir), app.builder.name)


def setup(app: Sphinx) -> dict[str, bool]:
"""Initialize Sphinx extension."""
Expand Down
16 changes: 16 additions & 0 deletions readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

build:
os: ubuntu-20.04
tools:
python: "3.9"

python:
install:
- requirements: requirements.txt

sphinx:
builder: dirhtml

search:
ignore: ['*']

0 comments on commit 6a13d3d

Please sign in to comment.