Skip to content

Commit

Permalink
Properly mark feature-gated functionality in docs (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder authored Jul 29, 2024
1 parent 66b90cb commit 60a89c6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
//! };
//! ```
#![cfg_attr(test, recursion_limit = "512")]
#![cfg_attr(docsrs, feature(doc_cfg))]

mod api;
mod body;
Expand Down Expand Up @@ -341,6 +342,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<Octocrab> {
STATIC_INSTANCE.swap(Arc::from(crab))
}
Expand All @@ -354,6 +356,7 @@ pub fn initialise(crab: Octocrab) -> Arc<Octocrab> {
/// }
/// ```
#[cfg(feature = "default-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "default-client")))]
pub fn instance() -> Arc<Octocrab> {
STATIC_INSTANCE.load().clone()
}
Expand Down Expand Up @@ -503,27 +506,31 @@ impl<Svc, Config, LayerState> OctocrabBuilder<Svc, Config, NoAuth, LayerState> {
impl OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady> {
/// 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
}

/// Set the connect timeout.
#[cfg(feature = "timeout")]
#[cfg_attr(docsrs, doc(cfg(feature = "timeout")))]
pub fn set_connect_timeout(mut self, timeout: Option<Duration>) -> Self {
self.config.connect_timeout = timeout;
self
}

/// Set the read timeout.
#[cfg(feature = "timeout")]
#[cfg_attr(docsrs, doc(cfg(feature = "timeout")))]
pub fn set_read_timeout(mut self, timeout: Option<Duration>) -> Self {
self.config.read_timeout = timeout;
self
}

/// Set the write timeout.
#[cfg(feature = "timeout")]
#[cfg_attr(docsrs, doc(cfg(feature = "timeout")))]
pub fn set_write_timeout(mut self, timeout: Option<Duration>) -> Self {
self.config.write_timeout = timeout;
self
Expand Down Expand Up @@ -596,6 +603,7 @@ impl OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>
}

#[cfg(feature = "retry")]
#[cfg_attr(docsrs, doc(cfg(feature = "retry")))]
pub fn set_connector_retry_service<S>(
&self,
connector: hyper_util::client::legacy::Client<S, OctoBody>,
Expand All @@ -606,6 +614,7 @@ impl OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>
}

#[cfg(feature = "timeout")]
#[cfg_attr(docsrs, doc(cfg(feature = "timeout")))]
pub fn set_connect_timeout_service<T>(&self, connector: T) -> TimeoutConnector<T>
where
T: Service<Uri> + Send,
Expand All @@ -623,6 +632,7 @@ impl OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>

/// 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<Octocrab> {
let client: hyper_util::client::legacy::Client<_, OctoBody> = {
#[cfg(all(not(feature = "opentls"), not(feature = "rustls")))]
Expand Down Expand Up @@ -959,6 +969,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()
Expand Down
1 change: 1 addition & 0 deletions src/service/middleware/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 60a89c6

Please sign in to comment.