cmd/doc: print Go syntax when printing struct.field docs

Fixes #20928

Change-Id: I7f7aafb8ff4b5deb50c286a9ae81c34ee85e56a9
Reviewed-on: https://go-review.googlesource.com/47730
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Brad Fitzpatrick 2017-07-06 20:02:26 +00:00
parent d1340ee2e9
commit 39ed6b14b4
3 changed files with 38 additions and 18 deletions

View file

@ -89,7 +89,7 @@ var tests = []test{
`VarFive = 5`, // From block starting with unexported variable.
`type unexportedType`, // No unexported type.
`unexportedTypedConstant`, // No unexported typed constant.
`Field`, // No fields.
`\bField`, // No fields.
`Method`, // No methods.
`someArgument[5-8]`, // No truncated arguments.
`type T1 T2`, // Type alias does not display as type declaration.
@ -395,14 +395,16 @@ var tests = []test{
"field",
[]string{p, `ExportedType.ExportedField`},
[]string{
`type ExportedType struct`,
`ExportedField int`,
`Comment before exported field.`,
`Comment on line with exported field.`,
`other fields elided`,
},
nil,
},
// Field with -u.
// Field with -u.
{
"method with -u",
[]string{"-u", p, `ExportedType.unexportedField`},
@ -413,6 +415,14 @@ var tests = []test{
nil,
},
// Field of struct with only one field.
{
"single-field struct",
[]string{p, `ExportedStructOneField.OnlyField`},
[]string{`the only field`},
[]string{`other fields elided`},
},
// Case matching off.
{
"case matching off",