Repository navigation
refactor(scripts): drive every generated region through one registry - #507
Merged
Merged
Conversation
gen-docs.ts and gen-action-docs.ts each drove their generated regions by hand: a lookup in a path-to-regions record, a throw for an unregistered path, a call to regenerateRegions, a read/write loop in main, and a log line. lib/region-driver.ts is now the one driver both call. A registry maps each path to its regions and the two whole-file rules no region's placement can carry: a shape rule judged on the file as read, before any region, and a rendered rule judged over the regenerated text. gen-docs's two page rules become registry data: the coverage page's title-and-tail rule is its shape, and the token-form label rule is every other page's rendered rule. The coverage page joins the docs registry, so generated.ts derives the docs rows from one Object.keys(). The four wrappers renderPage, renderCoverageFile, regenerateText, and regenerateAll go; tests call the driver with the registry. Every generated page regenerates byte-identically. The one message change is the unregistered-path refusal, which no longer carries a "gen-docs: " prefix; no user reaches it, since paths come from the registry keys.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The refactor preserves existing validation behavior while removing duplicated generation loops.
Review effort: Balanced
Findings: None
What changed in this PR
Centralizes generated-region processing in a shared registry-driven driver.
Changes:
- Adds shared file regeneration and validation hooks.
- Migrates documentation generators to unified registries.
- Updates generated-output discovery and tests.
| File | Description |
|---|---|
.github/scripts/lib/region-driver.ts |
Adds the shared registry and regeneration loop. |
.github/scripts/gen-docs.ts |
Migrates documentation pages to PAGES. |
.github/scripts/gen-action-docs.ts |
Migrates action documentation to FILES. |
.github/scripts/generated.ts |
Derives generated paths from both registries. |
test/scripts/gen-docs.test.ts |
Updates documentation generator tests. |
test/scripts/gen-action-docs.test.ts |
Updates action documentation generator tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
How
{ regions, shape?, rendered? }; the driver checksshapeon the text as read, regenerates the regions, then checksrenderedon the result.shape, the token-form label rule is every other page'srendered.generated.tsderives the docs rows from oneObject.keys().renderPage,renderCoverageFile,regenerateText,regenerateAll; tests call the driver with the registry.Proof
generated.tsrun,git statusclean for every generated path.regenerateRegionscalls in gen-docs.ts 4 to 0, in gen-action-docs.ts 3 to 0, in the driver 3.Technical details
shaperuns before the regions so a mis-titled coverage page reports its title, not its region's placement, which the existing coverage test pins;renderedruns after because fresh markers render the token-form definition the rule counts.lib/generated-regions.ts.git diff --numstat): region-driver.ts +54, gen-docs.ts +40/-53, gen-action-docs.ts +72/-97, generated.ts +4/-4, gen-docs.test.ts +11/-6, gen-action-docs.test.ts +9/-9.