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.
This commit is contained in:
Tim Hockin 2016-06-18 06:42:46 -07:00
parent 4a00a0fd6d
commit 052847f4ed
2 changed files with 9 additions and 2 deletions

View File

@ -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())
}
}
}

View File

@ -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