Skip to content

Commit b57a1d3

Browse files
committed
Directives are in comment text instead of groups
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]>
1 parent 787b9ce commit b57a1d3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

common/metrics/gendoc/options.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ func FileOptions(f *ast.File) ([]interface{}, error) {
4242
var options []interface{}
4343
var errors []error
4444

45-
// If the file contains gendoc:ignore, ignore the file
45+
// If the file contains a gendoc:ignore directive, ignore the file
4646
for _, c := range f.Comments {
47-
if strings.Contains(c.Text(), "gendoc:ignore") {
48-
return nil, nil
47+
for _, c := range c.List {
48+
if strings.HasPrefix(c.Text, "//gendoc:ignore") {
49+
return nil, nil
50+
}
4951
}
5052
}
5153

common/metrics/gendoc/testdata/ignored.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import "github.com/hyperledger/fabric/common/metrics"
1010

1111
//gendoc:ignore
1212

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

1515
var (
1616
Ignored = metrics.CounterOpts{

0 commit comments

Comments
 (0)