From fcc64e2cef7d76d05ad444f5b2bfd2721f21036e Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Sat, 7 May 2022 17:03:45 +0200 Subject: [PATCH 1/3] Automatically build documentation for all features --- CHANGELOG.md | 5 +++++ Cargo.toml | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31689c5..eb36c6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed + +- Build [docs.rs] documentation with all features enabled for completeness. + ## [0.2.0] ### Added @@ -61,5 +65,6 @@ Initial release. [0.1.1]: https://github.com/bertptrs/tracing-mutex/compare/v0.1.0...v0.1.1 [0.1.0]: https://github.com/bertptrs/tracing-mutex/releases/tag/v0.1.0 +[docs.rs]: https://docs.rs/tracing-mutex/latest/tracing_mutex/ [lock_api]: https://docs.rs/lock_api/ [parking_lot]: https://docs.rs/parking_lot/ diff --git a/Cargo.toml b/Cargo.toml index 6dca9bd..f8c419a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,10 @@ description = "Ensure deadlock-free mutexes by allocating in order, or else." readme = "README.md" repository = "https://github.com/bertptrs/tracing-mutex" +[package.metadata.docs.rs] +# Build docs for all features so the documentation is more complete +all-features = true + [dependencies] lazy_static = "1" lock_api = { version = "0.4", optional = true } From d1417e0b0c214ba6908e77f4df8abe4367525be6 Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Sat, 7 May 2022 17:43:45 +0200 Subject: [PATCH 2/3] Tag module docs with their required features --- CHANGELOG.md | 7 ++++++- Cargo.toml | 2 ++ src/lib.rs | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb36c6a..a43744c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,15 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -### Fixed +### Added - Build [docs.rs] documentation with all features enabled for completeness. +### Fixed + +- The `parkinglot` module is now correctly enabled by the `parkinglot` feature rather than the + `lockapi` feature. + ## [0.2.0] ### Added diff --git a/Cargo.toml b/Cargo.toml index f8c419a..02ffe44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,8 @@ repository = "https://github.com/bertptrs/tracing-mutex" [package.metadata.docs.rs] # Build docs for all features so the documentation is more complete all-features = true +# Set custom cfg so we can enable docs.rs magic +rustdoc-args = ["--cfg", "docsrs"] [dependencies] lazy_static = "1" diff --git a/src/lib.rs b/src/lib.rs index 2c15a7b..0b6f425 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,6 +45,7 @@ //! enabled, and to the underlying mutex when they're not. //! //! [paper]: https://whileydave.com/publications/pk07_jea/ +#![cfg_attr(docsrs, feature(doc_cfg))] use std::cell::RefCell; use std::cell::UnsafeCell; use std::fmt; @@ -61,16 +62,20 @@ use std::sync::PoisonError; use lazy_static::lazy_static; #[cfg(feature = "lockapi")] +#[cfg_attr(docsrs, doc(cfg(feature = "lockapi")))] pub use lock_api; #[cfg(feature = "parkinglot")] +#[cfg_attr(docsrs, doc(cfg(feature = "parkinglot")))] pub use parking_lot; use crate::graph::DiGraph; mod graph; #[cfg(feature = "lockapi")] +#[cfg_attr(docsrs, doc(cfg(feature = "lockapi")))] pub mod lockapi; -#[cfg(feature = "lockapi")] +#[cfg(feature = "parkinglot")] +#[cfg_attr(docsrs, doc(cfg(feature = "parkinglot")))] pub mod parkinglot; pub mod stdsync; From 0d2622d5c65f8a05f19b55215e6b5ec939cc96be Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Sat, 7 May 2022 17:44:58 +0200 Subject: [PATCH 3/3] Build documentation on CI --- .github/workflows/ci.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0375c09..d3601f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: name: Continuous integration jobs: - ci: + tests: name: Rust project runs-on: ubuntu-latest strategy: @@ -47,3 +47,22 @@ jobs: with: command: clippy args: --all-features --all-targets -- -D warnings + + docs: + name: Documentation build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + + - name: Build documentation + env: + # Build the docs like docs.rs builds it + RUSTDOCFLAGS: --cfg docsrs + run: cargo doc --all-features