]> Cypherpunks repositories - gostls13.git/commitdiff
godoc: don't print package clause in -src command-line mode with filtering
authorRobert Griesemer <gri@golang.org>
Tue, 30 Mar 2010 18:19:58 +0000 (11:19 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 30 Mar 2010 18:19:58 +0000 (11:19 -0700)
R=rsc
CC=golang-dev
https://golang.org/cl/844041

src/cmd/godoc/main.go

index 0ab1898f6136453cdef8c0296c498b22c89eed10..0ede0dcc949f509a34052812aefd2161100db423 100644 (file)
@@ -355,7 +355,18 @@ func main() {
                switch {
                case info.PAst != nil:
                        ast.FilterFile(info.PAst, filter)
-                       info.PAst.Doc = nil // don't show package comment in this case
+                       // Special case: Don't use templates for printing
+                       // so we only get the filtered declarations without
+                       // package clause or extra whitespace.
+                       for i, d := range info.PAst.Decls {
+                               if i > 0 {
+                                       fmt.Println()
+                               }
+                               writeAny(os.Stdout, d, *html)
+                               fmt.Println()
+                       }
+                       return
+
                case info.PDoc != nil:
                        info.PDoc.Filter(filter)
                }