add project, change cli file names, use config

This commit is contained in:
2026-09-16 08:17:29 -03:00
parent a29e0708e8
commit 86d051da48
47 changed files with 3218 additions and 2106 deletions

View File

@@ -5,7 +5,7 @@ Called wherever the IR crosses between layers: after an extractor writes one,
before an emitter reads one. That is the whole point of having one format — the
check is in one place instead of every consumer defending itself.
python3 -m docgen.ir path/to/ir.json
python3 -m docgen validate path/to/ir.json
Stdlib only. This is not a general JSON Schema engine and does not want to be;
it reads the field lists **out of `schema.json`** so the two cannot drift, then
@@ -23,7 +23,6 @@ that produce a broken diagram.
import json
import re
import sys
from pathlib import Path
HERE = Path(__file__).resolve().parent
@@ -276,37 +275,3 @@ def check_model_matches_schema() -> list[str]:
for extra in actual - declared:
problems.append(f"{cls.__name__} has {extra!r}; schema does not declare it")
return problems
def main(argv=None) -> int:
argv = sys.argv[1:] if argv is None else argv
if not argv:
print("usage: python3 -m docgen.ir <ir.json>", file=sys.stderr)
return 2
drift = check_model_matches_schema()
if drift:
print("model.py and schema.json disagree:", file=sys.stderr)
for d in drift:
print(f" {d}", file=sys.stderr)
return 1
path = Path(argv[0])
try:
data = json.loads(path.read_text())
except (OSError, json.JSONDecodeError) as e:
print(f"Error: could not read {path}: {e}", file=sys.stderr)
return 1
problems = check(data)
if problems:
print(f"{path}: {len(problems)} problem(s)", file=sys.stderr)
for p in problems:
print(f" {p}", file=sys.stderr)
return 1
print(
f"{path}: ok — {len(data['nodes'])} nodes, {len(data['edges'])} edges, "
f"schema v{data['meta'].get('schema_version')}"
)
return 0