Skip to content

Commit

Permalink
fix: docs
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Sep 12, 2021
1 parent 3dbbc9b commit 3a079d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ serve-docs:

.PHONY: build-api-docs
build-api-docs:
go run main.go docs api api/v1/*.go --output-file docs/api.md
go run main.go docs api/v1/*.go --output-file docs/api.md

.PHONY: build-docs
build-docs:
Expand Down
11 changes: 6 additions & 5 deletions cmd/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ import (
"github.com/spf13/cobra"
)

var APIDocs = &cobra.Command{
Use: "api",
Short: "Generate docs ",
Args: cobra.MinimumNArgs(0),
var Docs = &cobra.Command{
Use: "docs",
Short: "Generate docs ",
Hidden: true,
Args: cobra.MinimumNArgs(0),
Run: func(cmd *cobra.Command, args []string) {
printAPIDocs(args)
},
Expand All @@ -44,7 +45,7 @@ var APIDocs = &cobra.Command{
var out string

func init() {
APIDocs.Flags().StringVar(&out, "output-file", "API.md", "")
Docs.Flags().StringVar(&out, "output-file", "docs/API.md", "")
}

var (
Expand Down
21 changes: 1 addition & 20 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/flanksource/canary-checker/pkg/runner"
"github.com/flanksource/commons/logger"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
"github.com/spf13/pflag"
)

Expand Down Expand Up @@ -43,24 +42,6 @@ func init() {
logger.BindFlags(Root.PersistentFlags())

Root.PersistentFlags().BoolVar(&exposeEnv, "expose-env", false, "Expose environment variables for use in all templates. Note this has serious security implications with untrusted canaries")
docs := &cobra.Command{
Use: "docs",
Short: "generate documentation",
}

docs.AddCommand(&cobra.Command{
Use: "cli [PATH]",
Short: "generate CLI documentation",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
err := doc.GenMarkdownTree(Root, args[0])
if err != nil {
logger.Fatalf("error creating docs", err)
}
},
})

Root.AddCommand(APIDocs)
Root.AddCommand(docs)
Root.AddCommand(Docs)
Root.AddCommand(Run, Serve, Operator)
}

0 comments on commit 3a079d2

Please sign in to comment.