Skip to content

Commit ebaa31b

Browse files
committed
Enable usage of -D rustdoc::broken-intra-doc-links
Currently we have a bunch of broken links in our docs. Fix all the broken links an add `-D rustdoc::broken-intra-doc-links` to the docs build in CI. There are a few other improvements scattered through this PR, I tried to find a balance between scope creep and obvious errors in the diff.
1 parent 16b6c76 commit ebaa31b

File tree

7 files changed

+62
-48
lines changed

7 files changed

+62
-48
lines changed

contrib/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fi
9292

9393
# Build the docs if told to (this only works with the nightly toolchain)
9494
if [ "$DO_DOCS" = true ]; then
95-
RUSTDOCFLAGS="--cfg docsrs" cargo doc --features="$FEATURES"
95+
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly rustdoc --features="$FEATURES" -- -D rustdoc::broken-intra-doc-links
9696
fi
9797

9898
exit 0

src/descriptor/key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ impl DescriptorPublicKey {
600600
}
601601

602602
#[deprecated(note = "use at_derivation_index instead")]
603-
/// Deprecated name of [`at_derivation_index`].
603+
/// Deprecated name for [`Self::at_derivation_index`].
604604
pub fn derive(self, index: u32) -> Result<DefiniteDescriptorKey, ConversionError> {
605605
self.at_derivation_index(index)
606606
}

src/descriptor/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ impl Descriptor<DescriptorPublicKey> {
537537
}
538538

539539
#[deprecated(note = "use at_derivation_index instead")]
540-
/// Deprecated name for [`at_derivation_index`].
540+
/// Deprecated name for [`Self::at_derivation_index`].
541541
pub fn derive(&self, index: u32) -> Result<Descriptor<DefiniteDescriptorKey>, ConversionError> {
542542
self.at_derivation_index(index)
543543
}

src/interpreter/stack.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ use crate::miniscript::context::SigType;
1515
use crate::prelude::*;
1616

1717
/// Definition of Stack Element of the Stack used for interpretation of Miniscript.
18-
/// All stack elements with vec![] go to Dissatisfied and vec![1] are marked to Satisfied.
19-
/// Others are directly pushed as witness
18+
///
19+
/// All stack elements with `vec![]` go to `Element::Dissatisfied` and `vec![1]` are marked to
20+
/// `Element::Satisfied`. Others are directly pushed as witness.
2021
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
2122
pub enum Element<'txin> {
2223
/// Result of a satisfied Miniscript fragment

src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,20 @@ pub trait MiniscriptKey: Clone + Eq + Ord + fmt::Debug + fmt::Display + hash::Ha
154154
/// in BIP389 multipath descriptors.
155155
fn num_der_paths(&self) -> usize;
156156

157-
/// The associated [`sha256::Hash`] for this [`MiniscriptKey`],
158-
/// used in the hash256 fragment.
157+
/// The associated [`bitcoin::hashes::sha256::Hash`] for this [`MiniscriptKey`], used in the
158+
/// sha256 fragment.
159159
type Sha256: Clone + Eq + Ord + fmt::Display + fmt::Debug + hash::Hash;
160160

161-
/// The associated [`hash256::Hash`] for this [`MiniscriptKey`],
162-
/// used in the hash256 fragment.
161+
/// The associated [`miniscript::hash256::Hash`] for this [`MiniscriptKey`], used in the
162+
/// hash256 fragment.
163163
type Hash256: Clone + Eq + Ord + fmt::Display + fmt::Debug + hash::Hash;
164-
/// The associated [`ripedmd160::Hash`] for this [`MiniscriptKey`] type.
165-
/// used in the ripemd160 fragment
164+
165+
/// The associated [`bitcoin::hashes::ripemd160::Hash`] for this [`MiniscriptKey`] type, used
166+
/// in the ripemd160 fragment.
166167
type Ripemd160: Clone + Eq + Ord + fmt::Display + fmt::Debug + hash::Hash;
167168

168-
/// The associated [`hash160::Hash`] for this [`MiniscriptKey`] type.
169-
/// used in the hash160 fragment
169+
/// The associated [`bitcoin::hashes::hash160::Hash`] for this [`MiniscriptKey`] type, used in
170+
/// the hash160 fragment.
170171
type Hash160: Clone + Eq + Ord + fmt::Display + fmt::Debug + hash::Hash;
171172
}
172173

src/miniscript/decode.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ use crate::miniscript::ScriptContext;
2424
use crate::prelude::*;
2525
use crate::{bitcoin, hash256, Error, Miniscript, MiniscriptKey, ToPublicKey};
2626

