From 263c5ab665004b6b788c876c69fc66a54de69792 Mon Sep 17 00:00:00 2001 From: Boshen Date: Sun, 31 Mar 2024 16:38:30 +0800 Subject: [PATCH] docs: document feature flags --- .github/workflows/ci.yml | 2 +- Cargo.lock | 16 ++++++++++++++++ Cargo.toml | 8 +++++++- justfile | 4 ++++ src/lib.rs | 3 +++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a5b92d2..b905684a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -195,7 +195,7 @@ jobs: docs: true - name: Run doc - run: RUSTDOCFLAGS='-D warnings' cargo doc --no-deps + run: RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --all-features test: name: Test diff --git a/Cargo.lock b/Cargo.lock index 3f5a4a3e..eb6e0670 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -240,6 +240,15 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "document-features" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95" +dependencies = [ + "litrs", +] + [[package]] name = "dunce" version = "1.0.4" @@ -357,6 +366,12 @@ dependencies = [ "windows-targets 0.52.4", ] +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" + [[package]] name = "lock_api" version = "0.4.11" @@ -490,6 +505,7 @@ dependencies = [ "codspeed-criterion-compat", "criterion", "dashmap", + "document-features", "dunce", "json-strip-comments", "nodejs_package_json", diff --git a/Cargo.toml b/Cargo.toml index 6f4d4f6b..20e066ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -88,6 +88,7 @@ typescript_tsconfig_json = { version = "0.1.4" } nodejs_package_json = { version = "0.2.0" } codspeed-criterion-compat = { version = "2.4.0", default-features = false, optional = true } +document-features = { version = "0.2", optional = true } [dev-dependencies] vfs = "0.12.0" # for testing with in memory file system @@ -97,7 +98,12 @@ normalize-path = { version = "0.2.1" } [features] default = [] -# Enable the PackageJson::raw_json API +## Enables the [PackageJson::raw_json] API, +## which returns the `package.json` with `serde_json::Value`. package_json_raw_json_api = [] # For codspeed benchmark codspeed = ["codspeed-criterion-compat"] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] diff --git a/justfile b/justfile index 9da02821..74e40ca2 100644 --- a/justfile +++ b/justfile @@ -50,6 +50,10 @@ test: lint: cargo clippy -- --deny warnings +# Generate doc +doc: + RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --all-features + # Get code coverage codecov: cargo codecov --html diff --git a/src/lib.rs b/src/lib.rs index 22ca5215..ad4673f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,6 +35,9 @@ //! [cjs]: https://nodejs.org/api/modules.html //! [esm]: https://nodejs.org/api/esm.html //! +//! ## Feature flags +#![doc = document_features::document_features!()] +//! //! ## Example //! //! ```rust,ignore