blob: 2b045bd68a0cf0dd3eb5b7f334edaa0172f293fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/usr/bin/env python3
"""
Touch files that must pass Sphinx nit-picky mode
so they are rebuilt and we can catch regressions.
"""
import argparse
import csv
import sys
from pathlib import Path
wrong_directory_msg = "Must run this script from the repo root"
assert Path("Doc").exists() and Path("Doc").is_dir(), wrong_directory_msg
# Exclude these whether they're dirty or clean,
# because they trigger a rebuild of dirty files.
EXCLUDE_FILES = {
Path("Doc/whatsnew/changelog.rst"),
}
# Subdirectories of Doc/ to exclude.
EXCLUDE_SUBDIRS = {
".env",
".venv",
"env",
"includes",
"venv",
}
ALL_RST = {
rst for rst in Path("Doc/").rglob("*.rst") if rst.parts[1] not in EXCLUDE_SUBDIRS
}
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument("-c", "--clean", help="Comma-separated list of clean files")
args = parser.parse_args()
if args.clean:
clean_files = next(csv.reader([args.clean]))
CLEAN = {
Path(filename.strip())
for filename in clean_files
if Path(filename.strip()).is_file()
}
elif args.clean is not None:
print(
"Not touching any files: an empty string `--clean` arg value passed.",
)
sys.exit(0)
else:
with Path("Doc/tools/.nitignore").open() as ignored_files:
IGNORED = {
Path(filename.strip())
for filename in ignored_files
if filename.strip() and not filename.startswith("#")
}
CLEAN = ALL_RST - IGNORED - EXCLUDE_FILES
print("Touching:")
for filename in sorted(CLEAN):
print(filename)
filename.touch()
print(f"Touched {len(CLEAN)} files")
|