Skip to content

Commit

Permalink
Directives are in comment text instead of groups
Browse files Browse the repository at this point in the history
It's been a long time coming but the ast package is now treating
directives as a special case and removing them from comment groups.

See golang/go#37974

Signed-off-by: Matthew Sykes <[email protected]>
  • Loading branch information
sykesm authored and Jason Yellick committed Feb 15, 2021
1 parent a1b4d2d commit d539244
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions common/metrics/gendoc/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ func FileOptions(f *ast.File) ([]interface{}, error) {
var options []interface{}
var errors []error

// If the file contains gendoc:ignore, ignore the file
// If the file contains a gendoc:ignore directive, ignore the file
for _, c := range f.Comments {
if strings.Contains(c.Text(), "gendoc:ignore") {
return nil, nil
for _, c := range c.List {
if strings.HasPrefix(c.Text, "//gendoc:ignore") {
return nil, nil
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/metrics/gendoc/testdata/ignored.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "github.com/hyperledger/fabric/common/metrics"

//gendoc:ignore

// This should be ignored by doc generation because of the gendoc:ignore statement above.
// This should be ignored by doc generation because of the directive above.

var (
Ignored = metrics.CounterOpts{
Expand Down

0 comments on commit d539244

Please sign in to comment.