From: Jeffrey Czyz Date: Sat, 12 Feb 2022 04:22:20 +0000 (-0600) Subject: Generate docs with features for docs.rs X-Git-Tag: v0.0.105~3^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=62b1e01ad99a46d5824912272962644d9d7ae002;p=rust-lightning Generate docs with features for docs.rs Enable generating docs using --all-features or --features="std" where applicable. Additionally, use doc_auto_cfg to tag items requiring a feature. https://doc.rust-lang.org/nightly/rustdoc/unstable-features.html#doc_auto_cfg-automatically-generate-doccfg This requires building with nightly, which is what is used by docs.rs. https://docs.rs/about/builds To test locally, use: RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc ... --- diff --git a/lightning-background-processor/Cargo.toml b/lightning-background-processor/Cargo.toml index 1837cb17e..0341cd5ae 100644 --- a/lightning-background-processor/Cargo.toml +++ b/lightning-background-processor/Cargo.toml @@ -9,6 +9,10 @@ Utilities to perform required background tasks for Rust Lightning. """ edition = "2018" +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [dependencies] bitcoin = "0.27" lightning = { version = "0.0.104", path = "../lightning", features = ["std"] } diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs index 8ed0014a7..f2058b108 100644 --- a/lightning-background-processor/src/lib.rs +++ b/lightning-background-processor/src/lib.rs @@ -6,6 +6,8 @@ #![deny(missing_docs)] #![deny(unsafe_code)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] + #[macro_use] extern crate lightning; use lightning::chain; diff --git a/lightning-block-sync/Cargo.toml b/lightning-block-sync/Cargo.toml index 0a395e8b9..3a7d57956 100644 --- a/lightning-block-sync/Cargo.toml +++ b/lightning-block-sync/Cargo.toml @@ -9,6 +9,10 @@ Utilities to fetch the chain data from a block source and feed them into Rust Li """ edition = "2018" +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [features] rest-client = [ "serde", "serde_json", "chunked_transfer" ] rpc-client = [ "serde", "serde_json", "chunked_transfer" ] diff --git a/lightning-block-sync/src/lib.rs b/lightning-block-sync/src/lib.rs index ac031132a..8854aa3e8 100644 --- a/lightning-block-sync/src/lib.rs +++ b/lightning-block-sync/src/lib.rs @@ -17,6 +17,8 @@ #![deny(missing_docs)] #![deny(unsafe_code)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] + #[cfg(any(feature = "rest-client", feature = "rpc-client"))] pub mod http; diff --git a/lightning-invoice/Cargo.toml b/lightning-invoice/Cargo.toml index e1f33f0fa..3c2678bdc 100644 --- a/lightning-invoice/Cargo.toml +++ b/lightning-invoice/Cargo.toml @@ -8,6 +8,10 @@ license = "MIT OR Apache-2.0" keywords = [ "lightning", "bitcoin", "invoice", "BOLT11" ] readme = "README.md" +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [features] default = ["std"] no-std = ["hashbrown", "lightning/no-std", "core2/alloc"] diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs index d676f6c28..841e3f9c6 100644 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@ -5,6 +5,8 @@ #![deny(unused_mut)] #![deny(broken_intra_doc_links)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] + #![cfg_attr(feature = "strict", deny(warnings))] #![cfg_attr(all(not(feature = "std"), not(test)), no_std)] diff --git a/lightning-net-tokio/Cargo.toml b/lightning-net-tokio/Cargo.toml index 370e3cc42..2b495a117 100644 --- a/lightning-net-tokio/Cargo.toml +++ b/lightning-net-tokio/Cargo.toml @@ -10,6 +10,10 @@ For Rust-Lightning clients which wish to make direct connections to Lightning P2 """ edition = "2018" +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [dependencies] bitcoin = "0.27" lightning = { version = "0.0.104", path = "../lightning" } diff --git a/lightning-net-tokio/src/lib.rs b/lightning-net-tokio/src/lib.rs index 62c036b97..2582cc597 100644 --- a/lightning-net-tokio/src/lib.rs +++ b/lightning-net-tokio/src/lib.rs @@ -69,6 +69,8 @@ #![deny(broken_intra_doc_links)] #![deny(missing_docs)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] + use bitcoin::secp256k1::key::PublicKey; use tokio::net::TcpStream; diff --git a/lightning-persister/Cargo.toml b/lightning-persister/Cargo.toml index 79ffeeeb2..cb056a60f 100644 --- a/lightning-persister/Cargo.toml +++ b/lightning-persister/Cargo.toml @@ -8,6 +8,10 @@ description = """ Utilities to manage Rust-Lightning channel data persistence and retrieval. """ +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + [features] _bench_unstable = ["lightning/_bench_unstable"] diff --git a/lightning-persister/src/lib.rs b/lightning-persister/src/lib.rs index 558f4b8fe..a5cbe2f92 100644 --- a/lightning-persister/src/lib.rs +++ b/lightning-persister/src/lib.rs @@ -3,6 +3,8 @@ #![deny(broken_intra_doc_links)] #![deny(missing_docs)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] + #![cfg_attr(all(test, feature = "_bench_unstable"), feature(test))] #[cfg(all(test, feature = "_bench_unstable"))] extern crate test; diff --git a/lightning/Cargo.toml b/lightning/Cargo.toml index 5f6f2ef65..058a3b4f7 100644 --- a/lightning/Cargo.toml +++ b/lightning/Cargo.toml @@ -10,6 +10,10 @@ Does most of the hard work, without implying a specific runtime, requiring clien Still missing tons of error-handling. See GitHub issues for suggested projects if you want to contribute. Don't have to bother telling you not to use this for anything serious, because you'd have to build a client around it to even try. """ +[package.metadata.docs.rs] +features = ["std"] +rustdoc-args = ["--cfg", "docsrs"] + [features] # Internal test utilities exposed to other repo crates _test_utils = ["hex", "regex", "bitcoin/bitcoinconsensus"] diff --git a/lightning/src/lib.rs b/lightning/src/lib.rs index 2798f78ad..6d4cc50a9 100644 --- a/lightning/src/lib.rs +++ b/lightning/src/lib.rs @@ -28,6 +28,8 @@ #![allow(bare_trait_objects)] #![allow(ellipsis_inclusive_range_patterns)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] + #![cfg_attr(all(not(feature = "std"), not(test)), no_std)] #![cfg_attr(all(any(test, feature = "_test_utils"), feature = "_bench_unstable"), feature(test))]