Skip to content

Support for test cases in documentation comments #171

Open
@jpmckinney

Description

@jpmckinney

I use clap, and I put examples in the documentation comments for my commands/subcommands like:

enum Commands {
    /// Counts from START to STOP.
    ///
    /// $ mycli counter 1 3
    /// 1
    /// 2
    /// 3
    Counter {
        start: usize,
        stop: usize,
    }
}

From discussion in clap-rs/clap#4500

One alternative is to pull a markdown file into your doc comment

e.g. #[doc = include_str!("../../README.md")]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trycmdArea: trycmd packageenhancementImprove the expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions