Skip to content

Commit

Permalink
lib: enable doc_auto_cfg for docs.rs
Browse files Browse the repository at this point in the history
The upstream `docs.rs` website uses the nightly release of the Rust
compiler when building project docs. That means we can opt in to the
`doc_auto_cfg` feature to have documentation items automatically mention
the required crate features where appropriate.

This has the advantages of:

* Using a nice styled UI element for the requirements.
* Keeping the feature requirements in-sync with the docs automatically.

Since this feature requires the nightly toolchain we customize the CI
environment so that it is enabled only for the nightly channel.

[0]: https://docs.rs/about/builds
  • Loading branch information
cpu committed Sep 11, 2023
1 parent 9e9701c commit 06f0a5f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: cargo doc (all features)
run: cargo doc --all --all-features --document-private-items
env:
RUSTDOCFLAGS: '-Dwarnings'
RUSTDOCFLAGS: ${{ matrix.rust_channel == 'nightly' && '-Dwarnings --cfg=docsrs' || '-Dwarnings' }}

build-windows:
runs-on: windows-latest
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ println!("{}", cert.serialize_private_key_pem());
#![forbid(non_ascii_idents)]
#![deny(missing_docs)]
#![allow(clippy::complexity, clippy::style, clippy::pedantic)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

#[cfg(feature = "pem")]
use pem::Pem;
Expand Down

0 comments on commit 06f0a5f

Please sign in to comment.