From 259efbfb887da19ab8e9f976a4e5cefdf4d89c94 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 15 Sep 2023 15:01:33 -0400 Subject: [PATCH] Added all needed pieces to build feature. --- cmd/provenanced/cmd/docgen.go | 47 ++++++++++++++++++++++++++++++ cmd/provenanced/cmd/docgen_test.go | 1 + cmd/provenanced/cmd/root.go | 1 + go.mod | 2 ++ go.sum | 2 ++ 5 files changed, 53 insertions(+) create mode 100644 cmd/provenanced/cmd/docgen.go create mode 100644 cmd/provenanced/cmd/docgen_test.go diff --git a/cmd/provenanced/cmd/docgen.go b/cmd/provenanced/cmd/docgen.go new file mode 100644 index 0000000000..c08bb7de03 --- /dev/null +++ b/cmd/provenanced/cmd/docgen.go @@ -0,0 +1,47 @@ +package cmd + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + "github.com/spf13/cobra/doc" +) + +var docGenCmdStart = fmt.Sprintf("%s docgen", version.AppName) + +const ( + FlagMarkdown = "markdown" + FlagYaml = "yaml" + FlagRest = "rest" + FlagManpage = "manpage" +) + +func GetDocGenCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "docgen", + Short: "Generates cli documentation for the Provenance Blockchain.", + Long: "", + Example: fmt.Sprintf("%s '/tmp' --yaml --markdown", docGenCmdStart), + Hidden: true, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + markdown, err := cmd.Flags().GetBool(FlagMarkdown) + if err != nil { + return err + } + if markdown { + doc.GenMarkdownTree(cmd.Root(), args[0]) + } + + return nil + }, + } + + cmd.Flags().Bool(FlagMarkdown, false, "Generate documentation in the format of markdown pages.") + cmd.Flags().Bool(FlagYaml, false, "Generate documentation in the format of yaml.") + cmd.Flags().Bool(FlagRest, false, "Generate documentation in the format of rest.") + cmd.Flags().Bool(FlagManpage, false, "Generate documentation in the format of manpages.") + + return cmd +} diff --git a/cmd/provenanced/cmd/docgen_test.go b/cmd/provenanced/cmd/docgen_test.go new file mode 100644 index 0000000000..fedae39ac2 --- /dev/null +++ b/cmd/provenanced/cmd/docgen_test.go @@ -0,0 +1 @@ +package cmd_test diff --git a/cmd/provenanced/cmd/root.go b/cmd/provenanced/cmd/root.go index d85cf9ad07..da030bcbdb 100644 --- a/cmd/provenanced/cmd/root.go +++ b/cmd/provenanced/cmd/root.go @@ -154,6 +154,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { AddMetaAddressCmd(), snapshot.Cmd(newApp), GetPreUpgradeCmd(), + GetDocGenCmd(), ) fixDebugPubkeyRawTypeFlag(rootCmd) diff --git a/go.mod b/go.mod index f767d38067..7c14fe4152 100644 --- a/go.mod +++ b/go.mod @@ -68,6 +68,7 @@ require ( github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/iavl v0.19.6 // indirect github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -144,6 +145,7 @@ require ( github.com/prometheus/procfs v0.9.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rs/cors v1.8.2 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect diff --git a/go.sum b/go.sum index 0e0347725c..4c11921fb2 100644 --- a/go.sum +++ b/go.sum @@ -383,6 +383,7 @@ github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKy github.com/cosmos/ledger-cosmos-go v0.12.2/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creachadair/taskgroup v0.3.2 h1:zlfutDS+5XG40AOxcHDSThxKzns8Tnr9jnr6VqkYlkM= github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+kq+TDlRJQ0Wbk= @@ -1032,6 +1033,7 @@ github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=