1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Generate well-structured Markdown documentation from a [`clap`] CLI.
//!
//! `clapdown` walks a [`clap::Command`] and renders it to Markdown whose
//! heading outline tracks command nesting without ever skipping a level: the
//! root command is a top-level heading, each subcommand descends one level, and
//! a command's `Arguments`/`Options` sections sit one level below the command.
//! Arguments render as definition lists.
//!
//! # Example
//!
//! ```
//! use clap::Command;
//!
//! let cmd = Command::new("greet")
//! .about("Greet someone")
//! .arg(clap::Arg::new("name").help("Who to greet"));
//!
//! let markdown = clapdown::Options::new().render(&cmd);
//! assert!(markdown.contains("# `greet`"));
//! ```
//!
//! Use [`render_from`] to go straight from a derived CLI type:
//!
//! ```
//! use clap::Parser;
//!
//! #[derive(Parser)]
//! #[command(name = "greet", about = "Greet someone")]
//! struct Cli {
//! /// Who to greet
//! name: String,
//! }
//!
//! let markdown = clapdown::render_from::<Cli>(&clapdown::Options::new());
//! assert!(markdown.contains("# `greet`"));
//! ```
pub use ;
use ;
/// Render `cmd` to a Markdown string using `opts`.
///
/// Equivalent to [`Options::render`]; provided for callers that already hold an
/// [`Options`] value.
/// Render the CLI defined by `C` to a Markdown string using `opts`.
///
/// Obtains the [`Command`] via [`clap::CommandFactory`], so it works directly
/// with types deriving [`clap::Parser`].