Skip to content

Commit a05071b

Browse files
committed
Only rebuild index files when PEP metadata changes, not on every build
1 parent 0f1645c commit a05071b

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

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)