Properly set rustdoc attributes for docs.rs #2950
Labels
difficulty:moderate
getting-started
Issues that can be tackled if you don't know the internals of libp2p very well
help wanted
On the topic of:
What this does is tell docs.rs to pass the
docsrs
conditional compilation flag to rustc, meaning any code that is guarded withcfg(docsrs)
will now be included in the build.We use this in the
libp2p
root crate to conditionally include thedoc
attribute:rust-libp2p/src/lib.rs
Line 53 in 04b07c4
We need to do this conditionally because the
#[doc(cfg)]
attribute is not yet stable. docs.rs runs all their build pipelines on nightly so we can use it there.Now, interestingly, we don't set this in our
libp2p
crate so all of thesecfg_attr
attributes have been doing nothing all this time :)In this crate, it is used here: https://github.com/umgefahren/rust-libp2p/blob/6f4bca5bbfd141bc18d9d931c5d28b50a212f0fe/transports/onion/src/provider.rs#L31-L36
And will tell docs.rs to include a little "only available with feature
tokio
" tag next to the item.Originally posted by @thomaseizinger in #2899 (comment)
The text was updated successfully, but these errors were encountered: