Skip to content

Commit 5ff5cec

Browse files
committed
docs: use doc(cfg) to display which methods are unstable
1 parent 5424ecb commit 5ff5cec

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ fn main() -> Result<(), Box<dyn Error>> {
99
let output = std::env::var("OUT_DIR")?;
1010
::std::fs::write(format!("{}/target", output), target.as_bytes())?;
1111

12+
println!("cargo:rerun-if-env-changed=DOCS_RS");
13+
if std::env::var_os("DOCS_RS").as_deref() == Some(std::ffi::OsStr::new("1")) {
14+
println!("cargo:rustc-cfg=docs_rs");
15+
}
16+
1217
Ok(())
1318
}

src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#![warn(missing_docs)]
22
#![allow(clippy::new_without_default)]
33

4+
#![cfg_attr(docs_rs, feature(doc_cfg))]
5+
46
//! Rustwide is a library to execute your code on the Rust ecosystem, powering projects like
57
//! [Crater][crater] and [docs.rs][docsrs].
68
//!
7-
//! Rustwide uses feature flags to enable or disable parts of its code at compile time. The
8-
//! available flags are:
9+
//! ## Feature flags
10+
//!
11+
//! Rustwide provides some optional features that can be enabled with Cargo:
912
//!
1013
//! * **unstable**: allow Rustwide to use unstable Rust and Cargo features. While this feature also
1114
//! works on Rust stable it might cause Rustwide to break, and **no stability guarantee is

src/workspace.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,8 @@ impl WorkspaceBuilder {
101101
/// to build a lot of crates in a batch, but having the option disabled might cause trouble if
102102
/// you need to build recently published crates, as they might be missing from the cached
103103
/// index.
104-
///
105-
/// **To call this method the `unstable` rustwide feature flag needs to be enabled**, as it
106-
/// relies on unstable Cargo features.
107-
#[cfg(feature = "unstable")]
104+
#[cfg(any(feature = "unstable", doc))]
105+
#[cfg_attr(docs_rs, doc(cfg(feature = "unstable")))]
108106
pub fn fetch_registry_index_during_builds(mut self, enable: bool) -> Self {
109107
self.fetch_registry_index_during_builds = enable;
110108
self

0 commit comments

Comments
 (0)