Skip to main content

Module docgen

Module docgen 

Source
Expand description

Generates documentation from CLI applications.

Ported from internal/docgen/markdown.go. The Go original reflects over github.com/urfave/cli/v3’s cli.Command/cli.Flag types; no equivalent introspectable CLI framework is wired into xianyun-cli yet, so Command and Flag are minimal structs/traits mirroring the subset of cli.Command/cli.Flag this package’s tests actually exercise (Name, Usage, Commands, Flags, Hidden, Aliases, ArgsUsage, Description, and the Flag interface’s Names/Get/ TypeName/GetUsage/GetEnvVars). Whether the real xianyun-cli crate ends up using clap (whose derive API has no direct reflection equivalent) or a hand-rolled introspectable command tree is a Phase 4 design decision – see PORT_NOTES.md.

Structs§

Command
Ported from the subset of github.com/urfave/cli/v3’s cli.Command this package’s functions read.
Flag
Ported from the Flag interface in markdown.go (itself a superset of cli.Flag adding GetUsage/GetEnvVars/TypeName).
UnsupportedFlagTypeError
Ported from ErrUnsupportedFlagType. This port’s Flag has no reflection escape hatch, so it is unused until a real CLI framework integration needs it; kept for interface parity.

Enums§

FlagValue
Ported from the reflection flag.Get() result that getFlagDefaultValue compares against the zero value of its own type. A closed enum stands in for Go’s any, since this port’s Flag has no reflection to fall back on.

Functions§

generate_command_files
Ported from GenerateCommandFiles. Writes one markdown file per visible top-level command into out_dir, plus an _index.md listing all commands. cmd_base_dir is the directory containing per-command packages (e.g. "cmd"); a DOC.md file found at cmd_base_dir/{normalized_name}/DOC.md is appended to each command’s Description section.
write_command
Ported from writeCommand. Writes a single command’s documentation to the writer.
write_commands
Ported from writeCommands. Writes command documentation to the writer, sorted by name for consistent output.