trycmd icon indicating copy to clipboard operation
trycmd copied to clipboard

Support for test cases in documentation comments

Open jpmckinney opened this issue 3 years ago • 0 comments

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 https://github.com/clap-rs/clap/discussions/4500

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

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

jpmckinney avatar Nov 22 '22 14:11 jpmckinney