feat(docsite): check, caption and sync src= blocks in module READMEs (quick-261118-qsd)
- checkSnippets compares top-level src= fences of module READMEs like docs/ pages; the README src= refusal is gone - Sync also rewrites drifted src= fences in modules/<name>/README.md, still all-or-nothing across pages and READMEs - fenceAnnotator captions top-level src= fences on every page - the snippet-readme-src planted violation now plants a drifted README fence instead of the old refusal - utilities.md, README.md and CLAUDE.md describe src= in module READMEs
This commit is contained in:
@@ -504,6 +504,9 @@ func TestNestedFenceChecks(t *testing.T) {
|
||||
"> ```",
|
||||
"",
|
||||
}, "\n")
|
||||
// A module README's src= fences are checked like a docs/ page's: a
|
||||
// matching body passes, drift, nesting and refused targets are
|
||||
// reported at the README's own lines.
|
||||
readme := strings.Join([]string{
|
||||
"# fixture",
|
||||
"",
|
||||
@@ -515,15 +518,42 @@ func TestNestedFenceChecks(t *testing.T) {
|
||||
"x := 1",
|
||||
"```",
|
||||
"",
|
||||
"```go src=modules/fixture/fixture.go",
|
||||
"package fixture",
|
||||
"```go src=modules/fixture/example_test.go#ExampleHello",
|
||||
"fmt.Println(\"hello\")",
|
||||
"// Output: hello",
|
||||
"```",
|
||||
"",
|
||||
"```go src=modules/fixture/example_test.go#ExampleHello",
|
||||
"stale",
|
||||
"```",
|
||||
"",
|
||||
"- item",
|
||||
"",
|
||||
" ```go src=modules/fixture/example_test.go#ExampleHello",
|
||||
" stale",
|
||||
" ```",
|
||||
"",
|
||||
"> [!NOTE]",
|
||||
"> ```go src=modules/fixture/example_test.go#ExampleHello",
|
||||
"> ```",
|
||||
"",
|
||||
"```text src=modules/fixture/.env",
|
||||
"```",
|
||||
"",
|
||||
"```go src=modules/fixture/example_test.go#ExampleSilent",
|
||||
"```",
|
||||
"",
|
||||
}, "\n")
|
||||
exampleTest := "package fixture\n\nimport \"fmt\"\n\n" +
|
||||
"func ExampleHello() {\n\tfmt.Println(\"hello\")\n\t// Output: hello\n}\n\n" +
|
||||
"func ExampleSilent() {\n\tfmt.Println(\"quiet\")\n}\n"
|
||||
const hello = "modules/fixture/example_test.go#ExampleHello"
|
||||
assertProblems(t, checkFixture(t, fixtureCommands, map[string]string{
|
||||
"docs/index.md": page("Acme docs", "index", 0, "Text.\n"),
|
||||
"docs/setup/start.md": page("Start", "setup", 10, body),
|
||||
"modules/fixture/README.md": readme,
|
||||
"go.mod": "module example.com/acme\n\ngo 1.27\n",
|
||||
"docs/index.md": page("Acme docs", "index", 0, "Text.\n"),
|
||||
"docs/setup/start.md": page("Start", "setup", 10, body),
|
||||
"modules/fixture/README.md": readme,
|
||||
"modules/fixture/example_test.go": exampleTest,
|
||||
}), []string{
|
||||
"docs/setup/start.md:10: snippet: go code block has no src= reference",
|
||||
"docs/setup/start.md:16: snippet: go code block has no src= reference",
|
||||
@@ -531,7 +561,11 @@ func TestNestedFenceChecks(t *testing.T) {
|
||||
"docs/setup/start.md:24: snippet: main.go code block has no src= reference",
|
||||
`docs/setup/start.md:34: command: "bogus:nested" is not a summer or application command`,
|
||||
"docs/setup/start.md:37: snippet: config/app.yaml: " + nestedSrcMessage,
|
||||
"modules/fixture/README.md:11: snippet: modules/fixture/fixture.go: " + readmeSrcMessage,
|
||||
"modules/fixture/README.md:16: snippet: body differs from " + hello + " (run: summer docs:sync)",
|
||||
"modules/fixture/README.md:22: snippet: " + hello + ": " + nestedSrcMessage,
|
||||
"modules/fixture/README.md:27: snippet: " + hello + ": " + nestedSrcMessage,
|
||||
"modules/fixture/README.md:30: snippet: modules/fixture/.env: path names a dotfile or .env file",
|
||||
"modules/fixture/README.md:33: snippet: modules/fixture/example_test.go#ExampleSilent: ExampleSilent has no // Output: comment, so go test compiles it but never runs it",
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user