-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlint_docs.py
More file actions
78 lines (67 loc) · 2.33 KB
/
Copy pathlint_docs.py
File metadata and controls
78 lines (67 loc) · 2.33 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
"""Thin orchestrator: run all documentation linters via infrastructure.validation.docs.lint_runner."""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from scripts import ensure_repo_root_on_path # noqa: E402
ensure_repo_root_on_path()
from infrastructure.validation.docs.lint_runner import ( # noqa: E402
format_docs_lint_report,
run_docs_lint,
)
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(
description="Run mermaid + cross-link + consistency linters across the repo.",
)
parser.add_argument("--mermaid-only", action="store_true")
parser.add_argument("--links-only", action="store_true")
parser.add_argument("--consistency-only", action="store_true")
parser.add_argument("--doc-pairs-only", action="store_true")
parser.add_argument("--quiet", action="store_true")
parser.add_argument("--json", action="store_true")
parser.add_argument("--strict-mermaid", action="store_true")
parser.add_argument(
"--repo-root",
type=Path,
default=Path(__file__).resolve().parents[2],
)
parser.add_argument(
"--paths",
nargs="+",
metavar="PATH",
default=None,
help=(
"Scope the lint to repo-relative files/directories (e.g. "
"--paths README.md START_HERE.md docs/) for fast targeted checks "
"on slow volumes; omit for the full repo-wide scan."
),
)
args = parser.parse_args(argv)
repo_root = args.repo_root.resolve()
try:
report = run_docs_lint(
repo_root,
mermaid_only=args.mermaid_only,
links_only=args.links_only,
consistency_only=args.consistency_only,
doc_pairs_only=args.doc_pairs_only,
quiet=args.quiet,
strict_mermaid=args.strict_mermaid,
paths=args.paths,
)
except ValueError as exc:
parser.error(str(exc))
return 2
formatted = format_docs_lint_report(
report,
repo_root,
as_json=args.json,
quiet=args.quiet,
)
if formatted is not None:
sys.stdout.write(formatted)
return report.exit_code
if __name__ == "__main__":
sys.exit(main())