Skip to content

Commit c7d6fec

Browse files
committed
lib: enable doc_auto_cfg for docs.rs
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
1 parent 6c464b5 commit c7d6fec

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
- name: cargo doc (all features)
5959
run: cargo doc --all --all-features --document-private-items
6060
env:
61-
RUSTDOCFLAGS: '-Dwarnings'
61+
RUSTDOCFLAGS: ${{ matrix.rust_channel == 'nightly' && '-Dwarnings --cfg=docsrs' || '-Dwarnings' }}
6262

6363
build-windows:
6464
runs-on: windows-latest

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ println!("{}", cert.serialize_private_key_pem());
2929
#![forbid(non_ascii_idents)]
3030
#![deny(missing_docs)]
3131
#![allow(clippy::complexity, clippy::style, clippy::pedantic)]
32+
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
3233

3334
#[cfg(feature = "pem")]
3435
use pem::Pem;

0 commit comments

Comments
 (0)