Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRS: Enable PR previews #2023

Merged
merged 1 commit into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: ['*']