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 mark feature-gated functionality in docs #662

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 error;
Expand Down Expand Up @@ -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<Octocrab> {
STATIC_INSTANCE.swap(Arc::from(crab))
}
Expand All @@ -351,6 +353,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 @@ -500,27 +503,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 @@ -582,6 +589,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, String>,
Expand All @@ -592,6 +600,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 @@ -609,6 +618,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<_, String> = {
#[cfg(all(not(feature = "opentls"), not(feature = "rustls")))]
Expand Down Expand Up @@ -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()
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;
Loading