Skip to content

Commit 06dd041

Browse files
committed
docs: add fix hints and doc refs to coverage and MDX validation output
audit_coverage.py: - Coverage miss section now shows a structured Fix:/Ref: block with the exact generate-ast.py command and a link to CONTRIBUTING.md#validating-docstrings - Missing symbols listed one per line (symbol indented under module) for scannability instead of comma-joined on one long line - Emit a ::error or ::warning GHA annotation with symbol/module counts when coverage symbols are undocumented validate.py: - Add _CHECK_FIX_HINTS dict mapping each check label to a (fix text, ref URL) pair, covering all 8 check types with specific fix instructions and links into CONTRIBUTING.md (root or guide as appropriate) - _print_check_errors now prints Fix:/Ref: under each section header, matching the pattern established by _print_quality_report
1 parent b32661e commit 06dd041

2 files changed

Lines changed: 86 additions & 4 deletions

File tree

tooling/docs-autogen/audit_coverage.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,17 @@ def walk_module(module, module_path: str) -> None:
437437

438438
_IN_GHA = os.environ.get("GITHUB_ACTIONS") == "true"
439439

440-
# GitHub URL for the contributing guide docstring checks reference section.
441-
# Each issue kind links to the relevant anchor so developers can navigate directly.
440+
# Base URLs for documentation references emitted in fix hints.
441+
# These point to upstream main; anchors for the CI checks reference section
442+
# will resolve once the PR introducing them is merged.
442443
_CONTRIB_DOCS_URL = (
443444
"https://github.com/generative-computing/mellea/blob/main"
444445
"/docs/docs/guide/CONTRIBUTING.md"
445446
)
447+
_COVERAGE_DOCS_URL = (
448+
"https://github.com/generative-computing/mellea/blob/main"
449+
"/CONTRIBUTING.md#validating-docstrings"
450+
)
446451

447452
# Per-kind fix hints: (one-line fix text, CONTRIBUTING.md anchor)
448453
_KIND_FIX_HINTS: dict[str, tuple[str, str]] = {
@@ -865,11 +870,32 @@ def main():
865870
print(f"CLI commands: {len(report['cli_commands'])}")
866871

867872
if report["missing_symbols"]:
873+
total_missing = sum(len(s) for s in report["missing_symbols"].values())
874+
print(f"\n{'─' * 60}")
875+
print(
876+
f" Missing API docs — {total_missing} symbol(s) across "
877+
f"{len(report['missing_symbols'])} module(s)"
878+
)
868879
print(
869-
f"\n⚠️ Missing documentation for {len(report['missing_symbols'])} modules:"
880+
" Fix: Run the doc generation pipeline to produce MDX for new symbols,\n"
881+
" then add entries to docs/docs/docs.json navigation.\n"
882+
" uv run python tooling/docs-autogen/generate-ast.py"
870883
)
884+
print(f" Ref: {_COVERAGE_DOCS_URL}")
885+
print(f"{'─' * 60}")
871886
for module, symbols in sorted(report["missing_symbols"].items()):
872-
print(f" {module}: {', '.join(symbols)}")
887+
print(f" {module}")
888+
for sym in sorted(symbols):
889+
print(f" {sym}")
890+
if _IN_GHA:
891+
_gha_cmd(
892+
"error" if report["coverage_percentage"] < args.threshold else "warning",
893+
"API Coverage",
894+
f"{total_missing} symbol(s) undocumented in "
895+
f"{len(report['missing_symbols'])} module(s) — "
896+
f"coverage {report['coverage_percentage']}% "
897+
f"(threshold {args.threshold}%)",
898+
)
873899

874900
# Quality audit — scoped to documented (API reference) symbols only
875901
quality_issues: list[dict] = []

tooling/docs-autogen/validate.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,57 @@
1818

1919
_IN_GHA = os.environ.get("GITHUB_ACTIONS") == "true"
2020

21+
_ROOT_CONTRIB = (
22+
"https://github.com/generative-computing/mellea/blob/main/CONTRIBUTING.md"
23+
)
24+
_GUIDE_CONTRIB = (
25+
"https://github.com/generative-computing/mellea/blob/main"
26+
"/docs/docs/guide/CONTRIBUTING.md"
27+
)
28+
29+
# Per-check fix hints: label (as passed to _print_check_errors) -> (fix text, ref URL)
30+
_CHECK_FIX_HINTS: dict[str, tuple[str, str]] = {
31+
"Source links": (
32+
"Regenerate API docs to update version tags in source links: "
33+
"uv run python tooling/docs-autogen/generate-ast.py",
34+
f"{_ROOT_CONTRIB}#validating-docstrings",
35+
),
36+
"MDX syntax": (
37+
"Check for unclosed ``` fences, missing frontmatter, or unescaped {{ }} "
38+
"in code blocks. Each error includes the file and line number.",
39+
f"{_GUIDE_CONTRIB}#frontmatter-required-on-every-page",
40+
),
41+
"Internal links": (
42+
"Verify the relative link path resolves to an existing .mdx file. "
43+
"Each error shows the file, line, and broken link target.",
44+
f"{_GUIDE_CONTRIB}#links",
45+
),
46+
"Anchor collisions": (
47+
"Rename one of the conflicting headings so they produce unique anchors. "
48+
"Each error shows both heading texts and their line numbers.",
49+
f"{_GUIDE_CONTRIB}#headings",
50+
),
51+
"RST docstrings": (
52+
"Replace RST double-backtick notation (``Symbol``) with single backticks "
53+
"(`Symbol`) in the Python source docstring.",
54+
f"{_ROOT_CONTRIB}#docstrings",
55+
),
56+
"Stale files": (
57+
"Delete the listed files — they are review artifacts or superseded content "
58+
"that should not ship.",
59+
f"{_GUIDE_CONTRIB}#missing-content",
60+
),
61+
"Doc imports": (
62+
"Update the import path in the documentation code block to match the "
63+
"current module/symbol location.",
64+
f"{_GUIDE_CONTRIB}#code-and-fragment-consistency",
65+
),
66+
"Examples catalogue": (
67+
"Add a row for the new example directory to docs/docs/examples/index.md.",
68+
f"{_GUIDE_CONTRIB}#keeping-the-examples-catalogue-up-to-date",
69+
),
70+
}
71+
2172
# GitHub Actions silently drops inline diff annotations beyond ~10 per step.
2273
# We cap at 20 total across all validate.py checks so the most important issues
2374
# from each category remain visible in the PR diff. The complete list is always
@@ -590,8 +641,13 @@ def _print_check_errors(
590641
"""
591642
if not errors:
592643
return
644+
fix_hint, ref_url = _CHECK_FIX_HINTS.get(label, ("", ""))
593645
print(f"\n{'─' * 50}")
594646
print(f" {label} ({len(errors)} error(s))")
647+
if fix_hint:
648+
print(f" Fix: {fix_hint}")
649+
if ref_url:
650+
print(f" Ref: {ref_url}")
595651
print(f"{'─' * 50}")
596652
capped = 0
597653
for e in errors:

0 commit comments

Comments
 (0)