From 3989ee992667efef55c665a241d81c2cc347bc2b Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 4 Jan 2024 19:03:11 +0000 Subject: [PATCH] Show feature flags in documentation This can be rendered locally with: RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --no-deps --workspace --all-features --- zcash_client_backend/Cargo.toml | 4 ++++ zcash_client_backend/src/lib.rs | 2 ++ zcash_client_sqlite/Cargo.toml | 4 ++++ zcash_client_sqlite/src/lib.rs | 2 ++ zcash_extensions/Cargo.toml | 4 ++++ zcash_extensions/src/lib.rs | 2 ++ zcash_primitives/Cargo.toml | 1 + zcash_primitives/src/lib.rs | 1 + zcash_primitives/src/transaction/builder.rs | 1 - .../transaction/components/transparent/builder.rs | 1 - zcash_proofs/Cargo.toml | 1 + zcash_proofs/src/lib.rs | 13 +------------ zcash_proofs/src/prover.rs | 2 -- 13 files changed, 22 insertions(+), 16 deletions(-) diff --git a/zcash_client_backend/Cargo.toml b/zcash_client_backend/Cargo.toml index 7b3eae55e..aa39e3285 100644 --- a/zcash_client_backend/Cargo.toml +++ b/zcash_client_backend/Cargo.toml @@ -20,6 +20,10 @@ exclude = ["*.proto"] [package.metadata.cargo-udeps.ignore] development = ["zcash_proofs"] +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [dependencies] zcash_address.workspace = true zcash_encoding.workspace = true diff --git a/zcash_client_backend/src/lib.rs b/zcash_client_backend/src/lib.rs index 486ca7d47..a5f986beb 100644 --- a/zcash_client_backend/src/lib.rs +++ b/zcash_client_backend/src/lib.rs @@ -7,6 +7,8 @@ #![doc = document_features::document_features!()] //! +#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] // Catch documentation errors caused by code changes. #![deny(rustdoc::broken_intra_doc_links)] // Temporary until we have addressed all Result cases. diff --git a/zcash_client_sqlite/Cargo.toml b/zcash_client_sqlite/Cargo.toml index 9087ba36b..dd40f20d1 100644 --- a/zcash_client_sqlite/Cargo.toml +++ b/zcash_client_sqlite/Cargo.toml @@ -14,6 +14,10 @@ edition.workspace = true rust-version.workspace = true categories.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [dependencies] zcash_client_backend = { workspace = true, features = ["unstable-serialization", "unstable-spanning-tree"] } zcash_encoding.workspace = true diff --git a/zcash_client_sqlite/src/lib.rs b/zcash_client_sqlite/src/lib.rs index 745a701f4..0a649acbf 100644 --- a/zcash_client_sqlite/src/lib.rs +++ b/zcash_client_sqlite/src/lib.rs @@ -27,6 +27,8 @@ //! [`CompactBlock`]: zcash_client_backend::proto::compact_formats::CompactBlock //! [`init_cache_database`]: crate::chain::init::init_cache_database +#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] // Catch documentation errors caused by code changes. #![deny(rustdoc::broken_intra_doc_links)] diff --git a/zcash_extensions/Cargo.toml b/zcash_extensions/Cargo.toml index a38ef6383..d1bb69c45 100644 --- a/zcash_extensions/Cargo.toml +++ b/zcash_extensions/Cargo.toml @@ -10,6 +10,10 @@ edition.workspace = true rust-version.workspace = true categories.workspace = true +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [dependencies] blake2b_simd.workspace = true zcash_primitives = { workspace = true, features = ["zfuture" ] } diff --git a/zcash_extensions/src/lib.rs b/zcash_extensions/src/lib.rs index 4ccb49efb..2b88fa20b 100644 --- a/zcash_extensions/src/lib.rs +++ b/zcash_extensions/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] // Catch documentation errors caused by code changes. #![deny(rustdoc::broken_intra_doc_links)] diff --git a/zcash_primitives/Cargo.toml b/zcash_primitives/Cargo.toml index c7512a6ef..9483a46ae 100644 --- a/zcash_primitives/Cargo.toml +++ b/zcash_primitives/Cargo.toml @@ -16,6 +16,7 @@ categories.workspace = true [package.metadata.docs.rs] all-features = true +rustdoc-args = ["--cfg", "docsrs"] [dependencies] equihash.workspace = true diff --git a/zcash_primitives/src/lib.rs b/zcash_primitives/src/lib.rs index e45cc8c5f..96159013a 100644 --- a/zcash_primitives/src/lib.rs +++ b/zcash_primitives/src/lib.rs @@ -8,6 +8,7 @@ //! #![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] // Catch documentation errors caused by code changes. #![deny(rustdoc::broken_intra_doc_links)] // Temporary until we have addressed all Result cases. diff --git a/zcash_primitives/src/transaction/builder.rs b/zcash_primitives/src/transaction/builder.rs index b6b143b9e..b727fa54e 100644 --- a/zcash_primitives/src/transaction/builder.rs +++ b/zcash_primitives/src/transaction/builder.rs @@ -452,7 +452,6 @@ impl<'a, P: consensus::Parameters, U: sapling::builder::ProverProgress> Builder< /// Adds a transparent coin to be spent in this transaction. #[cfg(feature = "transparent-inputs")] - #[cfg_attr(docsrs, doc(cfg(feature = "transparent-inputs")))] pub fn add_transparent_input( &mut self, sk: secp256k1::SecretKey, diff --git a/zcash_primitives/src/transaction/components/transparent/builder.rs b/zcash_primitives/src/transaction/components/transparent/builder.rs index 6ca1bd7ff..323a54e83 100644 --- a/zcash_primitives/src/transaction/components/transparent/builder.rs +++ b/zcash_primitives/src/transaction/components/transparent/builder.rs @@ -203,7 +203,6 @@ impl TransparentBuilder { impl TxIn { #[cfg(feature = "transparent-inputs")] - #[cfg_attr(docsrs, doc(cfg(feature = "transparent-inputs")))] pub fn new(prevout: OutPoint) -> Self { TxIn { prevout, diff --git a/zcash_proofs/Cargo.toml b/zcash_proofs/Cargo.toml index dfa4966c7..ae9c2fc7f 100644 --- a/zcash_proofs/Cargo.toml +++ b/zcash_proofs/Cargo.toml @@ -15,6 +15,7 @@ categories.workspace = true [package.metadata.docs.rs] all-features = true +rustdoc-args = ["--cfg", "docsrs"] [dependencies] zcash_primitives.workspace = true diff --git a/zcash_proofs/src/lib.rs b/zcash_proofs/src/lib.rs index 4c094c183..e9d63255c 100644 --- a/zcash_proofs/src/lib.rs +++ b/zcash_proofs/src/lib.rs @@ -8,6 +8,7 @@ //! #![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] // Catch documentation errors caused by code changes. #![deny(rustdoc::broken_intra_doc_links)] // Temporary until we have addressed all Result cases. @@ -31,14 +32,9 @@ mod hashreader; pub mod sprout; #[cfg(any(feature = "local-prover", feature = "bundled-prover"))] -#[cfg_attr( - docsrs, - doc(cfg(any(feature = "local-prover", feature = "bundled-prover"))) -)] pub mod prover; #[cfg(feature = "download-params")] -#[cfg_attr(docsrs, doc(cfg(feature = "download-params")))] mod downloadreader; // Circuit names @@ -67,7 +63,6 @@ const DOWNLOAD_URL: &str = "https://download.z.cash/downloads"; /// The paths to the Sapling parameter files. #[cfg(feature = "download-params")] -#[cfg_attr(docsrs, doc(cfg(feature = "download-params")))] #[derive(Clone, Debug, Eq, PartialEq)] pub struct SaplingParameterPaths { /// The path to the Sapling spend parameter file. @@ -79,7 +74,6 @@ pub struct SaplingParameterPaths { /// Returns the default folder that the Zcash proving parameters are located in. #[cfg(feature = "directories")] -#[cfg_attr(docsrs, doc(cfg(feature = "directories")))] pub fn default_params_folder() -> Option { #[cfg(windows)] { @@ -107,7 +101,6 @@ pub fn default_params_folder() -> Option { /// /// This mirrors the behaviour of the `fetch-params.sh` script from `zcashd`. #[cfg(feature = "download-params")] -#[cfg_attr(docsrs, doc(cfg(feature = "download-params")))] #[deprecated( since = "0.6.0", note = "please replace with `download_sapling_parameters`, and use `download_sprout_parameters` if needed" @@ -126,7 +119,6 @@ pub fn download_parameters() -> Result<(), minreq::Error> { /// /// Returns the paths to the downloaded files. #[cfg(feature = "download-params")] -#[cfg_attr(docsrs, doc(cfg(feature = "download-params")))] pub fn download_sapling_parameters( timeout: Option, ) -> Result { @@ -156,7 +148,6 @@ pub fn download_sapling_parameters( /// /// Returns the path to the downloaded file. #[cfg(feature = "download-params")] -#[cfg_attr(docsrs, doc(cfg(feature = "download-params")))] pub fn download_sprout_parameters(timeout: Option) -> Result { fetch_params(SPROUT_NAME, SPROUT_HASH, SPROUT_BYTES, timeout) } @@ -166,7 +157,6 @@ pub fn download_sprout_parameters(timeout: Option) -> Result Option { let params_dir = default_params_folder()?; let (spend_path, output_path) = if params_dir.exists() { @@ -120,7 +119,6 @@ impl LocalTxProver { /// This requires the `bundled-prover` feature, which will increase the binary size by /// around 50 MiB. #[cfg(feature = "bundled-prover")] - #[cfg_attr(docsrs, doc(cfg(feature = "bundled-prover")))] pub fn bundled() -> Self { let (spend_buf, output_buf) = wagyu_zcash_parameters::load_sapling_parameters(); let p = parse_parameters(&spend_buf[..], &output_buf[..], None);