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’scli.Commandthis package’s functions read. - Flag
- Ported from the
Flaginterface inmarkdown.go(itself a superset ofcli.FlagaddingGetUsage/GetEnvVars/TypeName). - Unsupported
Flag Type Error - Ported from
ErrUnsupportedFlagType. This port’sFlaghas no reflection escape hatch, so it is unused until a real CLI framework integration needs it; kept for interface parity.
Enums§
- Flag
Value - Ported from the reflection
flag.Get()result thatgetFlagDefaultValuecompares against the zero value of its own type. A closed enum stands in for Go’sany, since this port’sFlaghas no reflection to fall back on.
Functions§
- generate_
command_ files - Ported from
GenerateCommandFiles. Writes one markdown file per visible top-level command intoout_dir, plus an_index.mdlisting all commands.cmd_base_diris the directory containing per-command packages (e.g."cmd"); aDOC.mdfile found atcmd_base_dir/{normalized_name}/DOC.mdis 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.