From cda56ef862e5292417f5897900e11588cb1e1004 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 23 Aug 2020 10:54:32 +0100 Subject: [PATCH] zcash_proofs: Add feature flags to docs.rs documentation --- zcash_proofs/Cargo.toml | 3 +++ zcash_proofs/src/lib.rs | 7 +++++++ zcash_proofs/src/prover.rs | 3 +++ 3 files changed, 13 insertions(+) diff --git a/zcash_proofs/Cargo.toml b/zcash_proofs/Cargo.toml index 8a917e2f8..74567b460 100644 --- a/zcash_proofs/Cargo.toml +++ b/zcash_proofs/Cargo.toml @@ -11,6 +11,9 @@ readme = "README.md" license = "MIT OR Apache-2.0" edition = "2018" +[package.metadata.docs.rs] +all-features = true + [dependencies] bellman = { version = "0.6", path = "../bellman", default-features = false, features = ["groth16"] } blake2b_simd = "0.5" diff --git a/zcash_proofs/src/lib.rs b/zcash_proofs/src/lib.rs index ecbb34c0b..6d0476c57 100644 --- a/zcash_proofs/src/lib.rs +++ b/zcash_proofs/src/lib.rs @@ -3,6 +3,7 @@ //! `zcash_proofs` contains the zk-SNARK circuits used by Zcash, and the APIs for creating //! and verifying proofs. +#![cfg_attr(docsrs, feature(doc_cfg))] // Catch documentation errors caused by code changes. #![deny(intra_doc_link_resolution_failure)] @@ -24,6 +25,10 @@ pub mod sapling; 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; // Circuit names @@ -42,6 +47,7 @@ const DOWNLOAD_URL: &str = "https://download.z.cash/downloads"; /// 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 { BaseDirs::new().map(|base_dirs| { if cfg!(any(windows, target_os = "macos")) { @@ -56,6 +62,7 @@ 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")))] pub fn download_parameters() -> Result<(), minreq::Error> { // Ensure that the default Zcash parameters location exists. let params_dir = default_params_folder().ok_or(io::Error::new( diff --git a/zcash_proofs/src/prover.rs b/zcash_proofs/src/prover.rs index 5373bc3f9..f84b22279 100644 --- a/zcash_proofs/src/prover.rs +++ b/zcash_proofs/src/prover.rs @@ -49,6 +49,7 @@ impl LocalTxProver { /// This function will panic if the paths do not point to valid parameter files with /// the expected hashes. #[cfg(feature = "local-prover")] + #[cfg_attr(docsrs, doc(cfg(feature = "local-prover")))] pub fn new(spend_path: &Path, output_path: &Path) -> Self { let (spend_params, spend_vk, output_params, _, _) = load_parameters(spend_path, output_path, None); @@ -81,6 +82,7 @@ impl LocalTxProver { /// This function will panic if the parameters in the default local location do not /// have the expected hashes. #[cfg(feature = "local-prover")] + #[cfg_attr(docsrs, doc(cfg(feature = "local-prover")))] pub fn with_default_location() -> Option { let params_dir = default_params_folder()?; let (spend_path, output_path) = if params_dir.exists() { @@ -103,6 +105,7 @@ 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 (spend_params, spend_vk, output_params, _, _) =