diff --git a/Cargo.toml b/Cargo.toml index 5a7b5051..60148afa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,11 @@ exclude = [ ] categories = ["web-programming", "encoding", "data-structures"] +# Enable all features when building on docs.rs to show feature gated bindings +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [lib] name = "cloudevents" diff --git a/src/binding/mod.rs b/src/binding/mod.rs index 282008e8..abb0388a 100644 --- a/src/binding/mod.rs +++ b/src/binding/mod.rs @@ -1,9 +1,23 @@ //! Provides protocol binding implementations for [`crate::Event`]. +#[cfg_attr(docsrs, doc(cfg(feature = "actix")))] #[cfg(feature = "actix")] pub mod actix; +#[cfg_attr(docsrs, doc(cfg(feature = "axum")))] #[cfg(feature = "axum")] pub mod axum; + +#[cfg_attr( + docsrs, + doc(cfg(any( + feature = "http-binding", + feature = "actix", + feature = "warp", + feature = "reqwest", + feature = "axum", + feature = "poem" + ))) +)] #[cfg(any( feature = "http-binding", feature = "actix", @@ -13,14 +27,19 @@ pub mod axum; feature = "poem" ))] pub mod http; +#[cfg_attr(docsrs, doc(cfg(feature = "nats")))] #[cfg(feature = "nats")] pub mod nats; +#[cfg_attr(docsrs, doc(cfg(feature = "poem")))] #[cfg(feature = "poem")] pub mod poem; +#[cfg_attr(docsrs, doc(cfg(feature = "rdkafka")))] #[cfg(feature = "rdkafka")] pub mod rdkafka; +#[cfg_attr(docsrs, doc(cfg(feature = "reqwest")))] #[cfg(feature = "reqwest")] pub mod reqwest; +#[cfg_attr(docsrs, doc(cfg(feature = "warp")))] #[cfg(feature = "warp")] pub mod warp; diff --git a/src/lib.rs b/src/lib.rs index a1837528..4f2a6de8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,6 +56,7 @@ #![doc(html_root_url = "https://docs.rs/cloudevents-sdk/0.5.0")] #![deny(rustdoc::broken_intra_doc_links)] +#![cfg_attr(docsrs, feature(doc_cfg))] // Show feature gate in doc pub mod binding; pub mod event;