Skip to content

Commit 03e0e4c

Browse files
committed
Add --clean arg to take a list of comma-seperated files to touch
1 parent 9517c21 commit 03e0e4c

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

.github/workflows/reusable-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
continue-on-error: true
4747
run: |
4848
# Mark files the pull request modified
49-
touch ${{ steps.changed_files.outputs.added_modified }}
49+
python Doc/tools/touch-clean-files.py --clean ${{ steps.changed_files.outputs.added_modified }}
5050
# Build docs with the '-n' (nit-picky) option; convert warnings to annotations
5151
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n --keep-going" html 2>&1 |
5252
python Doc/tools/warnings-to-gh-actions.py

Doc/tools/touch-clean-files.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
Touch files that must pass Sphinx nit-picky mode
44
so they are rebuilt and we can catch regressions.
55
"""
6-
6+
import argparse
7+
import csv
78
from pathlib import Path
89

910
wrong_directory_msg = "Must run this script from the repo root"
@@ -28,14 +29,28 @@
2829
rst for rst in Path("Doc/").rglob("*.rst") if rst.parts[1] not in EXCLUDE_SUBDIRS
2930
}
3031

31-
with Path("Doc/tools/.nitignore").open() as clean_files:
32-
DIRTY = {
32+
33+
parser = argparse.ArgumentParser(
34+
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
35+
)
36+
parser.add_argument("-c", "--clean", help="Comma-separated list of clean files")
37+
args = parser.parse_args()
38+
39+
if args.clean:
40+
clean_files = next(csv.reader([args.clean]))
41+
CLEAN = {
3342
Path(filename.strip())
3443
for filename in clean_files
35-
if filename.strip() and not filename.startswith("#")
44+
if Path(filename.strip()).is_file()
3645
}
37-
38-
CLEAN = ALL_RST - DIRTY - EXCLUDE_FILES
46+
else:
47+
with Path("Doc/tools/.nitignore").open() as ignored_files:
48+
IGNORED = {
49+
Path(filename.strip())
50+
for filename in ignored_files
51+
if filename.strip() and not filename.startswith("#")
52+
}
53+
CLEAN = ALL_RST - IGNORED - EXCLUDE_FILES
3954

4055
print("Touching:")
4156
for filename in sorted(CLEAN):

0 commit comments

Comments
 (0)