diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index d1117989c4..9e56e0ea96 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -12,8 +12,16 @@ jobs: steps: - uses: actions/checkout@v3 + # Right now the doc_cfg and auto_doc_cfg features require nightly + - name: Install latest nightly + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: true - name: Build documentation - run: cargo doc --verbose + run: cargo +nightly doc --verbose --all-features + env: + RUSTDOCFLAGS: --cfg docsrs - name: Deploy documentation uses: peaceiris/actions-gh-pages@v3 with: diff --git a/Cargo.toml b/Cargo.toml index a35832722d..08fd5bdcb6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,10 @@ std = [ ] vi = ["syntect"] +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [workspace] members = [ "examples/*", diff --git a/src/lib.rs b/src/lib.rs index 1f82538661..41d59804e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,6 +54,11 @@ //! }); //! ``` +// If the docsrs feature is enabled, use nightly documentation features. +// +// This can be locally tested using RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --all-features +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + // Not interested in these lints #![allow(clippy::new_without_default)] // TODO: address occurrences and then deny