Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly set rustdoc attributes for docs.rs #2950

Closed
thomaseizinger opened this issue Sep 29, 2022 · 1 comment · Fixed by #2983
Closed

Properly set rustdoc attributes for docs.rs #2950

thomaseizinger opened this issue Sep 29, 2022 · 1 comment · Fixed by #2983
Labels
difficulty:moderate getting-started Issues that can be tackled if you don't know the internals of libp2p very well help wanted

Comments

@thomaseizinger
Copy link
Contributor

thomaseizinger commented Sep 29, 2022

On the topic of:

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]

What this does is tell docs.rs to pass the docsrs conditional compilation flag to rustc, meaning any code that is guarded with cfg(docsrs) will now be included in the build.

We use this in the libp2p root crate to conditionally include the doc attribute:

#[cfg_attr(docsrs, doc(cfg(feature = "deflate")))]

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 these cfg_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)

@mxinden mxinden added difficulty:moderate help wanted getting-started Issues that can be tackled if you don't know the internals of libp2p very well labels Oct 3, 2022
@umgefahren
Copy link
Contributor

umgefahren commented Oct 4, 2022

I'm currently working on it, however it is a lot of effort, since I have to go through nearly every single line of code here.

I will make a pull request with the changes I applied to libp2p-core, so you can judge wether the changes are good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty:moderate getting-started Issues that can be tackled if you don't know the internals of libp2p very well help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants