/cobradoc

Alternative documentation generator for Cobra.

Primary LanguageGoMIT LicenseMIT

cobradoc GoDev Build GitHub release

Alternative documentation generator for golang Cobra.

Highlights

  • Supports markdown and manpage (troff) formats
  • Supports command groups
  • Generates single page for the whole command tree

Reference

API reference is available on pkg.go.dev.

Example

_example directory demonstrates usage of this package.

It contains:

Usage

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)
}

Credits

This package is inspired by cobraman by Ray Johnson, but uses single-page approach and adds support for command groups.

Authors

See here.

License

MIT