Skip to content

Commit da6c3a8

Browse files
authored
Merge pull request #29 from axone-protocol/feat/docs
Feat/docs
2 parents 07152e0 + 8dc7a6a commit da6c3a8

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

cmd/doc.go

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package cmd
2+
3+
import (
4+
"os"
5+
6+
"github.com/spf13/cobra"
7+
"github.com/spf13/cobra/doc"
8+
)
9+
10+
const (
11+
flagMkDirs = "mk-dirs"
12+
)
13+
14+
var metaDocsCmd = &cobra.Command{
15+
Use: "docs [dir]",
16+
Short: "Generate documentation to a directory",
17+
Args: cobra.ExactArgs(1),
18+
RunE: func(cmd *cobra.Command, args []string) error {
19+
targetPath := args[0]
20+
21+
shouldMkDirs, err := cmd.Flags().GetBool(flagMkDirs)
22+
if err != nil {
23+
return err
24+
}
25+
if shouldMkDirs {
26+
if err := mkDirs(targetPath); err != nil {
27+
return err
28+
}
29+
}
30+
31+
rootCmd.DisableAutoGenTag = true
32+
33+
err = doc.GenMarkdownTree(rootCmd, targetPath)
34+
if err != nil {
35+
return err
36+
}
37+
38+
return nil
39+
},
40+
}
41+
42+
func mkDirs(dir string) error {
43+
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
44+
return err
45+
}
46+
47+
return nil
48+
}
49+
50+
func init() {
51+
metaCmd.AddCommand(metaDocsCmd)
52+
metaDocsCmd.Flags().Bool(flagMkDirs, false, "create directories if they do not exist")
53+
}

cmd/meta.go

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package cmd
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
var metaCmd = &cobra.Command{
8+
Use: "meta",
9+
Short: "Meta commands for the tool",
10+
}
11+
12+
func init() {
13+
rootCmd.AddCommand(metaCmd)
14+
}

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ require (
5353
github.com/cosmos/iavl v1.2.2 // indirect
5454
github.com/cosmos/ics23/go v0.11.0 // indirect
5555
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
56+
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
5657
github.com/dailyburn/bigquery v0.0.0-20171116202005-b6f18972580e // indirect
5758
github.com/danieljoos/wincred v1.1.2 // indirect
5859
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
@@ -144,6 +145,7 @@ require (
144145
github.com/rogpeppe/go-internal v1.12.0 // indirect
145146
github.com/rs/cors v1.11.1 // indirect
146147
github.com/rs/zerolog v1.33.0 // indirect
148+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
147149
github.com/sagikazarmark/locafero v0.4.0 // indirect
148150
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
149151
github.com/samber/lo v1.47.0 // indirect

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIG
222222
github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM=
223223
github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8=
224224
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
225+
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
225226
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
226227
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
227228
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
@@ -792,6 +793,7 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
792793
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
793794
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
794795
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
796+
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
795797
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
796798
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
797799
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=

0 commit comments

Comments
 (0)