Skip to content

Commit

Permalink
Fixes gendoc (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Lüders authored May 18, 2021
1 parent b4c4f14 commit c36bfb9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/gendoc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ import (
)

var (
expPkg string
mdfname string
inPath string
outPath string
mdf *os.File
randSource = rand.NewSource(time.Now().UnixNano())
reGather = regexp.MustCompile(`^(Gather)(.*)`)
reExample = regexp.MustCompile(`^(Example)(.*)`)
)

func init() {
flag.StringVar(&expPkg, "gatherpkg", "gather", "Package where to find Gather methods")
flag.StringVar(&mdfname, "out", "gathered-data.md", "File to which MD doc will be generated")
flag.StringVar(&inPath, "in", "gatherers", "Package where to find Gather methods")
flag.StringVar(&outPath, "out", "gathered-data.md", "File to which MD doc will be generated")
}

type DocBlock struct {
Expand All @@ -40,7 +40,7 @@ type DocBlock struct {
func main() {
flag.Parse()
var err error
mdf, err = os.Create(mdfname)
mdf, err = os.Create(outPath)
if err != nil {
fmt.Println(err)
return
Expand All @@ -63,7 +63,7 @@ func main() {
keys = append(keys, k)
}
sort.Strings(keys)
_, err = mdf.WriteString("This document is auto-generated by `make gen-doc`\n\n")
_, err = mdf.WriteString("This document is auto-generated by `make docs`\n\n")
if err != nil {
fmt.Print(err)
}
Expand Down Expand Up @@ -120,7 +120,7 @@ func walkDir(cleanRoot string, md map[string]*DocBlock) error {
}

for astPackageName, astPackage := range d {
if astPackageName != expPkg && expPath == "" {
if astPackageName != inPath && expPath == "" {
continue
}
if expPath == "" && len(astPackage.Files) > 0 {
Expand Down

0 comments on commit c36bfb9

Please sign in to comment.