]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/doc: allow -all to apply to individual items
authorRob Pike <r@golang.org>
Wed, 24 Oct 2018 02:33:14 +0000 (13:33 +1100)
committerRob Pike <r@golang.org>
Wed, 31 Oct 2018 00:33:31 +0000 (00:33 +0000)
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 <iant@golang.org>
src/cmd/doc/doc_test.go
src/cmd/doc/main.go

index f8c52b1988baa224f4aa44a1227e7eea0124a0c5..0761c6ddb3b0fe73513c6e9e2246dd0ef5c15253 100644 (file)
@@ -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",
index 614f19438c8cd41316e997a68679bd45792be270..ec15ec5826149abb48b690658fb3258d9288eff3 100644 (file)
@@ -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
                }