(argv: list[str])
| 869 | |
| 870 | |
| 871 | def main(argv: list[str]) -> int: |
| 872 | parser = argparse.ArgumentParser( |
| 873 | description="Markdown linter for AI-narration / marketing-copy patterns", |
| 874 | epilog="With no arguments, scans doc/help, README.md, AGENTS.md, examples/.", |
| 875 | ) |
| 876 | parser.add_argument( |
| 877 | "paths", |
| 878 | nargs="*", |
| 879 | type=Path, |
| 880 | help="files or directories to scan (default: repo trees)", |
| 881 | ) |
| 882 | parser.add_argument( |
| 883 | "--no-report", |
| 884 | action="store_true", |
| 885 | help="skip writing .doc-report at the repo root", |
| 886 | ) |
| 887 | parser.add_argument( |
| 888 | "--quiet", |
| 889 | "-q", |
| 890 | action="store_true", |
| 891 | help="don't print per-finding lines (rely on .doc-report)", |
| 892 | ) |
| 893 | |
| 894 | args = parser.parse_args(argv) |
| 895 | |
| 896 | repo_root = Path(__file__).resolve().parent.parent |
| 897 | if not args.paths: |
| 898 | targets = default_targets(repo_root) |
| 899 | if not targets: |
| 900 | print("no default targets exist; pass paths explicitly", file=sys.stderr) |
| 901 | return 2 |
| 902 | args.paths = targets |
| 903 | |
| 904 | files = list(iter_markdown_files(args.paths)) |
| 905 | if not files: |
| 906 | print("no markdown files found", file=sys.stderr) |
| 907 | return 2 |
| 908 | |
| 909 | findings: list[Finding] = [] |
| 910 | for path in files: |
| 911 | findings.extend(scan_file(path)) |
| 912 | |
| 913 | if not args.quiet: |
| 914 | for f in findings: |
| 915 | print(f"{f.path}:{f.line}:{f.col}: {f.kind}: {f.message}") |
| 916 | |
| 917 | if not args.no_report: |
| 918 | write_report(repo_root / ".doc-report", findings) |
| 919 | |
| 920 | by_kind: dict[str, int] = {} |
| 921 | for f in findings: |
| 922 | by_kind[f.kind] = by_kind.get(f.kind, 0) + 1 |
| 923 | |
| 924 | print(f"\n{len(files)} files scanned, {len(findings)} findings", file=sys.stderr) |
| 925 | if by_kind: |
| 926 | for kind in sorted(by_kind): |
| 927 | print(f" {kind}: {by_kind[kind]}", file=sys.stderr) |
| 928 |
no test coverage detected