diff --git a/tools/layout/README.md b/tools/layout/README.md index 24182de2bc..53b1d62521 100644 --- a/tools/layout/README.md +++ b/tools/layout/README.md @@ -91,6 +91,10 @@ a path that does not exist when it existed before the move or its first missing `cmake -S ` whose folder has no CMakeLists.txt. It found a test that skipped silently after the move and several release build scripts. Dual-layout fallbacks that read both layouts on purpose show up as hits to read, not as breaks. +`checks/docs_paths.py [--explained checks/docs_paths_explained.txt]` reads the code spans and blocks of the user-facing pages +(docs/*.md, README.md, AGENTS.md, .github/*.md) and lists every command or path that existed before the move, does not exist now and has a new place +(`tools/iq_pack.py`, `.venv/bin/python`, `-m serve.server`). It reports no hit on the head of 0.2.16. + Run each Windows test file in its own process. In one combined pytest run, `serve/winjob.py` and `serve/lifeline.py` keep the `subprocess.Popen` that an earlier test may have replaced, and 7 tests fail in both trees for that reason only. diff --git a/tools/layout/checks/docs_paths.py b/tools/layout/checks/docs_paths.py index e15f85095a..1740f13b96 100644 --- a/tools/layout/checks/docs_paths.py +++ b/tools/layout/checks/docs_paths.py @@ -13,6 +13,8 @@ Also reported: commands that start a moved program from the repository root as b Prints one line per hit: page:line: token -> new path [context]. Exit 1 while a hit is left. --fix-list FILE writes "pagelineoldnewcontext" for the hits whose context is a command (a block or a span that starts like a command); --fix-all FILE writes it for every hit. +--explained FILE: lines "page | text | reason" for hits that are correct as written. A bare file name in a sentence (setup.py, strata.py) is not a hit: it matters +only as the program of a command. """ import posixpath import re @@ -22,6 +24,13 @@ import sys repo, rev, before = sys.argv[1:4] fix_list = sys.argv[sys.argv.index("--fix-list") + 1] if "--fix-list" in sys.argv else None fix_all = sys.argv[sys.argv.index("--fix-all") + 1] if "--fix-all" in sys.argv else None +explained_file = sys.argv[sys.argv.index("--explained") + 1] if "--explained" in sys.argv else None +EXPLAINED = [] # (page, text in the span or line, reason): a hit that is correct as written (checks/docs_paths_explained.txt) +if explained_file: + for _l in open(explained_file, encoding="utf-8"): + _p = [x.strip() for x in _l.rstrip("\n").split("|", 2)] + if len(_p) == 3 and _p[0] and not _p[0].startswith("#"): + EXPLAINED.append((_p[0], _p[1], _p[2])) sys.stdout.reconfigure(encoding="utf-8", errors="replace") @@ -123,6 +132,10 @@ for page in pages: if tok in old_tree or tok in old_dirs: nw = new_path(tok) if nw and nw != tok and (nw in tree or nw in dirs): + if tok in ("setup.py", "strata.py") and not re.search(r"(?:python3?(?:\.exe)?|py -3|[/\\]python(?:\.exe)?)\s+(?:-\S+\s+)*" + re.escape(tok), body): + continue # the name of one file in a sentence does not mislead; it matters as a command's program + if any(p == page and t in body for p, t, _why in EXPLAINED): + continue hits.append((page, n, tok, nw, "command" if (is_cmd or block) else "prose")) # the commands that start moved programs from the root if is_cmd: diff --git a/tools/layout/checks/docs_paths_explained.txt b/tools/layout/checks/docs_paths_explained.txt new file mode 100644 index 0000000000..a067ecf749 --- /dev/null +++ b/tools/layout/checks/docs_paths_explained.txt @@ -0,0 +1,3 @@ +# page | text in the span or code line | reason (hits of checks/docs_paths.py that are correct as written) +.github/SECURITY.md | strata_control/update_keys.json | names the key inside an INSTALLED Strata (the installed layout has strata_control/ at its top) +docs/SAFETY.md | strata_control/update_keys.json | names the key inside an INSTALLED Strata (the installed layout has strata_control/ at its top)