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,71 @@
|
||||
"""Stage 1 output: JSON, the PR comment and the monthly issue body."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterable
|
||||
|
||||
from docs_review.flags import Flag
|
||||
|
||||
STAGE1_MARKER = "<!-- docs-review:stage1 -->"
|
||||
MONTHLY_MARKER = "<!-- docs-review:monthly -->"
|
||||
|
||||
_SECTIONS = (
|
||||
("touched", "Touched",
|
||||
"These documents mention code or a name this PR changes."),
|
||||
("dead", "Dead",
|
||||
"These documents mention a path this PR removes or renames."),
|
||||
("uncovered", "Uncovered",
|
||||
"These source files are not mentioned in any document."),
|
||||
("stale_generated", "Stale generated",
|
||||
"These generated documents depend on an input that changed."),
|
||||
("unguided", "Unguided",
|
||||
"These documents are not described in the documentation guide."),
|
||||
)
|
||||
|
||||
|
||||
def stage1_json(flags: Iterable[Flag], *, mode: str, head_sha: str) -> dict:
|
||||
return {
|
||||
"mode": mode,
|
||||
"head_sha": head_sha,
|
||||
"flags": [
|
||||
{"kind": f.kind, "doc": f.doc, "subject": f.subject, "detail": f.detail}
|
||||
for f in flags
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def _line(f: Flag) -> str:
|
||||
if f.doc is None:
|
||||
return f"- `{f.subject}` ({f.detail})"
|
||||
return f"- `{f.doc}`: `{f.subject}` ({f.detail})"
|
||||
|
||||
|
||||
def render_sections(flags: Iterable[Flag]) -> list[str]:
|
||||
flags = tuple(flags)
|
||||
out: list[str] = []
|
||||
for kind, title, blurb in _SECTIONS:
|
||||
members = [f for f in flags if f.kind == kind]
|
||||
if members:
|
||||
out.append("\n".join([f"### {title}", blurb, ""] + [_line(f) for f in members]))
|
||||
return out
|
||||
|
||||
|
||||
def render_comment(
|
||||
flags: Iterable[Flag], *, head_sha: str, note: str | None = None
|
||||
) -> str | None:
|
||||
parts = render_sections(flags)
|
||||
if not parts and not note:
|
||||
return None
|
||||
if note:
|
||||
parts.append(note)
|
||||
parts.append(f"Checked at {head_sha}.")
|
||||
return STAGE1_MARKER + "\n" + "\n\n".join(parts) + "\n"
|
||||
|
||||
|
||||
def render_clean(head_sha: str) -> str:
|
||||
return STAGE1_MARKER + f"Nothing flagged as of {head_sha}."
|
||||
|
||||
|
||||
def render_issue(flags: Iterable[Flag], *, month: str) -> str:
|
||||
parts = render_sections(flags) or [f"Nothing flagged as of {month}."]
|
||||
return MONTHLY_MARKER + "\n" + f"Documents to review for {month}.\n\n" + "\n\n".join(parts) + "\n"
|
||||
Reference in new issue
Block a user