Skip to main content

Module docs

Module docs 

Source
Expand description

The command line as documentation data.

clap is the one declaration of the command line: every command, argument, default and value set. This module walks the built [clap::Command] into CommandDoc, attaches the typed examples declared beside the declaration in super::EXAMPLES, and derives the route each command has on the website. Every projection of the native command line — --help, docs/generated/cli.md, docs/generated/cli.json, the site dataset and /docs/cli/** — is a rendering of this one tree, never of --help prose and never of a list kept beside the declaration.

Structs§

ArgDoc
One argument of a command.
CliDocument
The machine-readable projection of the whole tree: docs/generated/cli.json, the file the website’s generator reads. One document, deterministic, with no provenance of its own beyond the crate version.
CommandDoc
One command of the executable’s command line, as clap declares it, with the commands under it. The root is majordomus.
ExampleView
One example, as every projection shows it. The command lines are rendered from the declaration’s argv, never written out a second time, so what a reader copies is what the example test executed.
PossibleValueDoc
One value of a value-enum argument.
SetupView
One command run before an example, in the same session.

Constants§

DECLARATION
The file the whole command line is declared in; the provenance every projection shows.
ROUTE_PREFIX
The prefix of every command’s route on the website. The native command line’s reference owns this section; the shell tool’s specification (docs/CLI.md) is a different program and renders elsewhere.
SCHEMA
The schema of docs/generated/cli.json, the machine-readable projection of this tree.

Functions§

document
The whole tree as the committed JSON projection.
render
["bench", "coverage", "--format", "json"] as majordomus bench coverage --format json. A word that would not survive a shell unquoted is quoted; nothing else is decorated.
route
The route of a command path: ["majordomus", "bench", "coverage"] becomes /docs/cli/bench/coverage/, and the root becomes /docs/cli/. The one rule; every other consumer reads CommandDoc::route rather than repeating it.
tree
The whole command line, from the built clap declaration and the examples declared with it. Deterministic and pure: clap keeps declaration order, and nothing here reads the environment, the repository or the network.