Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LongDescriptions ¶ added in v6.3.0
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
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 ¶
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
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.