From 141dc825e65fb63a92b3c1431a14fbb1a18463d7 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Mon, 8 Jul 2024 17:08:00 -0400 Subject: [PATCH] Properly mark feature-gated functionality in docs --- Cargo.toml | 2 ++ src/lib.rs | 11 +++++++++++ src/service/middleware/mod.rs | 1 + 3 files changed, 14 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 80841995..885fc2c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,8 @@ keywords = ["github", "github-api"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] targets = ["x86_64-unknown-linux-gnu"] [dependencies] diff --git a/src/lib.rs b/src/lib.rs index 8051cc17..a1a241a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -179,6 +179,7 @@ //! }; //! ``` #![cfg_attr(test, recursion_limit = "512")] +#![cfg_attr(docsrs, feature(doc_cfg))] mod api; mod error; @@ -338,6 +339,7 @@ pub async fn map_github_error( /// # } /// ``` #[cfg(feature = "default-client")] +#[cfg_attr(docsrs, doc(cfg(feature = "default-client")))] pub fn initialise(crab: Octocrab) -> Arc { STATIC_INSTANCE.swap(Arc::from(crab)) } @@ -351,6 +353,7 @@ pub fn initialise(crab: Octocrab) -> Arc { /// } /// ``` #[cfg(feature = "default-client")] +#[cfg_attr(docsrs, doc(cfg(feature = "default-client")))] pub fn instance() -> Arc { STATIC_INSTANCE.load().clone() } @@ -500,6 +503,7 @@ impl OctocrabBuilder { impl OctocrabBuilder { /// Set the retry configuration #[cfg(feature = "retry")] + #[cfg_attr(docsrs, doc(cfg(feature = "retry")))] pub fn add_retry_config(mut self, retry_config: RetryConfig) -> Self { self.config.retry_config = retry_config; self @@ -507,6 +511,7 @@ impl OctocrabBuilder /// Set the connect timeout. #[cfg(feature = "timeout")] + #[cfg_attr(docsrs, doc(cfg(feature = "timeout")))] pub fn set_connect_timeout(mut self, timeout: Option) -> Self { self.config.connect_timeout = timeout; self @@ -514,6 +519,7 @@ impl OctocrabBuilder /// Set the read timeout. #[cfg(feature = "timeout")] + #[cfg_attr(docsrs, doc(cfg(feature = "timeout")))] pub fn set_read_timeout(mut self, timeout: Option) -> Self { self.config.read_timeout = timeout; self @@ -521,6 +527,7 @@ impl OctocrabBuilder /// Set the write timeout. #[cfg(feature = "timeout")] + #[cfg_attr(docsrs, doc(cfg(feature = "timeout")))] pub fn set_write_timeout(mut self, timeout: Option) -> Self { self.config.write_timeout = timeout; self @@ -582,6 +589,7 @@ impl OctocrabBuilder } #[cfg(feature = "retry")] + #[cfg_attr(docsrs, doc(cfg(feature = "retry")))] pub fn set_connector_retry_service( &self, connector: hyper_util::client::legacy::Client, @@ -592,6 +600,7 @@ impl OctocrabBuilder } #[cfg(feature = "timeout")] + #[cfg_attr(docsrs, doc(cfg(feature = "timeout")))] pub fn set_connect_timeout_service(&self, connector: T) -> TimeoutConnector where T: Service + Send, @@ -609,6 +618,7 @@ impl OctocrabBuilder /// Build a [`Client`] instance with the current [`Service`] stack. #[cfg(feature = "default-client")] + #[cfg_attr(docsrs, doc(cfg(feature = "defaut-client")))] pub fn build(self) -> Result { let client: hyper_util::client::legacy::Client<_, String> = { #[cfg(all(not(feature = "opentls"), not(feature = "rustls")))] @@ -937,6 +947,7 @@ impl fmt::Debug for Octocrab { /// - `auth`: `None` /// - `client`: http client with the `octocrab` user agent. #[cfg(feature = "default-client")] +#[cfg_attr(docsrs, doc(cfg(feature = "default-client")))] impl Default for Octocrab { fn default() -> Self { OctocrabBuilder::default().build().unwrap() diff --git a/src/service/middleware/mod.rs b/src/service/middleware/mod.rs index 7dec247a..c7846da8 100644 --- a/src/service/middleware/mod.rs +++ b/src/service/middleware/mod.rs @@ -2,4 +2,5 @@ pub mod auth_header; pub mod base_uri; pub mod extra_headers; #[cfg(feature = "retry")] +#[cfg_attr(docsrs, doc(cfg(feature = "retry")))] pub mod retry;