4 ms·
I find rustdoc lacking for clap. rustdoc does a good job with API reference documentation and is improving in its handling of examples but derive reference and
by epage 4y ago
I find rustdoc lacking for clap. rustdoc does a good job with API reference documentation and is improving in its handling of examples but derive reference and tutorial documentation are a weak point.
For examples, its improving with the example scraping work (e.g. https://docs.rs/clap/latest/clap/struct.ArgMatches.html#method.value_of https://docs.rs/clap/latest/clap/struct.ArgMatches.html#meth...) but testing of example is still lacking. I've written trycmd to help (https://github.com/assert-rs/trycmd https://github.com/assert-rs/trycmd).
For derive reference and tutorial documentation, your choices are
- A very long, hard to navigate top-level documentation, see https://docs.rs/structopt/latest/structopt/ https://docs.rs/structopt/latest/structopt/
- External documentation, see https://serde.rs/ https://serde.rs/
- Dummy modules to store your documentation (I've seen this used but can't remember one off the top of my head)
For clap, my documentation examples are best served as programs and we've had a problem with these being broken. The Rust CLI book has a decent strategy for this by pulling in code from external files (https://rust-cli.github.io/book/index.html https://rust-cli.github.io/book/index.html). I was tempted to do that for clap where example code and output (all verified via trycmd) are pulled into an mdbook site but I've stopped short and just have a README that links out to everything (https://github.com/clap-rs/clap/blob/master/examples/tutorial_derive/README.md https://github.com/clap-rs/clap/blob/master/examples/tutoria...). Its not great.
- burntsushi 4y ago> Dummy modules to store your documentation (I've seen this used but can't remember one off the top of my head) Yeah I've done this and it works fantastic: https://docs.rs/csv/latest/csv/tutorial/index.html https://docs.rs/csv/latest/csv/tutorial/index.html All the examples are tested too. So not sure about the problem there. Can't speak to 'derive' docs. I rarely use derives outside of what std/serde give you, and I never publish any. But even so, I didn't say that rustdoc has zero weaknesses. :-) I said it is one of my favorite things about Rust because it is just so damn good. I've tried writing docs in several other languages before and they are leagues behind IMO. I would absolutely not call it "crippled." Not even close.