Alternative documentation generator for golang Cobra.
- Supports markdown and manpage (troff) formats
- Supports command groups
- Generates single page for the whole command tree
API reference is available on pkg.go.dev.
_example directory demonstrates usage of this package.
It contains:
Generate markdown page:
import "github.com/gavv/cobradoc"
err := cobradoc.WriteDocument(os.Stdout, rootCmd, cobradoc.Markdown, cobradoc.Options{
Name: "my-tool",
Header: "My page header",
ShortDescription: "My tool description",
})
if err != nil {
panic(err)
}
Generate manual page:
import "github.com/gavv/cobradoc"
err := cobradoc.WriteDocument(os.Stdout, rootCmd, cobradoc.Troff, cobradoc.Options{
Name: "my-tool",
Header: "My page header",
ShortDescription: "My tool description",
ExtraSections: []cobradoc.ExtraSection{
{
Title: cobradoc.BUGS,
Text: "Please report bugs via GitHub",
},
},
})
if err != nil {
panic(err)
}
This package is inspired by cobraman by Ray Johnson, but uses single-page approach and adds support for command groups.
See here.