Skip to content

Commit 40a8d4e

Browse files
authored
Infra: Faster incremental builds, up to 5.4x (#4848)
1 parent b8b9506 commit 40a8d4e

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

.github/workflows/render.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
python -m pip install --upgrade pip
4343
4444
- name: Render PEPs
45-
run: make dirhtml JOBS=$(nproc)
45+
run: make dirhtml search JOBS=$(nproc)
4646

4747
# remove the .doctrees folder when building for deployment as it takes two thirds of disk space
4848
- name: Clean up files

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build:
1313
- asdf plugin add uv
1414
- asdf install uv latest
1515
- asdf global uv latest
16-
- make dirhtml JOBS=$(nproc) BUILDDIR=_readthedocs/html
16+
- make dirhtml search JOBS=$(nproc) BUILDDIR=_readthedocs/html
1717

1818
sphinx:
1919
builder: dirhtml

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ ALLSPHINXOPTS = --builder $(BUILDER) \
2222
.PHONY: html
2323
html: venv
2424
$(SPHINXBUILD) $(ALLSPHINXOPTS)
25-
$(VENVDIR)/bin/python3 -m pagefind --site $(BUILDDIR) --verbose
2625

2726
## htmlview to open the index page built by the html target in your browser
2827
.PHONY: htmlview
@@ -43,6 +42,11 @@ dirhtml: BUILDER = dirhtml
4342
dirhtml: html
4443
mv $(BUILDDIR)/404/index.html $(BUILDDIR)/404.html
4544

45+
## search to rebuild the search index
46+
.PHONY: search
47+
search: venv
48+
$(VENVDIR)/bin/python3 -m pagefind --site $(BUILDDIR) --verbose
49+
4650
## linkcheck to check validity of links within PEP sources
4751
.PHONY: linkcheck
4852
linkcheck: BUILDER = linkcheck

pep_sphinx_extensions/pep_zero_generator/subindices.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@
1616

1717
def update_sphinx(filename: str, text: str, docnames: list[str], env: BuildEnvironment) -> Path:
1818
file_path = Path(env.srcdir, f"{filename}.rst")
19-
file_path.write_text(text, encoding="utf-8")
20-
21-
# Add to files for builder
22-
docnames.append(filename)
23-
# Add to files for writer
19+
# Only write and schedule for rebuild if content actually changed
20+
try:
21+
current = file_path.read_text(encoding="utf-8")
22+
except FileNotFoundError:
23+
current = None
24+
if current != text:
25+
file_path.write_text(text, encoding="utf-8")
26+
if filename not in docnames:
27+
docnames.append(filename)
28+
29+
# Always ensure Sphinx knows about the file
2430
env.found_docs.add(filename)
2531

2632
return file_path

peps/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
"api/*.rst",
4444
# Documentation
4545
"docs/*.rst",
46+
# Generated index files
47+
"numerical.rst",
48+
"topic/*.rst",
4649
]
4750
# And to ignore when looking for source files.
4851
exclude_patterns = [

0 commit comments

Comments
 (0)