Skip to content

Use doc_auto_cfg to show feature requirements on docs.rs #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2022

Conversation

nicholasbishop
Copy link
Member

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

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.

rust-osdev#486
@nicholasbishop
Copy link
Member Author

Merging since I want to include this in #488. Low-risk change since it should only affect anything on docs.rs.

@nicholasbishop nicholasbishop merged commit 9924472 into rust-osdev:main Aug 26, 2022
@nicholasbishop nicholasbishop deleted the bishop-rdoc-features branch August 26, 2022 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant