Skip to content

Commit

Permalink
cmd/doc: allow -all to apply to individual items
Browse files Browse the repository at this point in the history
It really only matters for types, and the code already worked but was
blocked by a usage check.

Fixes #25595

Change-Id: I823f313b682b37616ea555aee079e2fe39f914c2
Reviewed-on: https://go-review.googlesource.com/c/144357
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
robpike committed Oct 31, 2018
1 parent faafcc6 commit 84b96c2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
20 changes: 20 additions & 0 deletions src/cmd/doc/doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,26 @@ var tests = []test{
`unexportedTypedConstant`, // No unexported constant.
},
},
// Type -all.
{
"type",
[]string{"-all", p, `ExportedType`},
[]string{
`type ExportedType struct {`, // Type definition as source.
`Comment about exported type`, // Include comment afterwards.
`const ConstGroup4 ExportedType = ExportedType\{\}`, // Related constants.
`ExportedTypedConstant ExportedType = iota`,
`Constants tied to ExportedType`,
`func ExportedTypeConstructor\(\) \*ExportedType`,
`Comment about constructor for exported type.`,
`func ReturnExported\(\) ExportedType`,
`func \(ExportedType\) ExportedMethod\(a int\) bool`,
`Comment about exported method.`,
},
[]string{
`unexportedType`,
},
},
// Type T1 dump (alias).
{
"type T1",
Expand Down
5 changes: 1 addition & 4 deletions src/cmd/doc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ func do(writer io.Writer, flagSet *flag.FlagSet, args []string) (err error) {
}

// We have a package.
if showAll {
if symbol != "" {
return fmt.Errorf("-all valid only for package, not symbol: %s", symbol)
}
if showAll && symbol == "" {
pkg.allDoc()
return
}
Expand Down

0 comments on commit 84b96c2

Please sign in to comment.