docs

package
v6.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LongDescriptions added in v6.3.0

func LongDescriptions(sourcePath string) (map[string]string, error)

LongDescriptions parses a Go source file and returns a map from each urfave/cli flag's Name field to its long docs description, derived from the leading doc comment directly above the flag's composite literal.

Convention: a // comment block directly above an &cli.XFlag{...} literal is treated as the long docs description. Lines within a paragraph are joined with spaces; paragraphs (separated by an empty // line) are joined with "\n\n". A blank line in the source between the comment and the literal breaks the association.

This helper is intentionally format-agnostic: callers are responsible for merging the result into their docs format of choice (YAML, JSON, markdown, etc.).

func LongDescriptionsFor added in v6.4.0

func LongDescriptionsFor(sourcePath string) map[string]string

LongDescriptionsFor returns the long descriptions extracted from the Go source file at sourcePath, keyed by normalized flag name. It returns an empty map when sourcePath is empty or the file cannot be parsed so callers can pass an unset path without failing the whole pipeline.

func ToMarkdown

func ToMarkdown(app *cli.Command) (string, error)

ToMarkdown creates a markdown string for the `*App` without long descriptions. It is a convenience wrapper around ToMarkdownWithSource that passes an empty sourcePath.

func ToMarkdownWithSource added in v6.4.0

func ToMarkdownWithSource(app *cli.Command, sourcePath string) (string, error)

ToMarkdownWithSource creates a markdown string for the `*App`. If sourcePath points to a readable Go source file, long descriptions are extracted from leading doc comments above each flag's composite literal and merged into the rendered output. An empty sourcePath disables long description lookup. The function errors if either parsing or writing of the string fails.

Types

type CliTemplate

type CliTemplate struct {
	Name        string
	Version     string
	Description string
	Usage       string
	UsageText   string
	GlobalArgs  []*PluginArg
}

func GetTemplateData

func GetTemplateData(app *cli.Command) *CliTemplate

GetTemplateData returns the template data for the `*App` without long descriptions. It is a convenience wrapper around GetTemplateDataWithSource that passes an empty sourcePath.

func GetTemplateDataWithSource added in v6.4.0

func GetTemplateDataWithSource(app *cli.Command, sourcePath string) *CliTemplate

GetTemplateDataWithSource returns the template data for the `*App`. If sourcePath points to a readable Go source file, long descriptions are extracted from leading doc comments above each flag's composite literal and merged into the returned data. An empty sourcePath disables long description lookup.

type PluginArg

type PluginArg struct {
	Name            string
	EnvVars         []string
	Description     string
	LongDescription string
	Default         string
	Type            string
	Required        bool
}

Jump to

Keyboard shortcuts

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