diff --git a/Cargo.toml b/Cargo.toml index 26169817cfc..4588601ffcf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,9 +78,6 @@ serde = ["libp2p-core/serde", "libp2p-kad?/serde", "libp2p-gossipsub?/serde"] tokio = ["libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio"] async-std = ["libp2p-mdns?/async-io", "libp2p-tcp?/async-io", "libp2p-dns?/async-std"] -[package.metadata.docs.rs] -all-features = true - [dependencies] bytes = "1" futures = "0.3.1" @@ -204,3 +201,10 @@ required-features = ["full"] [[example]] name = "distributed-key-value-store" required-features = ["full"] + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/core/Cargo.toml b/core/Cargo.toml index c0881afe619..027cd6bd824 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -64,3 +64,10 @@ serde = ["multihash/serde-codec", "dep:serde"] [[bench]] name = "peer_id" harness = false + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/core/src/lib.rs b/core/src/lib.rs index ac55537eb0b..88c6cc0df7c 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -35,6 +35,8 @@ //! define how to upgrade each individual substream to use a protocol. //! See the `upgrade` module. +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + #[allow(clippy::derive_partial_eq_without_eq)] mod keys_proto { include!(concat!(env!("OUT_DIR"), "/keys_proto.rs")); diff --git a/misc/metrics/Cargo.toml b/misc/metrics/Cargo.toml index 1e96355606a..ca9acacbed4 100644 --- a/misc/metrics/Cargo.toml +++ b/misc/metrics/Cargo.toml @@ -38,3 +38,10 @@ futures = "0.3.1" libp2p = { path = "../..", features = ["full"] } hyper = { version="0.14", features = ["server", "tcp", "http1"] } tokio = { version = "1", features = ["rt-multi-thread"] } + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/misc/metrics/src/lib.rs b/misc/metrics/src/lib.rs index bc9f45b8d76..d42f6b3ffe0 100644 --- a/misc/metrics/src/lib.rs +++ b/misc/metrics/src/lib.rs @@ -25,6 +25,8 @@ //! //! See `examples` directory for more. +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + #[cfg(feature = "dcutr")] mod dcutr; #[cfg(feature = "gossipsub")] diff --git a/misc/multistream-select/Cargo.toml b/misc/multistream-select/Cargo.toml index c669eb314aa..8dced22ffcd 100644 --- a/misc/multistream-select/Cargo.toml +++ b/misc/multistream-select/Cargo.toml @@ -25,3 +25,10 @@ libp2p = { path = "../..", features = ["full"] } quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" } rand = "0.8" rw-stream-sink = { version = "0.3.0", path = "../../misc/rw-stream-sink" } + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/misc/multistream-select/src/lib.rs b/misc/multistream-select/src/lib.rs index 0d7346750bc..0dbcf3cbe0b 100644 --- a/misc/multistream-select/src/lib.rs +++ b/misc/multistream-select/src/lib.rs @@ -87,6 +87,8 @@ //! ``` //! +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + mod dialer_select; mod length_delimited; mod listener_select; diff --git a/misc/prost-codec/Cargo.toml b/misc/prost-codec/Cargo.toml index f4d1e90f844..34a5c451cc5 100644 --- a/misc/prost-codec/Cargo.toml +++ b/misc/prost-codec/Cargo.toml @@ -19,3 +19,10 @@ unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] } [dev-dependencies] prost-build = "0.11" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/misc/prost-codec/src/lib.rs b/misc/prost-codec/src/lib.rs index 32b8c9b9577..f8efa147a39 100644 --- a/misc/prost-codec/src/lib.rs +++ b/misc/prost-codec/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + use asynchronous_codec::{Decoder, Encoder}; use bytes::BytesMut; use prost::Message; diff --git a/misc/quickcheck-ext/src/lib.rs b/misc/quickcheck-ext/src/lib.rs index 392c9f0f8aa..a3b9ce26e6e 100644 --- a/misc/quickcheck-ext/src/lib.rs +++ b/misc/quickcheck-ext/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + pub use quickcheck::*; use core::ops::Range; diff --git a/misc/rw-stream-sink/Cargo.toml b/misc/rw-stream-sink/Cargo.toml index 113c168a96a..dba6ff992f1 100644 --- a/misc/rw-stream-sink/Cargo.toml +++ b/misc/rw-stream-sink/Cargo.toml @@ -16,3 +16,10 @@ static_assertions = "1" [dev-dependencies] async-std = "1.0" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/misc/rw-stream-sink/src/lib.rs b/misc/rw-stream-sink/src/lib.rs index 10f5ec09fe1..ee05196bfb4 100644 --- a/misc/rw-stream-sink/src/lib.rs +++ b/misc/rw-stream-sink/src/lib.rs @@ -25,6 +25,8 @@ //! Each call to [`AsyncWrite::poll_write`] will send one packet to the sink. //! Calls to [`AsyncRead::poll_read`] will read from the stream's incoming packets. +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + use futures::{prelude::*, ready}; use std::{ io::{self, Read}, diff --git a/muxers/mplex/Cargo.toml b/muxers/mplex/Cargo.toml index e5fb1c305ef..0008e9b7f1d 100644 --- a/muxers/mplex/Cargo.toml +++ b/muxers/mplex/Cargo.toml @@ -34,3 +34,10 @@ quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" } [[bench]] name = "split_send_size" harness = false + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/muxers/mplex/src/lib.rs b/muxers/mplex/src/lib.rs index 501c4dd6735..6fc0188cd33 100644 --- a/muxers/mplex/src/lib.rs +++ b/muxers/mplex/src/lib.rs @@ -18,6 +18,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + mod codec; mod config; mod io; diff --git a/muxers/yamux/Cargo.toml b/muxers/yamux/Cargo.toml index 35992e29efc..270c0a75f16 100644 --- a/muxers/yamux/Cargo.toml +++ b/muxers/yamux/Cargo.toml @@ -21,3 +21,10 @@ log = "0.4" [dev-dependencies] async-std = { version = "1.7.0", features = ["attributes"] } libp2p-muxer-test-harness = { path = "../test-harness" } + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/muxers/yamux/src/lib.rs b/muxers/yamux/src/lib.rs index 50e8a3ecc5e..c3118e7feac 100644 --- a/muxers/yamux/src/lib.rs +++ b/muxers/yamux/src/lib.rs @@ -21,6 +21,8 @@ //! Implements the Yamux multiplexing protocol for libp2p, see also the //! [specification](https://github.com/hashicorp/yamux/blob/master/spec.md). +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + use futures::{ future, prelude::*, diff --git a/protocols/autonat/Cargo.toml b/protocols/autonat/Cargo.toml index c3b88583839..68ff289a424 100644 --- a/protocols/autonat/Cargo.toml +++ b/protocols/autonat/Cargo.toml @@ -30,3 +30,10 @@ async-std = { version = "1.10", features = ["attributes"] } env_logger = "0.9" clap = { version = "4.0.13", features = ["derive"] } libp2p = { path = "../..", features = ["full"] } + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/protocols/autonat/src/lib.rs b/protocols/autonat/src/lib.rs index b21c73dd0d0..d0fd5c04346 100644 --- a/protocols/autonat/src/lib.rs +++ b/protocols/autonat/src/lib.rs @@ -19,6 +19,9 @@ // DEALINGS IN THE SOFTWARE. //! Implementation of the AutoNAT protocol. + +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + mod behaviour; mod protocol; diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index d9cc5861bc5..c90af2f7bf7 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -33,3 +33,10 @@ env_logger = "0.9.0" libp2p = { path = "../..", features = ["full"] } rand = "0.8" clap = { version = "4.0.13", features = ["derive"] } + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/protocols/dcutr/src/lib.rs b/protocols/dcutr/src/lib.rs index 4a843bac2b7..738af5300b1 100644 --- a/protocols/dcutr/src/lib.rs +++ b/protocols/dcutr/src/lib.rs @@ -21,6 +21,8 @@ //! Implementation of the [libp2p Direct Connection Upgrade through Relay //! specification](https://github.com/libp2p/specs/blob/master/relay/DCUtR.md). +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + pub mod behaviour; mod handler; mod protocol; diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index f030e7477d9..cfbf03ebd46 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -23,3 +23,10 @@ smallvec = "1.6.1" [build-dependencies] prost-build = "0.11" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/protocols/floodsub/src/lib.rs b/protocols/floodsub/src/lib.rs index 109d0db8795..6eb0af276e2 100644 --- a/protocols/floodsub/src/lib.rs +++ b/protocols/floodsub/src/lib.rs @@ -21,6 +21,8 @@ //! Implements the floodsub protocol, see also the: //! [spec](https://github.com/libp2p/specs/tree/master/pubsub). +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + use libp2p_core::PeerId; pub mod protocol; diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 00778ef0688..cc337869ccf 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -43,3 +43,10 @@ derive_builder = "0.11.1" [build-dependencies] prost-build = "0.11" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/protocols/gossipsub/src/lib.rs b/protocols/gossipsub/src/lib.rs index 4f00f82ba36..b262f7ce88b 100644 --- a/protocols/gossipsub/src/lib.rs +++ b/protocols/gossipsub/src/lib.rs @@ -133,6 +133,8 @@ //! println!("Listening on {:?}", addr); //! ``` +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + pub mod error; pub mod protocol; diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index c24c2e8a9c6..d52155bae1c 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -31,3 +31,10 @@ libp2p = { path = "../..", features = ["full"] } [build-dependencies] prost-build = "0.11" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/protocols/identify/src/lib.rs b/protocols/identify/src/lib.rs index e9d89dfba97..e4748eba07c 100644 --- a/protocols/identify/src/lib.rs +++ b/protocols/identify/src/lib.rs @@ -39,6 +39,8 @@ //! that negotiates and executes the protocol on every established connection, emitting //! [`Event`]s. +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + pub use self::behaviour::{Behaviour, Config, Event}; pub use self::protocol::{Info, UpgradeError, PROTOCOL_NAME, PUSH_PROTOCOL_NAME}; diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index e97394b7071..89354c74aa8 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -43,3 +43,10 @@ prost-build = "0.11" [features] serde = ["dep:serde", "bytes/serde"] + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/protocols/kad/src/lib.rs b/protocols/kad/src/lib.rs index de6f8159e0b..67cee19818d 100644 --- a/protocols/kad/src/lib.rs +++ b/protocols/kad/src/lib.rs @@ -38,6 +38,7 @@ // TODO: we allow dead_code for now because this library contains a lot of unused code that will // be useful later for record store #![allow(dead_code)] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] pub mod handler; pub mod kbucket; diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 2663c76f820..1209d670f43 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -45,3 +45,10 @@ required-features = ["async-io"] name = "use-tokio" required-features = ["tokio"] + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/protocols/mdns/src/lib.rs b/protocols/mdns/src/lib.rs index f05476af7dd..45609f73ef6 100644 --- a/protocols/mdns/src/lib.rs +++ b/protocols/mdns/src/lib.rs @@ -30,6 +30,9 @@ //! implements the `NetworkBehaviour` trait. This struct will automatically discover other //! libp2p nodes on the local network. //! + +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + use std::net::{Ipv4Addr, Ipv6Addr}; use std::time::Duration; diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index 70e03164318..51c1f8e7da2 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -24,3 +24,10 @@ void = "1.0" async-std = "1.6.2" libp2p = { path = "../..", features = ["full"] } quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" } + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/protocols/ping/src/lib.rs b/protocols/ping/src/lib.rs index 42234488964..02babd2ea06 100644 --- a/protocols/ping/src/lib.rs +++ b/protocols/ping/src/lib.rs @@ -40,6 +40,8 @@ //! [`Swarm`]: libp2p_swarm::Swarm //! [`Transport`]: libp2p_core::Transport +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + mod handler; mod protocol; diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index 19837380355..f4b12ccb991 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -37,3 +37,10 @@ env_logger = "0.9.0" libp2p = { path = "../..", features = ["full"] } quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" } clap = { version = "4.0.13", features = ["derive"] } + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/protocols/relay/src/lib.rs b/protocols/relay/src/lib.rs index 79329335079..e1d4bb03b20 100644 --- a/protocols/relay/src/lib.rs +++ b/protocols/relay/src/lib.rs @@ -21,6 +21,8 @@ //! libp2p circuit relay implementations +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + pub mod v2; // Check that we can safely cast a `usize` to a `u64`. diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index fc25965bccd..378ec567636 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -35,3 +35,10 @@ tokio = { version = "1.15", features = [ "rt-multi-thread", "time", "macros", "s [build-dependencies] prost-build = "0.11" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/protocols/rendezvous/src/lib.rs b/protocols/rendezvous/src/lib.rs index 1708147f977..08aae950068 100644 --- a/protocols/rendezvous/src/lib.rs +++ b/protocols/rendezvous/src/lib.rs @@ -18,6 +18,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + pub use self::codec::{Cookie, ErrorCode, Namespace, NamespaceTooLong, Registration, Ttl}; mod codec; diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 53e0b756392..f35bf92fc64 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -27,3 +27,10 @@ async-std = "1.6.2" env_logger = "0.9.0" libp2p = { path = "../..", features = ["full"] } rand = "0.8" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/protocols/request-response/src/lib.rs b/protocols/request-response/src/lib.rs index c4e18d894fb..887a42a9b6a 100644 --- a/protocols/request-response/src/lib.rs +++ b/protocols/request-response/src/lib.rs @@ -56,6 +56,8 @@ //! advertised during inbound respectively outbound protocol negotiation //! on the substreams. +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + pub mod codec; pub mod handler; diff --git a/src/lib.rs b/src/lib.rs index d2b4226d2ce..c8b0ed64f7a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,6 +31,7 @@ #![doc(html_logo_url = "https://libp2p.io/img/logo_small.png")] #![doc(html_favicon_url = "https://libp2p.io/img/favicon.png")] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] pub use bytes; pub use futures; @@ -40,17 +41,14 @@ pub use libp2p_core::multihash; pub use multiaddr; #[cfg(feature = "autonat")] -#[cfg_attr(docsrs, doc(cfg(feature = "autonat")))] #[doc(inline)] pub use libp2p_autonat as autonat; #[doc(inline)] pub use libp2p_core as core; #[cfg(feature = "dcutr")] -#[cfg_attr(docsrs, doc(cfg(feature = "dcutr")))] #[doc(inline)] pub use libp2p_dcutr as dcutr; #[cfg(feature = "deflate")] -#[cfg_attr(docsrs, doc(cfg(feature = "deflate")))] #[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))] #[doc(inline)] pub use libp2p_deflate as deflate; @@ -60,20 +58,16 @@ pub use libp2p_deflate as deflate; #[doc(inline)] pub use libp2p_dns as dns; #[cfg(feature = "floodsub")] -#[cfg_attr(docsrs, doc(cfg(feature = "floodsub")))] #[doc(inline)] pub use libp2p_floodsub as floodsub; #[cfg(feature = "gossipsub")] -#[cfg_attr(docsrs, doc(cfg(feature = "gossipsub")))] #[cfg(not(target_os = "unknown"))] #[doc(inline)] pub use libp2p_gossipsub as gossipsub; #[cfg(feature = "identify")] -#[cfg_attr(docsrs, doc(cfg(feature = "identify")))] #[doc(inline)] pub use libp2p_identify as identify; #[cfg(feature = "kad")] -#[cfg_attr(docsrs, doc(cfg(feature = "kad")))] #[doc(inline)] pub use libp2p_kad as kad; #[cfg(feature = "mdns")] @@ -82,39 +76,30 @@ pub use libp2p_kad as kad; #[doc(inline)] pub use libp2p_mdns as mdns; #[cfg(feature = "metrics")] -#[cfg_attr(docsrs, doc(cfg(feature = "metrics")))] #[doc(inline)] pub use libp2p_metrics as metrics; #[cfg(feature = "mplex")] -#[cfg_attr(docsrs, doc(cfg(feature = "mplex")))] #[doc(inline)] pub use libp2p_mplex as mplex; #[cfg(feature = "noise")] -#[cfg_attr(docsrs, doc(cfg(feature = "noise")))] #[doc(inline)] pub use libp2p_noise as noise; #[cfg(feature = "ping")] -#[cfg_attr(docsrs, doc(cfg(feature = "ping")))] #[doc(inline)] pub use libp2p_ping as ping; #[cfg(feature = "plaintext")] -#[cfg_attr(docsrs, doc(cfg(feature = "plaintext")))] #[doc(inline)] pub use libp2p_plaintext as plaintext; #[cfg(feature = "pnet")] -#[cfg_attr(docsrs, doc(cfg(feature = "pnet")))] #[doc(inline)] pub use libp2p_pnet as pnet; #[cfg(feature = "relay")] -#[cfg_attr(docsrs, doc(cfg(feature = "relay")))] #[doc(inline)] pub use libp2p_relay as relay; #[cfg(feature = "rendezvous")] -#[cfg_attr(docsrs, doc(cfg(feature = "rendezvous")))] #[doc(inline)] pub use libp2p_rendezvous as rendezvous; #[cfg(feature = "request-response")] -#[cfg_attr(docsrs, doc(cfg(feature = "request-response")))] #[doc(inline)] pub use libp2p_request_response as request_response; #[doc(inline)] @@ -129,20 +114,16 @@ pub use libp2p_tcp as tcp; #[doc(inline)] pub use libp2p_tls as tls; #[cfg(feature = "uds")] -#[cfg_attr(docsrs, doc(cfg(feature = "uds")))] #[doc(inline)] pub use libp2p_uds as uds; #[cfg(feature = "wasm-ext")] -#[cfg_attr(docsrs, doc(cfg(feature = "wasm-ext")))] #[doc(inline)] pub use libp2p_wasm_ext as wasm_ext; #[cfg(feature = "websocket")] -#[cfg_attr(docsrs, doc(cfg(feature = "websocket")))] #[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))] #[doc(inline)] pub use libp2p_websocket as websocket; #[cfg(feature = "yamux")] -#[cfg_attr(docsrs, doc(cfg(feature = "yamux")))] #[doc(inline)] pub use libp2p_yamux as yamux; @@ -188,20 +169,6 @@ pub use libp2p_swarm_derive::NetworkBehaviour; feature = "mplex", feature = "yamux" ))] -#[cfg_attr( - docsrs, - doc(cfg(all( - not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")), - any( - all(feature = "tcp-async-io", feature = "dns-async-std"), - all(feature = "tcp", feature = "dns", feature = "async-std") - ), - feature = "websocket", - feature = "noise", - feature = "mplex", - feature = "yamux" - ))) -)] #[cfg_attr( all( any(feature = "tcp-async-io", feature = "dns-async-std"), @@ -262,20 +229,6 @@ pub async fn development_transport( feature = "mplex", feature = "yamux" ))] -#[cfg_attr( - docsrs, - doc(cfg(all( - not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")), - any( - all(feature = "tcp-tokio", feature = "dns-tokio"), - all(feature = "tcp", feature = "dns", feature = "tokio") - ), - feature = "websocket", - feature = "noise", - feature = "mplex", - feature = "yamux" - ))) -)] #[cfg_attr( all( any(feature = "tcp-tokio", feature = "dns-tokio"), diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index baab666b0eb..622e23f5c09 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -23,3 +23,10 @@ libp2p = { path = "..", features = ["full"] } either = "1.6.0" futures = "0.3.1" void = "1" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/swarm-derive/src/lib.rs b/swarm-derive/src/lib.rs index 426e4faec1f..a23028579ee 100644 --- a/swarm-derive/src/lib.rs +++ b/swarm-derive/src/lib.rs @@ -19,6 +19,7 @@ // DEALINGS IN THE SOFTWARE. #![recursion_limit = "256"] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] use heck::ToUpperCamelCase; use proc_macro::TokenStream; diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index adbb81cd70e..bf3fb3fe503 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -29,3 +29,10 @@ async-std = { version = "1.6.2", features = ["attributes"] } env_logger = "0.9" libp2p = { path = "..", features = ["full"] } quickcheck = { package = "quickcheck-ext", path = "../misc/quickcheck-ext" } + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 3979bcfecba..5acdd15aa7b 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -53,6 +53,8 @@ //! are supported, when to open a new outbound substream, etc. //! +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + mod connection; mod registry; #[cfg(test)] diff --git a/transports/deflate/Cargo.toml b/transports/deflate/Cargo.toml index bbb1e124771..999db9f8b30 100644 --- a/transports/deflate/Cargo.toml +++ b/transports/deflate/Cargo.toml @@ -20,3 +20,10 @@ async-std = "1.6.2" libp2p = { path = "../..", features = ["full"] } quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" } rand = "0.8" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/transports/deflate/src/lib.rs b/transports/deflate/src/lib.rs index 698b6cab6a9..29be83462b9 100644 --- a/transports/deflate/src/lib.rs +++ b/transports/deflate/src/lib.rs @@ -18,6 +18,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + use futures::{prelude::*, ready}; use libp2p_core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use std::{io, iter, pin::Pin, task::Context, task::Poll}; diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index a17b64b705c..0bd9afa3644 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -32,3 +32,10 @@ tokio = ["trust-dns-resolver/tokio-runtime"] # available for `tokio`. tokio-dns-over-rustls = ["tokio", "trust-dns-resolver/dns-over-rustls"] tokio-dns-over-https-rustls = ["tokio", "trust-dns-resolver/dns-over-https-rustls"] + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/transports/dns/src/lib.rs b/transports/dns/src/lib.rs index 1b9bb199200..99ae2d151de 100644 --- a/transports/dns/src/lib.rs +++ b/transports/dns/src/lib.rs @@ -54,6 +54,8 @@ //! //![trust-dns-resolver]: https://docs.rs/trust-dns-resolver/latest/trust_dns_resolver/#dns-over-tls-and-dns-over-https +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + #[cfg(feature = "async-std")] use async_std_resolver::{AsyncStdConnection, AsyncStdConnectionProvider}; use futures::{future::BoxFuture, prelude::*}; diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index cb75bb7ebe9..3dd07ee82de 100644 --- a/transports/noise/Cargo.toml +++ b/transports/noise/Cargo.toml @@ -38,3 +38,10 @@ ed25519-compact = "2.0.2" [build-dependencies] prost-build = "0.11" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/transports/noise/src/lib.rs b/transports/noise/src/lib.rs index ac341c2802d..d710e163ae2 100644 --- a/transports/noise/src/lib.rs +++ b/transports/noise/src/lib.rs @@ -53,6 +53,8 @@ //! //! [noise]: http://noiseprotocol.org/ +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + mod error; mod io; mod protocol; diff --git a/transports/plaintext/Cargo.toml b/transports/plaintext/Cargo.toml index 1af9894d371..7c2051d2364 100644 --- a/transports/plaintext/Cargo.toml +++ b/transports/plaintext/Cargo.toml @@ -27,3 +27,10 @@ rand = "0.8" [build-dependencies] prost-build = "0.11" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/transports/plaintext/src/lib.rs b/transports/plaintext/src/lib.rs index 9855a3297b3..da5674b6497 100644 --- a/transports/plaintext/src/lib.rs +++ b/transports/plaintext/src/lib.rs @@ -18,6 +18,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + use crate::error::PlainTextError; use bytes::Bytes; diff --git a/transports/pnet/Cargo.toml b/transports/pnet/Cargo.toml index 3bd3f3689df..edeb4ee8508 100644 --- a/transports/pnet/Cargo.toml +++ b/transports/pnet/Cargo.toml @@ -20,3 +20,10 @@ pin-project = "1.0.2" [dev-dependencies] quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" } + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/transports/pnet/src/lib.rs b/transports/pnet/src/lib.rs index 8560171682e..5a54cf37496 100644 --- a/transports/pnet/src/lib.rs +++ b/transports/pnet/src/lib.rs @@ -23,6 +23,9 @@ //! //! Libp2p nodes configured with a pre-shared key can only communicate with other nodes with //! the same key. + +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + mod crypt_writer; use crypt_writer::CryptWriter; use futures::prelude::*; diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 06517a84f67..6cf164d52cf 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -29,3 +29,10 @@ async-io = ["async-io-crate"] async-std = { version = "1.6.5", features = ["attributes"] } tokio-crate = { package = "tokio", version = "1.0.1", default-features = false, features = ["net", "rt", "macros"] } env_logger = "0.9.0" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/transports/tcp/src/lib.rs b/transports/tcp/src/lib.rs index bf75107982b..c4a1f7a350a 100644 --- a/transports/tcp/src/lib.rs +++ b/transports/tcp/src/lib.rs @@ -26,6 +26,8 @@ //! the enabled features, which implement the `Transport` trait for use as a //! transport with `libp2p-core` or `libp2p-swarm`. +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + mod provider; use if_watch::{IfEvent, IfWatcher}; diff --git a/transports/uds/Cargo.toml b/transports/uds/Cargo.toml index e9483f503d1..5ec9ba8c46a 100644 --- a/transports/uds/Cargo.toml +++ b/transports/uds/Cargo.toml @@ -19,3 +19,10 @@ tokio = { version = "1.15", default-features = false, features = ["net"], option [target.'cfg(all(unix, not(target_os = "emscripten")))'.dev-dependencies] tempfile = "3.0" + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/transports/uds/src/lib.rs b/transports/uds/src/lib.rs index 71e6c094013..5f3f9ab7265 100644 --- a/transports/uds/src/lib.rs +++ b/transports/uds/src/lib.rs @@ -36,7 +36,7 @@ not(target_os = "emscripten"), any(feature = "tokio", feature = "async-std") ))] -#![cfg_attr(docsrs, doc(cfg(all(unix, not(target_os = "emscripten")))))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] use futures::stream::BoxStream; use futures::{ @@ -66,7 +66,6 @@ pub type Listener = BoxStream< macro_rules! codegen { ($feature_name:expr, $uds_config:ident, $build_listener:expr, $unix_stream:ty, $($mut_or_not:tt)*) => { /// Represents the configuration for a Unix domain sockets transport capability for libp2p. - #[cfg_attr(docsrs, doc(cfg(feature = $feature_name)))] pub struct $uds_config { listeners: VecDeque<(ListenerId, Listener)>, } diff --git a/transports/wasm-ext/Cargo.toml b/transports/wasm-ext/Cargo.toml index b4f290e7676..50ea584c3cd 100644 --- a/transports/wasm-ext/Cargo.toml +++ b/transports/wasm-ext/Cargo.toml @@ -20,3 +20,10 @@ wasm-bindgen-futures = "0.4.4" [features] websocket = [] + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/transports/wasm-ext/src/lib.rs b/transports/wasm-ext/src/lib.rs index bb1e3ea0653..5ed34f41a94 100644 --- a/transports/wasm-ext/src/lib.rs +++ b/transports/wasm-ext/src/lib.rs @@ -32,6 +32,8 @@ //! module. //! +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + use futures::{future::Ready, prelude::*, ready, stream::SelectAll}; use libp2p_core::{ connection::Endpoint, diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index 5402af48c6f..078fd7486d8 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -25,3 +25,10 @@ webpki-roots = "0.22" [dev-dependencies] libp2p = { path = "../..", features = ["full"] } + +# Passing arguments to the docsrs builder in order to properly document cfg's. +# More information: https://docs.rs/about/builds#cross-compiling +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +rustc-args = ["--cfg", "docsrs"] diff --git a/transports/websocket/src/lib.rs b/transports/websocket/src/lib.rs index 721f9c92848..0dc529ffec6 100644 --- a/transports/websocket/src/lib.rs +++ b/transports/websocket/src/lib.rs @@ -20,6 +20,8 @@ //! Implementation of the libp2p `Transport` trait for Websockets. +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + pub mod error; pub mod framed; pub mod tls;