How to test a package.metadata.docs.rs setting?

Hi,

I've used #![cfg_attr(docsrs, feature(doc_cfg))] and #[cfg_attr(docsrs, doc(cfg(feature = "my_flag")))] like Tokio does.

Added in Cargo.toml :

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

Now I'm wondering how do I test that locally before pushing everything on crates.io?

Thanks!

You can pass the cfg directly while building docs using cargo by setting the environment variable RUSTFLAGS="--cfg docsrs"

1 Like

I had to use RUSTDOCFLAGS but that was the solution :slight_smile: thanks!

1 Like

TIL RUSTDOCFLAGS exists

1 Like