27+
#[cfg(doc)]
28+
use crate::Descriptor;
29+
2730
fn return_none<T>(_: usize) -> Option<T> {
2831
None
2932
}
@@ -112,14 +115,14 @@ enum NonTerm {
112115
// could be or_i or tern
113116
EndIfElse,
114117
}
115-
/// All AST elements
116-
/// This variant is the inner Miniscript variant that allows the user to bypass
117-
/// some of the miniscript rules. You should *never* construct Terminal directly.
118-
/// This is only exposed to external user to allow matching on the [`crate::Miniscript`]
118+
/// All AST elements.
119+
///
120+
/// This variant is the inner Miniscript variant that allows the user to bypass some of the
121+
/// miniscript rules. You should *never* construct `Terminal` directly. This is only exposed to
122+
/// external users to allow matching on the [`Miniscript`].
119123
///
120-
/// The average user should always use the [`crate::Descriptor`] APIs. Advanced users
121-
/// who want deal with Miniscript ASTs should use the [`crate::Miniscript`] APIs.
122-
#[allow(broken_intra_doc_links)]
124+
/// The average user should always use the [`Descriptor`] APIs. Advanced users who want deal
125+
/// with Miniscript ASTs should use the [`Miniscript`] APIs.
123126
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
124127
pub enum Terminal<Pk: MiniscriptKey, Ctx: ScriptContext> {
125128
/// `1`
@@ -160,38 +163,38 @@ pub enum Terminal<Pk: MiniscriptKey, Ctx: ScriptContext> {
160163
Check(Arc<Miniscript<Pk, Ctx>>),
161164
/// `DUP IF [V] ENDIF`
162165
DupIf(Arc<Miniscript<Pk, Ctx>>),
163-
/// [T] VERIFY
166+
/// `[T] VERIFY`
164167
Verify(Arc<Miniscript<Pk, Ctx>>),
165-
/// SIZE 0NOTEQUAL IF [Fn] ENDIF
168+
/// `SIZE 0NOTEQUAL IF [Fn] ENDIF`
166169
NonZero(Arc<Miniscript<Pk, Ctx>>),
167-
/// [X] 0NOTEQUAL
170+
/// `[X] 0NOTEQUAL`
168171
ZeroNotEqual(Arc<Miniscript<Pk, Ctx>>),
169172
// Conjunctions
170-
/// [V] [T]/[V]/[F]/[Kt]
173+
/// `[V] [T]/[V]/[F]/[Kt]`
171174
AndV(Arc<Miniscript<Pk, Ctx>>, Arc<Miniscript<Pk, Ctx>>),
172-
/// [E] [W] BOOLAND
175+
/// `[E] [W] BOOLAND`
173176
AndB(Arc<Miniscript<Pk, Ctx>>, Arc<Miniscript<Pk, Ctx>>),
174-
/// [various] NOTIF [various] ELSE [various] ENDIF
177+
/// `[various] NOTIF [various] ELSE [various] ENDIF`
175178
AndOr(
176179
Arc<Miniscript<Pk, Ctx>>,
177180
Arc<Miniscript<Pk, Ctx>>,
178181
Arc<Miniscript<Pk, Ctx>>,
179182
),
180183
// Disjunctions
181-
/// [E] [W] BOOLOR
184+
/// `[E] [W] BOOLOR`
182185
OrB(Arc<Miniscript<Pk, Ctx>>, Arc<Miniscript<Pk, Ctx>>),
183-
/// [E] IFDUP NOTIF [T]/[E] ENDIF
186+
/// `[E] IFDUP NOTIF [T]/[E] ENDIF`
184187
OrD(Arc<Miniscript<Pk, Ctx>>, Arc<Miniscript<Pk, Ctx>>),
185-
/// [E] NOTIF [V] ENDIF
188+
/// `[E] NOTIF [V] ENDIF`
186189
OrC(Arc<Miniscript<Pk, Ctx>>, Arc<Miniscript<Pk, Ctx>>),
187-
/// IF [various] ELSE [various] ENDIF
190+
/// `IF [various] ELSE [various] ENDIF`
188191
OrI(Arc<Miniscript<Pk, Ctx>>, Arc<Miniscript<Pk, Ctx>>),
189192
// Thresholds
190-
/// [E] ([W] ADD)* k EQUAL
193+
/// `[E] ([W] ADD)* k EQUAL`
191194
Thresh(usize, Vec<Arc<Miniscript<Pk, Ctx>>>),
192-
/// k (<key>)* n CHECKMULTISIG
195+
/// `k (<key>)* n CHECKMULTISIG`
193196
Multi(usize, Vec<Pk>),
194-
/// <key> CHECKSIG (<key> CHECKSIGADD)*(n-1) k NUMEQUAL
197+
/// `<key> CHECKSIG (<key> CHECKSIGADD)*(n-1) k NUMEQUAL`
195198
MultiA(usize, Vec<Pk>),
196199
}
197200

src/policy/concrete.rs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ use crate::miniscript::types::extra_props::TimelockInfo;
2929
use crate::prelude::*;
3030
use crate::{errstr, Error, ForEachKey, MiniscriptKey, Translator};
3131

32+
#[cfg(all(doc, not(feature = "compiler")))]
33+
use crate::Descriptor;
34+
3235
/// Maximum TapLeafs allowed in a compiled TapTree
3336
#[cfg(feature = "compiler")]
3437
const MAX_COMPILATION_LEAVES: usize = 1024;
@@ -207,18 +210,18 @@ pub enum PolicyError {
207210
DuplicatePubKeys,
208211
}
209212

210-
/// Descriptor context for [`Policy`] compilation into a [`Descriptor`]
213+
/// Descriptor context for [`Policy`] compilation into a [`Descriptor`].
211214
pub enum DescriptorCtx<Pk> {
212-
/// [Bare][`Descriptor::Bare`]
215+
/// See docs for [`Descriptor::Bare`].
213216
Bare,
214-
/// [Sh][`Descriptor::Sh`]
217+
/// See docs for [`Descriptor::Sh`].
215218
Sh,
216-
/// [Wsh][`Descriptor::Wsh`]
219+
/// See docs for [`Descriptor::Wsh`].
217220
Wsh,
218-
/// Sh-wrapped [Wsh][`Descriptor::Wsh`]
221+
/// See docs for [`Descriptor::Wsh`].
219222
ShWsh,
220-
/// [Tr][`Descriptor::Tr`] where the Option<Pk> corresponds to the internal_key if no internal
221-
/// key can be inferred from the given policy
223+
/// [`Descriptor::Tr`] where the `Option<Pk>` corresponds to the internal key if no
224+
/// internal key can be inferred from the given policy.
222225
Tr(Option<Pk>),
223226
}
224227

@@ -364,7 +367,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
364367
}
365368
}
366369

