First, let me start by saying that rust doc and the cargo docs are generally great, and a lot of people put a lot of effort into documenting how to use their code.
When I start using a new crate, usually the first thing I do, therefore, is look at their docs.rs page, and I don't usually start by investigating their repository and trying to read their code.
However, inevitably I usually do have to go look at their repository, because afaict, rust docs does not generate any information about the crate's feature configuration.
Some projects, for example this one, has extensive documentation of their features in the main crate README.md: jwt_compact - Rust
Some projects document their "recommended" configuration which you can copy paste into your cargo toml, such as this one: GitHub - seanmonstar/warp: A super-easy, composable, web server framework for warp speeds.
However, those notes don't end up in the docs.rs for the project: warp - Rust
Some projects have a repo with a large workspace, so it may take some digging to find documentation around a particular crate's configuration.
Usually my experience has been that, unless there is something in the first rustdoc page for the crate, then I go to the repository for the crate, (which is usually but not always github), where I search for a README.md. If there's nothing mentioned there, then I look for a Cargo.toml
and hope that there are #
comments describing the features.
Cargo currently supports a cargo toml field [package.metadata.docs.rs]
, but this is used to customize the build flags and features used by docs.rs when it builds the documentation from the source code. It is not used to provide any information intended for the user to figure out how to configure your crate.
Question: Should there be a standard way to document what features your crate offers? Should rustdoc generate a summary of the different options, based on what appears in cargo.toml?
IMO it would be nice if docs.rs can tell me not only how to use the code, but how to configure the crate, at a particular release. That would mean that I would almost never have to navigate to the actual repository and try to find the released commit in order to figure out how to use the crate.