Skip to content

Commit

Permalink
- fallback to inline comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide Nabais committed Sep 11, 2023
1 parent 0382c8e commit 78a63b5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions comment_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package jsonschema

import (
"fmt"
"io/fs"
gopath "path"
"path/filepath"
"strings"

"go/ast"
"go/doc"
"go/parser"
"go/token"
"io/fs"
gopath "path"
"path/filepath"
"strings"
)

// ExtractGoComments will read all the go files contained in the provided path,
Expand Down Expand Up @@ -69,6 +68,9 @@ func ExtractGoComments(base, path string, commentMap map[string]string) error {
}
case *ast.Field:
txt := x.Doc.Text()
if txt == "" {
txt = x.Comment.Text()
}
if typ != "" && txt != "" {
for _, n := range x.Names {
if ast.IsExported(n.String()) {
Expand Down

0 comments on commit 78a63b5

Please sign in to comment.