Documentation
¶
Overview ¶
Package docs provides documentation generation for Cobra commands in multiple formats including Markdown, man pages, YAML, and reStructuredText.
Index ¶
- func GenMan(cmd *cobra.Command, header *GenManHeader, w io.Writer) error
- func GenManTree(cmd *cobra.Command, dir string) error
- func GenManTreeFromOpts(cmd *cobra.Command, opts GenManTreeOptions) error
- func GenMarkdown(cmd *cobra.Command, w io.Writer) error
- func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) string) error
- func GenMarkdownTree(cmd *cobra.Command, dir string) error
- func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error
- func GenReST(cmd *cobra.Command, w io.Writer) error
- func GenReSTCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) string) error
- func GenReSTTree(cmd *cobra.Command, dir string) error
- func GenReSTTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error
- func GenYaml(cmd *cobra.Command, w io.Writer) error
- func GenYamlCustom(cmd *cobra.Command, w io.Writer, customizer func(*CommandDoc)) error
- func GenYamlTree(cmd *cobra.Command, dir string) error
- func GenYamlTreeCustom(cmd *cobra.Command, dir string, filenameFunc func(*cobra.Command) string) error
- type CommandDoc
- type GenManHeader
- type GenManTreeOptions
- type OptionDoc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenManTree ¶
GenManTree generates man pages for cmd and all subcommands. Man pages are written to the specified directory.
func GenManTreeFromOpts ¶
func GenManTreeFromOpts(cmd *cobra.Command, opts GenManTreeOptions) error
GenManTreeFromOpts generates man pages with custom options.
func GenMarkdown ¶
GenMarkdown generates markdown documentation for a single command.
func GenMarkdownCustom ¶
GenMarkdownCustom generates markdown documentation with a custom link handler.
func GenMarkdownTree ¶
GenMarkdownTree generates markdown documentation for a command and all its subcommands. Files are created in the specified directory using the command path as filename.
func GenMarkdownTreeCustom ¶
func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error
GenMarkdownTreeCustom generates markdown documentation with custom file prepender and link handler. The filePrepender is called with each filename to prepend content (e.g., front matter). The linkHandler transforms command names to links (e.g., adding .md extension).
func GenReSTCustom ¶
GenReSTCustom generates reStructuredText documentation with a custom link handler.
func GenReSTTree ¶
GenReSTTree generates reStructuredText documentation for a command and all its subcommands. Files are created in the specified directory using the command path as filename.
func GenReSTTreeCustom ¶
func GenReSTTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error
GenReSTTreeCustom generates reStructuredText documentation with custom file prepender and link handler. The filePrepender is called with each filename to prepend content (e.g., directives). The linkHandler transforms command names to RST links.
func GenYamlCustom ¶
GenYamlCustom generates YAML documentation with custom processing.
func GenYamlTree ¶
GenYamlTree generates YAML documentation for a command and all its subcommands. Each command is written to a separate file.
Types ¶
type CommandDoc ¶
type CommandDoc struct {
Name string `yaml:"name"`
Synopsis string `yaml:"synopsis,omitempty"`
Description string `yaml:"description,omitempty"`
Usage string `yaml:"usage,omitempty"`
Aliases []string `yaml:"aliases,omitempty"`
Options []OptionDoc `yaml:"options,omitempty"`
InheritedOptions []OptionDoc `yaml:"inherited_options,omitempty"`
Commands []CommandDoc `yaml:"commands,omitempty"`
Examples string `yaml:"examples,omitempty"`
SeeAlso []string `yaml:"see_also,omitempty"`
}
CommandDoc represents YAML documentation structure for a command.
type GenManHeader ¶
type GenManHeader struct {
Title string
Section string
Date *time.Time
Source string
Manual string
}
GenManHeader contains man page metadata
type GenManTreeOptions ¶
type GenManTreeOptions struct {
Path string
CommandSeparator string
Header *GenManHeader
}
GenManTreeOptions configures man page generation