367-
/// Compile the [`Policy`] into a [`Tr`][`Descriptor::Tr`] Descriptor.
370+
/// Compile the [`Policy`] into a [`Descriptor::Tr`].
368371
///
369372
/// ### TapTree compilation
370373
///
@@ -417,20 +420,26 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
417420
}
418421
}
419422

420-
/// Compile the [`Policy`] into a [`Tr`][`Descriptor::Tr`] Descriptor, with policy-enumeration
421-
/// by [`Policy::enumerate_policy_tree`].
423+
/// Compiles the [`Policy`] into a [`Descriptor::Tr`].
422424
///
423425
/// ### TapTree compilation
424426
///
425-
/// The policy tree constructed by root-level disjunctions over [`Or`][`Policy::Or`] and
426-
/// [`Thresh`][`Policy::Threshold`](k, ..n..) which is flattened into a vector (with respective
427-
/// probabilities derived from odds) of policies.
428-
/// For example, the policy `thresh(1,or(pk(A),pk(B)),and(or(pk(C),pk(D)),pk(E)))` gives the vector
427+
/// The policy tree constructed by root-level disjunctions over [`Policy::Or`] and
428+
/// [`Policy::Threshold`] (k, ..n..) which is flattened into a vector (with respective
429+
/// probabilities derived from odds) of policies. For example, the policy
430+
/// `thresh(1,or(pk(A),pk(B)),and(or(pk(C),pk(D)),pk(E)))` gives the vector
429431
/// `[pk(A),pk(B),and(or(pk(C),pk(D)),pk(E)))]`.
430432
///
431433
/// ### Policy enumeration
432434
///
433-
/// Refer to [`Policy::enumerate_policy_tree`] for the current strategy implemented.
435+
/// Generates a root-level disjunctive tree over the given policy tree.
436+
///
437+
/// Uses a fixed-point algorithm to enumerate the disjunctions until exhaustive root-level
438+
/// enumeration or limits exceed. For a given [`Policy`], we maintain an [ordered
439+
/// set](`BTreeSet`) of `(prob, policy)` (ordered by probability) to maintain the list of
440+
/// enumerated sub-policies whose disjunction is isomorphic to initial policy (*invariant*).
441+
///
442+
/// [`Policy`]: crate::policy::concrete::Policy
434443
#[cfg(feature = "compiler")]
435444
pub fn compile_tr_private_experimental(
436445
&self,

0 commit comments

Comments
 (0)