aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/doc/testdata/pkg.go
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2016-08-03 00:31:17 -0700
committerJoe Tsai <thebrokentoaster@gmail.com>2016-10-05 00:12:35 +0000
commit84743c348b0a4a7ed1ea3d7122feb757ccc7ebae (patch)
tree3b1841f3d247eebf8fdbfba3bcbaa4af3372e20a /src/cmd/doc/testdata/pkg.go
parent44009a24138b6c7b5fd5b4be113db44fdfd1678e (diff)
downloadgo-84743c348b0a4a7ed1ea3d7122feb757ccc7ebae.tar.xz
cmd/doc: ensure summaries truly are only one line
The documentation for doc says: > Doc prints the documentation comments associated with the item identified by its > arguments (a package, const, func, type, var, or method) followed by a one-line > summary of each of the first-level items "under" that item (package-level > declarations for a package, methods for a type, etc.). Certain variables (and constants, functions, and types) have value specifications that are multiple lines long. Prior to this change, doc would print out all of the lines necessary to display the value. This is inconsistent with the documented behavior, which guarantees a one-line summary for all first-level items. We fix this here by writing a general oneLineNode method that always returns a one-line summary (guaranteed!) of any input node. Packages like image/color/palette and unicode now become much more readable since large slices are now a single line. $ go doc image/color/palette <<< // Before: var Plan9 = []color.Color{ color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x44, 0xff}, color.RGBA{0x00, 0x00, 0x88, 0xff}, ... // Hundreds of more lines! } var WebSafe = []color.Color{ color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x33, 0xff}, color.RGBA{0x00, 0x00, 0x66, 0xff}, ... // Hundreds of more lines! } // After: var Plan9 = []color.Color{ ... } var WebSafe = []color.Color{ ... } >>> In order to test this, I ran `go doc` and `go doc -u` on all of the standard library packages and diff'd the output with and without the change to ensure that all differences were intended. Fixes #13072 Change-Id: Ida10b7796b7e4e174a929b55c60813a9eb7158fe Reviewed-on: https://go-review.googlesource.com/25420 Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/cmd/doc/testdata/pkg.go')
-rw-r--r--src/cmd/doc/testdata/pkg.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/cmd/doc/testdata/pkg.go b/src/cmd/doc/testdata/pkg.go
index fb941cde7a..924daa171b 100644
--- a/src/cmd/doc/testdata/pkg.go
+++ b/src/cmd/doc/testdata/pkg.go
@@ -127,6 +127,36 @@ const Casematch = 2
func ReturnUnexported() unexportedType { return 0 }
func ReturnExported() ExportedType { return ExportedType{} }
+const MultiLineConst = `
+ MultiLineString1
+ MultiLineString2
+ MultiLineString3
+`
+
+func MultiLineFunc(x interface {
+ MultiLineMethod1() int
+ MultiLineMethod2() int
+ MultiLineMethod3() int
+}) (r struct {
+ MultiLineField1 int
+ MultiLineField2 int
+ MultiLineField3 int
+}) {
+ return r
+}
+
+var MultiLineVar = map[struct {
+ MultiLineField1 string
+ MultiLineField2 uint64
+}]struct {
+ MultiLineField3 error
+ MultiLineField2 error
+}{
+ {"FieldVal1", 1}: {},
+ {"FieldVal2", 2}: {},
+ {"FieldVal3", 3}: {},
+}
+
const (
_, _ uint64 = 2 * iota, 1 << iota
constLeft1, constRight1