Skip to content

Commit 714d413

Browse files
committed
feat(validate): integrate narration lint into validation flow
docgen validate now runs pre-TTS narration lint alongside the existing stream-presence and A/V-drift checks. Each segment's narration file is located via resolve_segment_name and checked against the configured deny patterns. Issues are capped at 10 per segment for readability. Made-with: Cursor
1 parent 01f7965 commit 714d413

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/docgen/validate.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def validate_segment(
6262
else:
6363
report.checks.append(CheckResult("recording_exists", False, [f"No recording for {seg_id}"]))
6464

65+
report.checks.append(self._check_narration_lint(seg_id))
66+
6567
return report.to_dict()
6668

6769
def run_pre_push(self) -> None:
@@ -87,6 +89,34 @@ def print_report(self, reports: list) -> None:
8789
for d in c.get("details", []):
8890
print(f" {d}")
8991

92+
def _check_narration_lint(self, seg_id: str) -> CheckResult:
93+
narr = self._find_narration(seg_id)
94+
if not narr:
95+
return CheckResult("narration_lint", True, ["No narration file (skipped)"])
96+
from docgen.narration_lint import lint_pre_tts
97+
text = narr.read_text(encoding="utf-8")
98+
deny = self.config.narration_lint_config.get("pre_tts_deny_patterns")
99+
result = lint_pre_tts(text, deny_patterns=deny)
100+
return CheckResult(
101+
"narration_lint",
102+
result.passed,
103+
result.issues[:10] if result.issues else [],
104+
)
105+
106+
def _find_narration(self, seg_id: str) -> Path | None:
107+
d = self.config.narration_dir
108+
if not d.exists():
109+
return None
110+
seg_name = self.config.resolve_segment_name(seg_id)
111+
exact = d / f"{seg_name}.md"
112+
if exact.exists():
113+
return exact
114+
for md in d.glob(f"{seg_id}-*.md"):
115+
return md
116+
for md in d.glob(f"*{seg_id}*.md"):
117+
return md
118+
return None
119+
90120
def _find_recording(self, seg_id: str) -> Path | None:
91121
d = self.config.recordings_dir
92122
if not d.exists():

0 commit comments

Comments
 (0)