gopls/doc: fix section rewriting
Sections were being iteratively replaced in the original doc, rather
than an incrementally updated doc.
Change-Id: Ie49058ecc109e3f99babe24f02ee9c742915cd8d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/258567
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
diff --git a/gopls/doc/generate.go b/gopls/doc/generate.go
index 06757d5..7e0afeb 100644
--- a/gopls/doc/generate.go
+++ b/gopls/doc/generate.go
@@ -63,7 +63,7 @@
}
func rewriteSettings(doc []byte, api *source.APIJSON) ([]byte, error) {
- var result []byte
+ result := doc
for category, opts := range api.Options {
section := bytes.NewBuffer(nil)
for _, opt := range opts {
@@ -77,7 +77,7 @@
fmt.Fprintf(section, "### **%v** *%v*\n%v%v\n\nDefault: `%v`.\n", opt.Name, opt.Type, opt.Doc, enumValues, opt.Default)
}
var err error
- result, err = replaceSection(doc, category, section.Bytes())
+ result, err = replaceSection(result, category, section.Bytes())
if err != nil {
return nil, err
}