aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/doc/testdata
diff options
context:
space:
mode:
authorSegev Finer <segev208@gmail.com>2019-03-29 09:35:06 +0000
committerRob Pike <r@golang.org>2019-03-31 23:35:35 +0000
commit4091cf972a37418c847426bd15709cd0128fad81 (patch)
tree3c0520b2fe5669b3c12b822d196f9312f73c23b7 /src/cmd/doc/testdata
parentc1783896049a4e0b4b8834ca02e0914b8d03de79 (diff)
downloadgo-4091cf972a37418c847426bd15709cd0128fad81.tar.xz
cmd/doc: correctly indent pre-formatted blocks
They were previously indented at the same level as the normal text when printing a single symbol or the description of a field. Running "go doc text/template Must": Before: func Must(t *Template, err error) *Template Must is a helper that wraps a call to a function returning (*Template, error) and panics if the error is non-nil. It is intended for use in variable initializations such as var t = template.Must(template.New("name").Parse("text")) After: func Must(t *Template, err error) *Template Must is a helper that wraps a call to a function returning (*Template, error) and panics if the error is non-nil. It is intended for use in variable initializations such as var t = template.Must(template.New("name").Parse("text")) Running "go doc http Request.Header": Before: type Request struct { // Header contains the request header fields either received // by the server or to be sent by the client. // // If a server received a request with header lines, // // Host: example.com // accept-encoding: gzip, deflate // Accept-Language: en-us // fOO: Bar // foo: two // // then // // Header = map[string][]string{ // "Accept-Encoding": {"gzip, deflate"}, // "Accept-Language": {"en-us"}, // "Foo": {"Bar", "two"}, // } ... After: type Request struct { // Header contains the request header fields either received by the server or // to be sent by the client. // // If a server received a request with header lines, // // Host: example.com // accept-encoding: gzip, deflate // Accept-Language: en-us // fOO: Bar // foo: two // // then // // Header = map[string][]string{ // "Accept-Encoding": {"gzip, deflate"}, // "Accept-Language": {"en-us"}, // "Foo": {"Bar", "two"}, // } ... Fixes #29708 Change-Id: Ibe1a6a7a76d6b19c5737ba6e8210e3ad0b88ce16 GitHub-Last-Rev: 439c0fe70a01490cbd9c3613eba3fe45a3ffd9be GitHub-Pull-Request: golang/go#31120 Reviewed-on: https://go-review.googlesource.com/c/go/+/169957 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/cmd/doc/testdata')
-rw-r--r--src/cmd/doc/testdata/pkg.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/cmd/doc/testdata/pkg.go b/src/cmd/doc/testdata/pkg.go
index 88e8c215d0..759b7723a6 100644
--- a/src/cmd/doc/testdata/pkg.go
+++ b/src/cmd/doc/testdata/pkg.go
@@ -207,3 +207,25 @@ const (
Duplicate = iota
duplicate
)
+
+// Comment about exported function with formatting.
+//
+// Example
+//
+// fmt.Println(FormattedDoc())
+//
+// Text after pre-formatted block.
+func ExportedFormattedDoc(a int) bool {
+ return true
+}
+
+type ExportedFormattedType struct {
+ // Comment before exported field with formatting.
+ //
+ // Example
+ //
+ // a.ExportedField = 123
+ //
+ // Text after pre-formatted block.
+ ExportedField int
+}