docs

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package docs provides documentation generation for Cobra commands in multiple formats including Markdown, man pages, YAML, and reStructuredText.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenMan

func GenMan(cmd *cobra.Command, header *GenManHeader, w io.Writer) error

GenMan generates a man page for a single command.

func GenManTree

func GenManTree(cmd *cobra.Command, dir string) error

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

func GenMarkdown(cmd *cobra.Command, w io.Writer) error

GenMarkdown generates markdown documentation for a single command.

func GenMarkdownCustom

func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) string) error

GenMarkdownCustom generates markdown documentation with a custom link handler.

func GenMarkdownTree

func GenMarkdownTree(cmd *cobra.Command, dir string) error

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 GenReST

func GenReST(cmd *cobra.Command, w io.Writer) error

GenReST generates reStructuredText documentation for a single command.

func GenReSTCustom

func GenReSTCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) string) error

GenReSTCustom generates reStructuredText documentation with a custom link handler.

func GenReSTTree

func GenReSTTree(cmd *cobra.Command, dir string) error

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 GenYaml

func GenYaml(cmd *cobra.Command, w io.Writer) error

GenYaml generates YAML documentation for a single command.

func GenYamlCustom

func GenYamlCustom(cmd *cobra.Command, w io.Writer, customizer func(*CommandDoc)) error

GenYamlCustom generates YAML documentation with custom processing.

func GenYamlTree

func GenYamlTree(cmd *cobra.Command, dir string) error

GenYamlTree generates YAML documentation for a command and all its subcommands. Each command is written to a separate file.

func GenYamlTreeCustom

func GenYamlTreeCustom(cmd *cobra.Command, dir string, filenameFunc func(*cobra.Command) string) error

GenYamlTreeCustom generates YAML documentation with a custom filename function.

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

type OptionDoc

type OptionDoc struct {
	Name         string `yaml:"name"`
	Shorthand    string `yaml:"shorthand,omitempty"`
	DefaultValue string `yaml:"default_value,omitempty"`
	Usage        string `yaml:"usage"`
	Type         string `yaml:"type,omitempty"`
}

OptionDoc represents YAML documentation for a command flag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL