Skip to content

Commit

Permalink
Extract Go comments from "main" package too
Browse files Browse the repository at this point in the history
ExtractGoComments() uses the fully-qualified package path when creating
keys in our CommentMap, but we perform lookups in that map using keys
constructed using (reflect.Type)PkgPath(). The latter method always
returns "main" for types defined in the "main" package, rather than a
fully-qualified package path, so those lookups fail. The result is that
we never incorporate comments into a schema for types defined in "main".

Update ExtractGoComments() to handle the special case of "main".
  • Loading branch information
vzxv committed Feb 6, 2024
1 parent 9b6bb6e commit 801c3aa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion comment_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ func ExtractGoComments(base, path string, commentMap map[string]string) error {
if err != nil {
return err
}
for _, v := range d {
for pkg, v := range d {
// paths may have multiple packages, like for tests
k := gopath.Join(base, path)
if p == "main" {
k = pkg
}
dict[k] = append(dict[k], v)
}
}
Expand Down

0 comments on commit 801c3aa

Please sign in to comment.