feat(docsite): require src= on Go code blocks of module READMEs (quick-261118-qsd)

This commit is contained in:
Jakub Zych
2026-11-18 20:18:38 +01:00
parent 1e56d750ef
commit 8c03cc3621
11 changed files with 43 additions and 40 deletions

View File

@@ -16,7 +16,7 @@ import (
)
// themeTree is a two-section fixture: the index (two H2 headings, a
// callout), two setup pages and one API page with a Go fence.
// callout), two setup pages and one API page with a src= Go fence.
func themeTree(t *testing.T) string {
t.Helper()
return writeTree(t, map[string]string{
@@ -27,8 +27,11 @@ func themeTree(t *testing.T) string {
"docs/setup/start.md": page("Start", "setup", 10, "## Only heading\n\nText.\n"),
"docs/setup/second.md": page("Second", "setup", 20, "Text.\n"),
"modules/alpha/alpha.go": "package alpha\n",
"modules/alpha/alpha_test.go": "package alpha\n\nimport \"testing\"\n\n" +
"func TestName(t *testing.T) {\n\tif name() != \"x\" {\n\t\tt.Fatal(name())\n\t}\n}\n\n" +
"func name() string {\n\treturn \"x\" // done\n}\n",
"modules/alpha/README.md": "# alpha\n\nAlpha does one thing well.\n\n## Usage\n\n" +
"```go\nfunc main() {\n\treturn \"x\" // done\n}\n```\n\n```yaml\nkey: true\n```\n",
"```go src=modules/alpha/alpha_test.go#name\nfunc name() string {\n\treturn \"x\" // done\n}\n```\n\n```yaml\nkey: true\n```\n",
})
}