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

View File

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