Skip to content

Commit ac2a3b4

Browse files
committed
experiment doccfg with attr docrs
1 parent 3d8da96 commit ac2a3b4

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,5 @@ jobs:
143143
toolchain: nightly
144144
targets: x86_64-unknown-linux-gnu, aarch64-apple-darwin, aarch64-apple-ios, x86_64-pc-windows-msvc
145145

146-
- name: docs bulid check
146+
- name: docs build check
147147
run: bash build-xplat-docs.sh

build-xplat-docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ TARGETS=(
99
)
1010

1111
for TARGET in "${TARGETS[@]}"; do
12-
cargo +nightly doc --no-deps --features "$FEATURES" --target "$TARGET" -Zbuild-std $OPEN_DOCS
12+
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --no-deps --features "$FEATURES" --target "$TARGET" -Zbuild-std $OPEN_DOCS
1313
done

src/lib.rs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(doc_cfg)]
1+
#![cfg_attr(docsrs, feature(doc_cfg))]
22
/*!
33
44
# Keyring
@@ -204,11 +204,8 @@ compile_error!("This crate cannot use both the sync and async versions of any cr
204204
//
205205
// pick the *nix keystore
206206
//
207-
#[cfg(any(
208-
all(target_os = "linux", feature = "linux-native"),
209-
all(target_os = "linux", feature = "linux-native-sync-persistent", doc)
210-
))]
211-
#[doc(cfg(all(target_os = "linux")))]
207+
#[cfg(all(target_os = "linux", feature = "linux-native"))]
208+
#[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
212209
pub mod keyutils;
213210
#[cfg(all(
214211
target_os = "linux",
@@ -218,14 +215,14 @@ pub mod keyutils;
218215
))]
219216
pub use keyutils as default;
220217

221-
#[cfg(any(
222-
all(
223-
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
224-
any(feature = "sync-secret-service", feature = "async-secret-service"),
225-
),
226-
all(target_os = "linux", feature = "linux-native-sync-persistent", doc),
218+
#[cfg(all(
219+
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
220+
any(feature = "sync-secret-service", feature = "async-secret-service"),
227221
))]
228-
#[doc(cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")))]
222+
#[cfg_attr(
223+
docsrs,
224+
doc(cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")))
225+
)]
229226
pub mod secret_service;
230227
#[cfg(all(
231228
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
@@ -237,17 +234,14 @@ pub mod secret_service;
237234
))]
238235
pub use secret_service as default;
239236

240-
#[cfg(any(
241-
all(
242-
target_os = "linux",
243-
any(
244-
feature = "linux-native-sync-persistent",
245-
feature = "linux-native-async-persistent",
246-
)
247-
),
248-
all(target_os = "linux", feature = "linux-native-sync-persistent", doc),
237+
#[cfg(all(
238+
target_os = "linux",
239+
any(
240+
feature = "linux-native-sync-persistent",
241+
feature = "linux-native-async-persistent",
242+
)
249243
))]
250-
#[doc(cfg(all(target_os = "linux")))]
244+
#[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
251245
pub mod keyutils_persistent;
252246
#[cfg(all(
253247
target_os = "linux",
@@ -278,15 +272,15 @@ pub use mock as default;
278272
// pick the Apple keystore
279273
//
280274
#[cfg(all(target_os = "macos", feature = "apple-native"))]
281-
#[doc(cfg(all(target_os = "macos")))]
275+
#[cfg_attr(docsrs, doc(cfg(target_os = "macos")))]
282276
pub mod macos;
283277
#[cfg(all(target_os = "macos", feature = "apple-native"))]
284278
pub use macos as default;
285279
#[cfg(all(target_os = "macos", not(feature = "apple-native")))]
286280
pub use mock as default;
287281

288282
#[cfg(all(target_os = "ios", feature = "apple-native"))]
289-
#[doc(cfg(all(target_os = "ios")))]
283+
#[cfg_attr(docsrs, doc(cfg(target_os = "ios")))]
290284
pub mod ios;
291285
#[cfg(all(target_os = "ios", feature = "apple-native"))]
292286
pub use ios as default;
@@ -297,7 +291,7 @@ pub use mock as default;
297291
// pick the Windows keystore
298292
//
299293
#[cfg(all(target_os = "windows", feature = "windows-native"))]
300-
#[doc(cfg(all(target_os = "windows")))]
294+
#[cfg_attr(docsrs, doc(cfg(target_os = "windows")))]
301295
pub mod windows;
302296
#[cfg(all(target_os = "windows", not(feature = "windows-native")))]
303297
pub use mock as default;

0 commit comments

Comments
 (0)