Skip to content

Commit 27b5172

Browse files
authored
Merge pull request #200 from rust-random/doc_feature
Use doc_cfg to improve register_custom_getrandom docs
2 parents 9a48bfa + d7a0d58 commit 27b5172

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: actions-rs/toolchain@v1
2222
with:
2323
profile: minimal
24-
toolchain: nightly # Needed for -Z minimal-versions
24+
toolchain: nightly # Needed for -Z minimal-versions and doc_cfg
2525
override: true
2626
- uses: Swatinem/rust-cache@v1
2727
- name: Install precompiled cargo-deadlinks
@@ -30,7 +30,10 @@ jobs:
3030
wget -O /tmp/cargo-deadlinks $URL
3131
chmod +x /tmp/cargo-deadlinks
3232
mv /tmp/cargo-deadlinks ~/.cargo/bin
33-
- run: cargo deadlinks -- --features=custom,std
33+
- name: Generate Docs
34+
env:
35+
RUSTDOCFLAGS: --cfg docsrs
36+
run: cargo deadlinks -- --features=custom,std
3437
- run: |
3538
cargo generate-lockfile -Z minimal-versions
3639
cargo test --features=custom,std

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ test-in-browser = []
5050

5151
[package.metadata.docs.rs]
5252
features = ["std", "custom"]
53+
rustdoc-args = ["--cfg", "docsrs"]

src/custom.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ use core::num::NonZeroU32;
1212

1313
/// Register a function to be invoked by `getrandom` on unsupported targets.
1414
///
15-
/// *This API requires the `"custom"` Cargo feature to be activated*.
16-
///
1715
/// ## Writing a custom `getrandom` implementation
1816
///
1917
/// The function to register must have the same signature as
@@ -75,6 +73,7 @@ use core::num::NonZeroU32;
7573
/// [top-level documentation](index.html#custom-implementations) this
7674
/// registration only has an effect on unsupported targets.
7775
#[macro_export]
76+
#[cfg_attr(docsrs, doc(cfg(feature = "custom")))]
7877
macro_rules! register_custom_getrandom {
7978
($path:path) => {
8079
// We use an extern "C" function to get the guarantees of a stable ABI.

src/error_impls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
8+
#![cfg_attr(docsrs, doc(cfg(feature = "std")))]
89
extern crate std;
910

1011
use crate::Error;

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
)]
147147
#![no_std]
148148
#![warn(rust_2018_idioms, unused_lifetimes, missing_docs)]
149+
#![cfg_attr(docsrs, feature(doc_cfg))]
149150

150151
#[macro_use]
151152
extern crate cfg_if;

0 commit comments

Comments
 (0)