Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
20 changes: 20 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,23 @@ jobs:

- name: Clippy check
run: cargo clippy --features=linux-native -- -D warnings

doc_build:
runs-on: ubuntu-latest

steps:
- name: Fetch head
uses: actions/checkout@v4

- name: Install rust stable
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
target:
- x86_64-unknown-linux-gnu
- aarch64-apple-darwin
- aarch64-apple-ios
- x86_64-pc-windows-msvc

- name: docs bulid check
run: bash build-xplat-docs.sh
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@ rprompt = "2"
whoami = "1.5"

[package.metadata.docs.rs]
features = ["apple-native", "windows-native", "sync-secret-service", "crypto-rust"]
default-target = "x86_64-unknown-linux-gnu"
targets = ["x86_64-unknown-linux-gnu", "aarch64-apple-darwin", "aarch64-apple-ios", "x86_64-pc-windows-msvc"]
features = ["apple-native", "windows-native", "linux-native-sync-persistent", "crypto-rust"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Thanks to the following for helping make this library better, whether through co
- @Sytten
- @thewh1teagle
- @tmpfs
- @unkcpz
- @VorpalBlade
- @zschreur

Expand Down
22 changes: 12 additions & 10 deletions build-xplat-docs.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/bash
if [[ "$OSTYPE" == "linux"* ]]; then
cargo doc --no-deps --features=linux-native-sync-persistent $OPEN_DOCS
cargo doc --no-deps --features=sync-secret-service $OPEN_DOCS
cargo doc --no-deps --features=linux-native $OPEN_DOCS
elif [[ "$OSTYPE" == "darwin"* ]]; then
cargo doc --no-deps --features=linux-native --target aarch64-unknown-linux-musl $OPEN_DOCS
cargo doc --no-deps --features=windows-native --target aarch64-pc-windows-msvc $OPEN_DOCS
cargo doc --no-deps --features=apple-native --target aarch64-apple-darwin $OPEN_DOCS
cargo doc --no-deps --features=apple-native --target aarch64-apple-ios $OPEN_DOCS
fi

FEATURES="apple-native, windows-native, linux-native-sync-persistent, crypto-rust"
TARGETS=(
"x86_64-unknown-linux-gnu"
"aarch64-apple-darwin"
"aarch64-apple-ios"
"x86_64-pc-windows-msvc"
)

for TARGET in "${TARGETS[@]}"; do
cargo +nightly doc --no-deps --features "$FEATURES" --target "$TARGET" -Zbuild-std $OPEN_DOCS
done
36 changes: 26 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![feature(doc_cfg)]
/*!

# Keyring
Expand Down Expand Up @@ -203,7 +204,11 @@ compile_error!("This crate cannot use both the sync and async versions of any cr
//
// pick the *nix keystore
//
#[cfg(all(target_os = "linux", feature = "linux-native"))]
#[cfg(any(
all(target_os = "linux", feature = "linux-native"),
all(target_os = "linux", feature = "linux-native-sync-persistent", doc)
))]
#[doc(cfg(all(target_os = "linux")))]
pub mod keyutils;
#[cfg(all(
target_os = "linux",
Expand All @@ -213,10 +218,14 @@ pub mod keyutils;
))]
pub use keyutils as default;

#[cfg(all(
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
any(feature = "sync-secret-service", feature = "async-secret-service"),
#[cfg(any(
all(
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
any(feature = "sync-secret-service", feature = "async-secret-service"),
),
all(target_os = "linux", feature = "linux-native-sync-persistent", doc),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like overkill. The linux-native-sync-persistent feature turns on the sync-secret-service feature so all you really need to do is add "doc" to the list of features on line 224.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! simpler after using #[cfg_attr(docsrs, doc(cfg(target_os = "linux")))].

))]
#[doc(cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")))]
pub mod secret_service;
#[cfg(all(
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
Expand All @@ -228,13 +237,17 @@ pub mod secret_service;
))]
pub use secret_service as default;

#[cfg(all(
target_os = "linux",
any(
feature = "linux-native-sync-persistent",
feature = "linux-native-async-persistent",
)
#[cfg(any(
all(
target_os = "linux",
any(
feature = "linux-native-sync-persistent",
feature = "linux-native-async-persistent",
)
),
all(target_os = "linux", feature = "linux-native-sync-persistent", doc),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above, just add "doc" to line 243

))]
#[doc(cfg(all(target_os = "linux")))]
pub mod keyutils_persistent;
#[cfg(all(
target_os = "linux",
Expand Down Expand Up @@ -265,13 +278,15 @@ pub use mock as default;
// pick the Apple keystore
//
#[cfg(all(target_os = "macos", feature = "apple-native"))]
#[doc(cfg(all(target_os = "macos")))]
pub mod macos;
#[cfg(all(target_os = "macos", feature = "apple-native"))]
pub use macos as default;
#[cfg(all(target_os = "macos", not(feature = "apple-native")))]
pub use mock as default;

#[cfg(all(target_os = "ios", feature = "apple-native"))]
#[doc(cfg(all(target_os = "ios")))]
pub mod ios;
#[cfg(all(target_os = "ios", feature = "apple-native"))]
pub use ios as default;
Expand All @@ -282,6 +297,7 @@ pub use mock as default;
// pick the Windows keystore
//
#[cfg(all(target_os = "windows", feature = "windows-native"))]
#[doc(cfg(all(target_os = "windows")))]
pub mod windows;
#[cfg(all(target_os = "windows", not(feature = "windows-native")))]
pub use mock as default;
Expand Down