Skip to content

Commit f30bcc6

Browse files
ninevrajeff-hiner
authored andcommitted
Document all features (on docs.rs)
Use the unstable feature doc_auto_cfg to document items' feature flags, and configure docs.rs runs to compile all features. For now, using this locally requires running `cargo +nightly rustdoc --all-features -- --cfg docsrs`.
1 parent 66e3607 commit f30bcc6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ itertools = "0.10"
3131
[[example]]
3232
name = "evtest_tokio"
3333
required-features = ["tokio"]
34+
35+
[package.metadata.docs.rs]
36+
all-features = true
37+
rustdoc-args = ["--cfg", "docsrs"]

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@
8686
8787
// should really be cfg(target_os = "linux") and maybe also android?
8888
#![cfg(unix)]
89+
// Flag items' docs' with their required feature flags, but only on docsrs so
90+
// that local docs can still be built on stable toolchains.
91+
// As of the time of writing, the stabilization plan is such that:
92+
// - Once stabilized, this attribute should be replaced with #![doc(auto_cfg)]
93+
// - Then in edition 2024, doc(auto_cfg) will become the default and the
94+
// attribute can be removed entirely
95+
// (see https://github.com/rust-lang/rust/pull/100883#issuecomment-1264470491)
96+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
8997

9098
// has to be first for its macro
9199
#[macro_use]

0 commit comments

Comments
 (0)