Documentation ¶
Overview ¶
Package cobraman is a library for generating documentation out of a command line structure created by the github.com/spf13/cobra library.
Index ¶
- Variables
- func AddTemplateFunc(name string, tmplFunc interface{})
- func AddTemplateFuncs(tmplFuncs template.FuncMap)
- func GenerateDocs(cmd *cobra.Command, opts *Options, directory string, templateName string) (err error)
- func GenerateOnePage(cmd *cobra.Command, opts *Options, templateName string, w io.Writer) error
- func RegisterTemplate(name string, separator string, extension string, templateString string)
- type DocGenTool
- type Options
Constants ¶
This section is empty.
Variables ¶
var ErrMissingCommandName = errors.New("you need a command name to have a man page")
ErrMissingCommandName is returned with no command is provided.
Functions ¶
func AddTemplateFunc ¶
func AddTemplateFunc(name string, tmplFunc interface{})
AddTemplateFunc adds a template function that's available to doc templates.
func AddTemplateFuncs ¶
AddTemplateFuncs adds multiple template functions that are available to doc templates.
func GenerateDocs ¶
func GenerateDocs(cmd *cobra.Command, opts *Options, directory string, templateName string) (err error)
GenerateDocs - build man pages for the passed in cobra.Command and all of its children.
func GenerateOnePage ¶
GenerateOnePage will generate one documentation page and output the result to w TODO: document use of this function in README.
func RegisterTemplate ¶
RegisterTemplate takes a template string creates a template for use with CobraMan. It also takes a separator and file extension to be used when generating the file names for the generated files.
Types ¶
type DocGenTool ¶
type DocGenTool struct {
// contains filtered or unexported fields
}
DocGenTool is an opaque type created by CreateDocGenCmdLineTool.
func CreateDocGenCmdLineTool ¶
func CreateDocGenCmdLineTool(appCmd *cobra.Command) *DocGenTool
CreateDocGenCmdLineTool creates a command line parser that can be used in a utility tool to generate documentation for a companion application.
func (*DocGenTool) AddBashCompletionGenerator ¶
func (dg *DocGenTool) AddBashCompletionGenerator(fileName string) *DocGenTool
AddBashCompletionGenerator will create a subcommand for the utility tool that will generate a Bash Completion file for the companion app. It will support a --directory flag and use the fileName passed into this function.
func (*DocGenTool) AddDocGenerator ¶
func (dg *DocGenTool) AddDocGenerator(opts *Options, templateName string) *DocGenTool
AddDocGenerator will create a subcommand for the utility tool that will generate documentation with the passed in Options and templateName. It supports a --directory flag for where to place the generated files. The subcommand will be named generate-<templateName> where templateName is the same as the template used to generate the documentation.
func (*DocGenTool) Execute ¶
func (dg *DocGenTool) Execute() error
Execute will parse args and execute the command line.
type Options ¶ added in v0.3.0
type Options struct { // What section to generate the pages 4 (1 is the default if not set) Section string // If you just want to set the date used in the center footer use Date CenterFooter string // If you just want to set the date used in the center footer use Date // Will default to Now Date *time.Time LeftFooter string // CenterHeader used across all pages CenterHeader string // Files if set with content will create a FILES section for all // pages. If you want this section only for a single command add // it as an annotation: cmd.Annotations["man-files-section"] // The field will be sanitized for troff output. However, if // it starts with a '.' we assume it is valid troff and pass it through. Files string // Bugs if set with content will create a BUGS section for all // pages. If you want this section only for a single command add // it as an annotation: cmd.Annotations["man-bugs-section"] // The field will be sanitized for troff output. However, if // it starts with a '.' we assume it is valid troff and pass it through. Bugs string // Environment if set with content will create a ENVIRONMENT section for all // pages. If you want this section only for a single command add // it as an annotation: cmd.Annotations["man-environment-section"] // The field will be sanitized for troff output. However, if // it starts with a '.' we assume it is valid troff and pass it through. Environment string // Author if set will create a Author section with this content. Author string // CustomData allows passing custom data into the template CustomData map[string]interface{} // contains filtered or unexported fields }
Options is used configure how GenerateManPages will do its job.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package main creates example documentation
|
Package main creates example documentation |
cmd
Package cmd is an example cobra application used to demonstrate the output of cobraman
|
Package cmd is an example cobra application used to demonstrate the output of cobraman |
docutil
Package main generates the documentation for the example application
|
Package main generates the documentation for the example application |