Skip to content

Commit 8653104

Browse files
committed
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 ...
1 parent 6604fbf commit 8653104

File tree

12 files changed

+36
-0
lines changed

12 files changed

+36
-0
lines changed

lightning-background-processor/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Utilities to perform required background tasks for Rust Lightning.
99
"""
1010
edition = "2018"
1111

12+
[package.metadata.docs.rs]
13+
all-features = true
14+
rustdoc-args = ["--cfg", "docsrs"]
15+
1216
[dependencies]
1317
bitcoin = "0.27"
1418
lightning = { version = "0.0.104", path = "../lightning", features = ["std"] }

lightning-background-processor/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#![deny(missing_docs)]
77
#![deny(unsafe_code)]
88

9+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
10+
911
#[macro_use] extern crate lightning;
1012

1113
use lightning::chain;

lightning-block-sync/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Utilities to fetch the chain data from a block source and feed them into Rust Li
99
"""
1010
edition = "2018"
1111

12+
[package.metadata.docs.rs]
13+
all-features = true
14+
rustdoc-args = ["--cfg", "docsrs"]
15+
1216
[features]
1317
rest-client = [ "serde", "serde_json", "chunked_transfer" ]
1418
rpc-client = [ "serde", "serde_json", "chunked_transfer" ]

lightning-block-sync/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#![deny(missing_docs)]
1818
#![deny(unsafe_code)]
1919

20+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
21+
2022
#[cfg(any(feature = "rest-client", feature = "rpc-client"))]
2123
pub mod http;
2224

lightning-invoice/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ license = "MIT OR Apache-2.0"
88
keywords = [ "lightning", "bitcoin", "invoice", "BOLT11" ]
99
readme = "README.md"
1010

11+
[package.metadata.docs.rs]
12+
all-features = true
13+
rustdoc-args = ["--cfg", "docsrs"]
14+
1115
[features]
1216
default = ["std"]
1317
no-std = ["hashbrown", "lightning/no-std", "core2/alloc"]

lightning-invoice/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#![deny(unused_mut)]
66
#![deny(broken_intra_doc_links)]
77

8+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
9+
810
#![cfg_attr(feature = "strict", deny(warnings))]
911
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
1012

lightning-net-tokio/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ For Rust-Lightning clients which wish to make direct connections to Lightning P2
1010
"""
1111
edition = "2018"
1212

13+
[package.metadata.docs.rs]
14+
all-features = true
15+
rustdoc-args = ["--cfg", "docsrs"]
16+
1317
[dependencies]
1418
bitcoin = "0.27"
1519
lightning = { version = "0.0.104", path = "../lightning" }

lightning-net-tokio/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
#![deny(broken_intra_doc_links)]
7070
#![deny(missing_docs)]
7171

72+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
73+
7274
use bitcoin::secp256k1::key::PublicKey;
7375

7476
use tokio::net::TcpStream;

lightning-persister/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ description = """
88
Utilities to manage Rust-Lightning channel data persistence and retrieval.
99
"""
1010

11+
[package.metadata.docs.rs]
12+
all-features = true
13+
rustdoc-args = ["--cfg", "docsrs"]
14+
1115
[features]
1216
unstable = ["lightning/unstable"]
1317

lightning-persister/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#![deny(broken_intra_doc_links)]
44
#![deny(missing_docs)]
55

6+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
7+
68
#![cfg_attr(all(test, feature = "unstable"), feature(test))]
79
#[cfg(all(test, feature = "unstable"))] extern crate test;
810

lightning/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Does most of the hard work, without implying a specific runtime, requiring clien
1010
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.
1111
"""
1212

13+
[package.metadata.docs.rs]
14+
features = ["std"]
15+
rustdoc-args = ["--cfg", "docsrs"]
16+
1317
[features]
1418
fuzztarget = ["bitcoin/fuzztarget", "regex"]
1519
# Internal test utilities exposed to other repo crates

lightning/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#![allow(bare_trait_objects)]
2929
#![allow(ellipsis_inclusive_range_patterns)]
3030

31+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
32+
3133
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
3234

3335
#![cfg_attr(all(any(test, feature = "_test_utils"), feature = "unstable"), feature(test))]

0 commit comments

Comments
 (0)