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.

https://github.com/rust-osdev/uefi-rs/issues/486
This commit is contained in:
Nicholas Bishop 2022-08-25 23:14:49 -04:00
parent 08ddf18ae0
commit 99244728cd
2 changed files with 2 additions and 0 deletions

View file

@ -49,3 +49,4 @@ uefi = { path = "." }
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]