diff --git a/cmd/summer/commands_documented_test.go b/cmd/summer/commands_documented_test.go index 5518fdb0..23c94580 100644 --- a/cmd/summer/commands_documented_test.go +++ b/cmd/summer/commands_documented_test.go @@ -31,10 +31,11 @@ func applicationCommands() []bonfire.Command { } // TestCommandsDocumented is the framework's documentation coverage gate -// (D-17): every framework command has a description, long help, examples -// and described arguments and options, and the test fails on any gap. +// (D-17): every command of the summer tool (its delegates included) and of +// an application binary has a description, long help, examples and +// described arguments and options, and the test fails on any gap. func TestCommandsDocumented(t *testing.T) { - commands := applicationCommands() + commands := append(toolCommands(), applicationCommands()...) for _, problem := range bonfire.CheckDocs(commands) { t.Error(problem) } diff --git a/cmd/summer/docs.go b/cmd/summer/docs.go index 3fb47768..77dd0be8 100644 --- a/cmd/summer/docs.go +++ b/cmd/summer/docs.go @@ -2,7 +2,7 @@ package main import ( "context" - "errors" + "fmt" "os" "os/signal" "sync" @@ -24,6 +24,17 @@ func docsBuildCommand() bonfire.Command { return bonfire.Command{ Name: "docs:build", Description: "Build the documentation site", + Long: `Checks every page under docs/ and every module README, then writes the static +site to site/ (or --out): HTML pages, a raw .md copy of each page, llms.txt, +llms-full.txt and the search index. It fails, writing nothing, when a page +names an identifier that does not exist, links to a missing page or anchor, +shows a command neither summer nor an application binary has, or has a src= +code block that differs from its source. --check only reports. Run it from +the framework root.`, + Examples: []bonfire.Example{ + {Command: "docs:build --check", Description: "Check the docs and write nothing"}, + {Command: "docs:build --base-url /docs/ --out /tmp/site", Description: "Build the site for /docs/ into /tmp/site"}, + }, Flags: []bonfire.Flag{ {Name: "root", Description: "Repository root; src= paths and modules/ resolve against it", Default: "."}, {Name: "src", Description: "Docs source directory (default /docs)"}, @@ -63,6 +74,14 @@ func docsSyncCommand() bonfire.Command { return bonfire.Command{ Name: "docs:sync", Description: "Rewrite src= code blocks from their sources", + Long: `Rewrites every code block that has a src= reference with the current text of +its source (a file, or a function, test or example in it), so the docs show +what the code does. Run it after changing code a page shows; docs:build +--check fails until you do.`, + Examples: []bonfire.Example{ + {Command: "docs:sync", Description: "Refresh every src= block of the docs in this repository"}, + {Command: "docs:sync --root ../summercms.go", Description: "Refresh the docs of another checkout"}, + }, Flags: []bonfire.Flag{ {Name: "root", Description: "Repository root; src= paths resolve against it", Default: "."}, {Name: "src", Description: "Docs source directory (default /docs)"}, @@ -174,11 +193,11 @@ func docsCommands() *docsite.Commands { } // reportDocsProblems prints one line per problem and a summary, and returns -// a short error so the binary exits 1. +// a Reported error, so the binary exits 1 without repeating the list. func reportDocsProblems(out bonfire.Output, cmd string, problems []docsite.Problem) error { for _, p := range problems { out.Printf("%s\n", p) } out.Printf("%s: %d problems, nothing written\n", cmd, len(problems)) - return errors.New(cmd + " failed") + return bonfire.Reported(fmt.Errorf("%s failed", cmd)) } diff --git a/cmd/summer/main.go b/cmd/summer/main.go index b40b2517..472013f6 100644 --- a/cmd/summer/main.go +++ b/cmd/summer/main.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "context" "fmt" "os" @@ -54,12 +55,39 @@ func buildCommand() bonfire.Command { return bonfire.Command{ Name: "build", Description: "Generate plugin imports and build the app binary", + Long: `Reads summer.yaml of the application in the current directory (or the nearest +one above it), generates plugins.gen.go and main.go from it, and runs go build +into bin/, passing the manifest's build.tags as -tags. On a terminal a +spinner runs while go build works. It ends with "Built bin/ in