1
0

add header to the generated output

This commit is contained in:
Arpad Ryszka 2025-08-26 21:02:10 +02:00
parent e2747666f9
commit b092c9cb4c
2 changed files with 10 additions and 3 deletions

View File

@ -21,6 +21,12 @@ import (
"strings"
)
const header = `/*
Generated by https://code.squareroundforest.org/arpio/docreflect
*/
`
type options struct {
wd string
goroot string
@ -600,6 +606,7 @@ func format(w io.Writer, pname string, docs map[string]string) error {
_, err = fmt.Fprintln(w, a...)
}
println(header)
printf("package %s\n", pname)
println("import \"code.squareroundforest.org/arpio/docreflect\"")
println("func init() {")

View File

@ -404,12 +404,12 @@ func TestFormat(t *testing.T) {
}
o := b.String()
if o != `package testpackage
if !strings.Contains(o, `package testpackage
import "code.squareroundforest.org/arpio/docreflect"
func init() {
docreflect.Register("baz", "qux")
docreflect.Register("foo", "bar")
}` {
t.Fatal()
}`) {
t.Fatal(o)
}
}