Skip to main content

render_markdown

Function render_markdown 

Source
pub fn render_markdown(command: &Command) -> String
Expand description

Render a Markdown documentation page for a command.

The output is GitHub-flavored Markdown with:

  • A # canonical top-level heading.
  • ## headings for Description, Usage, Arguments, Flags, Subcommands, Examples, Best Practices, and Anti-Patterns.
  • Arguments and flags rendered as Markdown tables.
  • Usage and examples rendered as fenced code blocks.

Empty sections are omitted.

§Arguments

  • command — The command to render documentation for.

§Examples

let cmd = Command::builder("deploy")
    .summary("Deploy the app")
    .build()
    .unwrap();

let md = render_markdown(&cmd);
assert!(md.starts_with("# deploy"));
assert!(md.contains("Deploy the app"));