Skip to content

Commit f1b7ec1

Browse files
Merge pull request #237 from unkcpz/fix/235/keyring-doc-xplat
doc: cross-platform with target tags Fixes #235.
2 parents 779dfe0 + 09c9c0d commit f1b7ec1

File tree

5 files changed

+52
-12
lines changed

5 files changed

+52
-12
lines changed

.github/workflows/doctest.yaml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Docs Build
2+
3+
on: [ workflow_dispatch, pull_request ]
4+
5+
jobs:
6+
doc_build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
target:
11+
- x86_64-unknown-linux-gnu
12+
- aarch64-apple-darwin
13+
- aarch64-apple-ios
14+
- x86_64-pc-windows-msvc
15+
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v4
19+
20+
- name: Install dependencies (linux only)
21+
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }}
22+
run: |
23+
sudo apt-get update
24+
sudo apt-get install -y libdbus-1-dev pkg-config
25+
26+
- name: Install Rust nightly
27+
uses: actions-rust-lang/setup-rust-toolchain@v1
28+
with:
29+
target: ${{ matrix.target }}
30+
toolchain: nightly
31+
components: rust-src
32+
33+
- name: Build docs
34+
run: |
35+
FEATURES="apple-native, windows-native, linux-native-sync-persistent, crypto-rust"
36+
RUSTDOCFLAGS="--cfg docsrs" \
37+
cargo +nightly doc --no-deps --features "$FEATURES" --target ${{ matrix.target }} -Zbuild-std
38+

Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,6 @@ rprompt = "2"
7777
whoami = "1.5"
7878

7979
[package.metadata.docs.rs]
80-
features = ["apple-native", "windows-native", "sync-secret-service", "crypto-rust"]
80+
default-target = "x86_64-unknown-linux-gnu"
81+
targets = ["x86_64-unknown-linux-gnu", "aarch64-apple-darwin", "aarch64-apple-ios", "x86_64-pc-windows-msvc"]
82+
features = ["apple-native", "windows-native", "linux-native-sync-persistent", "crypto-rust"]

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ Thanks to the following for helping make this library better, whether through co
142142
- @Sytten
143143
- @thewh1teagle
144144
- @tmpfs
145+
- @unkcpz
145146
- @VorpalBlade
146147
- @zschreur
147148

build-xplat-docs.sh

-11
This file was deleted.

src/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg_attr(docsrs, feature(doc_cfg))]
12
/*!
23
34
# Keyring
@@ -204,6 +205,7 @@ compile_error!("This crate cannot use both the sync and async versions of any cr
204205
// pick the *nix keystore
205206
//
206207
#[cfg(all(target_os = "linux", feature = "linux-native"))]
208+
#[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
207209
pub mod keyutils;
208210
#[cfg(all(
209211
target_os = "linux",
@@ -217,6 +219,10 @@ pub use keyutils as default;
217219
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
218220
any(feature = "sync-secret-service", feature = "async-secret-service"),
219221
))]
222+
#[cfg_attr(
223+
docsrs,
224+
doc(cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")))
225+
)]
220226
pub mod secret_service;
221227
#[cfg(all(
222228
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
@@ -235,6 +241,7 @@ pub use secret_service as default;
235241
feature = "linux-native-async-persistent",
236242
)
237243
))]
244+
#[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
238245
pub mod keyutils_persistent;
239246
#[cfg(all(
240247
target_os = "linux",
@@ -265,13 +272,15 @@ pub use mock as default;
265272
// pick the Apple keystore
266273
//
267274
#[cfg(all(target_os = "macos", feature = "apple-native"))]
275+
#[cfg_attr(docsrs, doc(cfg(target_os = "macos")))]
268276
pub mod macos;
269277
#[cfg(all(target_os = "macos", feature = "apple-native"))]
270278
pub use macos as default;
271279
#[cfg(all(target_os = "macos", not(feature = "apple-native")))]
272280
pub use mock as default;
273281

274282
#[cfg(all(target_os = "ios", feature = "apple-native"))]
283+
#[cfg_attr(docsrs, doc(cfg(target_os = "ios")))]
275284
pub mod ios;
276285
#[cfg(all(target_os = "ios", feature = "apple-native"))]
277286
pub use ios as default;
@@ -282,6 +291,7 @@ pub use mock as default;
282291
// pick the Windows keystore
283292
//
284293
#[cfg(all(target_os = "windows", feature = "windows-native"))]
294+
#[cfg_attr(docsrs, doc(cfg(target_os = "windows")))]
285295
pub mod windows;
286296
#[cfg(all(target_os = "windows", not(feature = "windows-native")))]
287297
pub use mock as default;

0 commit comments

Comments
 (0)