feat(11.1-01): verify src= code blocks and add summer docs:sync
- src= fences name a file, a Go declaration or Example body, or a docs:start region - confinement: relative clean paths inside the root, no dotfiles or .env, no nested go.mod modules, Examples need // Output:, test regions must run - a drifted or missing snippet is a problem, so docs:build writes nothing - docs:sync rewrites drifted fence bodies in place - fences render in figure.code with a source caption; .md fences keep only the language - bonfire ExampleCall is the first verified example, shown in setup/installation
This commit is contained in:
27
modules/bonfire/example_test.go
Normal file
27
modules/bonfire/example_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package bonfire_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/bonfire"
|
||||
)
|
||||
|
||||
func ExampleCall() {
|
||||
commands := []bonfire.Command{{
|
||||
Name: "acme:greet",
|
||||
Description: "Greet someone by name",
|
||||
Args: []bonfire.Arg{{Name: "name", Required: true}},
|
||||
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||
name, _ := in.Argument("name")
|
||||
out.Printf("Hello, %s\n", name)
|
||||
return nil
|
||||
},
|
||||
}}
|
||||
|
||||
if err := bonfire.Call(context.Background(), commands, "acme:greet", []string{"blog"}, os.Stdout); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
// Output: Hello, blog
|
||||
}
|
||||
Reference in New Issue
Block a user