From 052847f4edfdb02472380c3659a334fc23e35d05 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Sat, 18 Jun 2016 06:42:46 -0700 Subject: [PATCH] go2idl: Track doc.go file-comments Previously we just tracked comments on the 'package' declaration. Treat all file comments as one comment-block, for simplicity. Can be revisited if needed. --- cmd/libs/go2idl/parser/parse.go | 6 +++++- cmd/libs/go2idl/types/types.go | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/libs/go2idl/parser/parse.go b/cmd/libs/go2idl/parser/parse.go index 3d264a94bb5..2bf2f806217 100644 --- a/cmd/libs/go2idl/parser/parse.go +++ b/cmd/libs/go2idl/parser/parse.go @@ -370,8 +370,12 @@ func (b *Builder) FindTypes() (types.Universe, error) { for _, f := range b.parsed[pkgPath] { if strings.HasSuffix(f.name, "/doc.go") { + tp := u.Package(pkgPath) + for i := range f.file.Comments { + tp.Comments = append(tp.Comments, splitLines(f.file.Comments[i].Text())...) + } if f.file.Doc != nil { - u.Package(pkgPath).DocComments = splitLines(f.file.Doc.Text()) + tp.DocComments = splitLines(f.file.Doc.Text()) } } } diff --git a/cmd/libs/go2idl/types/types.go b/cmd/libs/go2idl/types/types.go index d34450868c4..b6e9391d716 100644 --- a/cmd/libs/go2idl/types/types.go +++ b/cmd/libs/go2idl/types/types.go @@ -89,9 +89,12 @@ type Package struct { // 'package x' line. Name string - // Comments from doc.go file. + // DocComments from doc.go, if any. DocComments []string + // Comments from doc.go, if any. + Comments []string + // Types within this package, indexed by their name (*not* including // package name). Types map[string]*Type