Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Clear cmd docs before generating them #3499

Merged
merged 1 commit into from Jul 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 25 additions & 2 deletions hack/docgen.go
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/spf13/cobra/doc"

commands "github.com/argoproj/argo/cmd/argo/commands"
"github.com/argoproj/argo/cmd/argo/commands"
)

const sectionHeader = `
Expand Down Expand Up @@ -342,10 +342,33 @@ func (c *DocGeneratorContext) generate() string {
return out
}

func removeContents(dir string) error {
d, err := os.Open(dir)
if err != nil {
return err
}
defer func() { _ = d.Close() }()
names, err := d.Readdirnames(-1)
if err != nil {
return err
}
for _, name := range names {
err = os.RemoveAll(filepath.Join(dir, name))
if err != nil {
return err
}
}
return nil
}

func generateDocs() {
cmd := commands.NewCommand()
cmd.DisableAutoGenTag = true
err := doc.GenMarkdownTree(cmd, "docs/cli")
err := removeContents("docs/cli")
if err != nil {
panic(err)
}
err = doc.GenMarkdownTree(cmd, "docs/cli")
if err != nil {
panic(err)
}
Expand Down