Skip to content

Commit 9924472

Browse files
Use doc_auto_cfg to show feature requirements on docs.rs
Add a `docsrs` config in the `docs.rs` metadata in Cargo.toml. This will set `--cfg docsrs` when building on docs.rs. Enable the `doc_auto_cfg` feature when the `docsrs` config is enabled. This feature is currently unstable, but docs.rs uses a nightly compiler so this works fine. The effect of this is that docs.rs will show a badge for items that are only available if some feature is enabled. For example, `BootServices::find_handles` will have a badge saying "Available on crate feature exts only." To view this locally, run this: ``` RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --all-features --open ``` This change has only been applied to the `uefi` package, since the `uefi-macros` package does not have any features and the `uefi-services` package's features don't control the visiblity of any public items. #486
1 parent 08ddf18 commit 9924472

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ uefi = { path = "." }
4949

5050
[package.metadata.docs.rs]
5151
all-features = true
52+
rustdoc-args = ["--cfg", "docsrs"]

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#![feature(negative_impls)]
3030
#![feature(ptr_metadata)]
3131
#![cfg_attr(feature = "exts", feature(vec_into_raw_parts))]
32+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
3233
#![no_std]
3334
// Enable some additional warnings and lints.
3435
#![warn(clippy::ptr_as_ptr, missing_docs, unused)]

0 commit comments

Comments
 (0)