Stage 1 flags the living documents a pull request makes stale (no model, nothing sent). Stage 2, on repositories that opt in with drafter: claude, has Claude Code draft the edits in a sandboxed copy of the tree and opens them as a pull request into the feature branch. A monthly pass re-reads the top-level documents against the whole repository. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
ade847ba5b
38 files changed
+4286
No files matched your search
@@ -0,0 +1,64 @@
|
||||
import json
|
||||
import unittest
|
||||
|
||||
from docs_review.flags import Flag
|
||||
from docs_review.report import (
|
||||
MONTHLY_MARKER, STAGE1_MARKER, render_clean, render_comment, render_issue,
|
||||
stage1_json,
|
||||
)
|
||||
|
||||
DEAD = Flag("dead", "README.md", "R/old.R", "removed")
|
||||
UNCOV = Flag("uncovered", None, "scripts/report_*", "3 files")
|
||||
TOUCH = Flag("touched", "docs/a.md", "R/x.R", "changed")
|
||||
STALE = Flag("stale_generated", "docs/g.md", "R/x.R", "input changed: R/x.R")
|
||||
UNG = Flag("unguided", "docs/b.md", "docs/b.md", "not described in docs/README.md")
|
||||
|
||||
|
||||
class ReportTest(unittest.TestCase):
|
||||
def test_empty_is_none(self):
|
||||
self.assertIsNone(render_comment((), head_sha="abc"))
|
||||
|
||||
def test_comment_sections_in_order(self):
|
||||
body = render_comment([UNG, STALE, UNCOV, DEAD, TOUCH], head_sha="abc")
|
||||
self.assertTrue(body.startswith(STAGE1_MARKER))
|
||||
heads = [l for l in body.splitlines() if l.startswith("### ")]
|
||||
self.assertEqual(heads, ["### Touched", "### Dead", "### Uncovered",
|
||||
"### Stale generated", "### Unguided"])
|
||||
self.assertIn("- `README.md`: `R/old.R` (removed)", body)
|
||||
self.assertIn("- `scripts/report_*` (3 files)", body)
|
||||
self.assertTrue(body.rstrip().endswith("Checked at abc."))
|
||||
|
||||
def test_only_present_kinds(self):
|
||||
body = render_comment([DEAD], head_sha="abc")
|
||||
self.assertNotIn("### Touched", body)
|
||||
|
||||
def test_note_only(self):
|
||||
body = render_comment((), head_sha="abc", note="drafter failed: token expired")
|
||||
self.assertIn("drafter failed: token expired", body)
|
||||
self.assertTrue(body.startswith(STAGE1_MARKER))
|
||||
|
||||
def test_clean(self):
|
||||
self.assertEqual(render_clean("abc"),
|
||||
STAGE1_MARKER + "Nothing flagged as of abc.")
|
||||
|
||||
def test_json_roundtrip(self):
|
||||
d = stage1_json([DEAD, UNCOV], mode="pr", head_sha="abc")
|
||||
back = json.loads(json.dumps(d))
|
||||
self.assertEqual(back["mode"], "pr")
|
||||
self.assertEqual(back["head_sha"], "abc")
|
||||
self.assertEqual(back["flags"][0],
|
||||
{"kind": "dead", "doc": "README.md",
|
||||
"subject": "R/old.R", "detail": "removed"})
|
||||
self.assertIsNone(back["flags"][1]["doc"])
|
||||
|
||||
def test_issue(self):
|
||||
body = render_issue([DEAD, UNG], month="2026-11")
|
||||
self.assertTrue(body.startswith(MONTHLY_MARKER))
|
||||
self.assertIn("2026-11", body)
|
||||
self.assertIn("### Dead", body)
|
||||
self.assertIn("### Unguided", body)
|
||||
self.assertNotIn("Checked at", body)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user