Skip to content

Commit 44edc0c

Browse files
authored
Fix private docs (#326)
## Synopsis We do have quite a rich private documentation, which helps to understand and navigate code. However, it has never been checked on CI, so many intra-doc links are just broken. ## Solution - Check private Rust docs on CI to build OK. - Fix the broken intra-doc links in private docs.
1 parent 04afa51 commit 44edc0c

File tree

9 files changed

+52
-14
lines changed

9 files changed

+52
-14
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,23 @@ jobs:
145145
#################
146146

147147
rustdoc:
148+
name: rustdoc${{ matrix.opts != '' && ' (private)' || '' }}
149+
strategy:
150+
fail-fast: false
151+
matrix:
152+
opts: ["", "--document-private-items"]
148153
runs-on: ubuntu-latest
149154
steps:
150155
- uses: actions/checkout@v4
151156
- uses: dtolnay/rust-toolchain@v1
152157
with:
153158
toolchain: nightly
154159

155-
- run: cargo +nightly doc -p derive_more-impl --features full
160+
- run: cargo +nightly doc -p derive_more-impl --features full ${{ matrix.opts }}
156161
env:
157162
RUSTDOCFLAGS: --cfg docsrs --cfg ci
158163

159-
- run: cargo +nightly doc -p derive_more --features full
164+
- run: cargo +nightly doc -p derive_more --features full ${{ matrix.opts }}
160165
env:
161166
RUSTDOCFLAGS: --cfg docsrs --cfg ci
162167

impl/src/as/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,19 @@ pub fn expand(
148148
/// - [`syn::Ident`] of the derived trait.
149149
/// - [`syn::Ident`] of the derived trait method.
150150
/// - Optional `mut` token indicating [`AsMut`] expansion.
151+
///
152+
/// [`syn::Ident`]: struct@syn::Ident
151153
type ExpansionCtx<'a> = (&'a syn::Ident, &'a syn::Ident, Option<&'a Token![mut]>);
152154

153155
/// Expansion of a macro for generating [`AsRef`]/[`AsMut`] implementations for a single field of a
154156
/// struct.
155157
struct Expansion<'a> {
156-
/// [`ExpansionCtx] of the derived trait.
158+
/// [`ExpansionCtx`] of the derived trait.
157159
trait_info: ExpansionCtx<'a>,
158160

159161
/// [`syn::Ident`] of the struct.
162+
///
163+
/// [`syn::Ident`]: struct@syn::Ident
160164
ident: &'a syn::Ident,
161165

162166
/// [`syn::Generics`] of the struct.

impl/src/fmt/display.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ pub fn expand(input: &syn::DeriveInput, trait_name: &str) -> syn::Result<TokenSt
6767
/// - Struct/enum/union [`syn::Ident`].
6868
/// - Derived trait [`syn::Ident`].
6969
/// - Attribute name [`syn::Ident`].
70+
///
71+
/// [`syn::Ident`]: struct@syn::Ident
7072
type ExpansionCtx<'a> = (
7173
&'a ContainerAttributes,
7274
&'a syn::Ident,
@@ -202,12 +204,16 @@ struct Expansion<'a> {
202204
attrs: &'a ContainerAttributes,
203205

204206
/// Struct or enum [`syn::Ident`].
207+
///
208+
/// [`syn::Ident`]: struct@syn::Ident
205209
ident: &'a syn::Ident,
206210

207211
/// Struct or enum [`syn::Fields`].
208212
fields: &'a syn::Fields,
209213

210214
/// [`fmt`] trait [`syn::Ident`].
215+
///
216+
/// [`syn::Ident`]: struct@syn::Ident
211217
trait_ident: &'a syn::Ident,
212218
}
213219

@@ -220,6 +226,7 @@ impl<'a> Expansion<'a> {
220226
/// greater than 1.
221227
///
222228
/// [`Display::fmt()`]: fmt::Display::fmt()
229+
/// [`FmtAttribute`]: super::FmtAttribute
223230
fn generate_body(&self) -> syn::Result<TokenStream> {
224231
match &self.attrs.fmt {
225232
Some(fmt) => {

impl/src/fmt/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ struct FmtAttribute {
101101
lit: syn::LitStr,
102102

103103
/// Optional [`token::Comma`].
104+
///
105+
/// [`token::Comma`]: struct@token::Comma
104106
comma: Option<token::Comma>,
105107

106108
/// Interpolation arguments.
@@ -414,6 +416,8 @@ impl Placeholder {
414416
///
415417
/// `#[<attribute>(...)]` can be specified only once, while multiple `#[<attribute>(bound(...))]`
416418
/// are allowed.
419+
///
420+
/// [`fmt::Display`]: std::fmt::Display
417421
#[derive(Debug, Default)]
418422
struct ContainerAttributes {
419423
/// Interpolation [`FmtAttribute`].
@@ -468,7 +472,7 @@ impl attr::ParseMultiple for ContainerAttributes {
468472
}
469473
}
470474

471-
/// Matches the provided `trait_name` to appropriate [`Attribute::Fmt`] argument name.
475+
/// Matches the provided `trait_name` to appropriate [`FmtAttribute`]'s argument name.
472476
fn trait_name_to_attribute_name<T>(trait_name: T) -> &'static str
473477
where
474478
T: for<'a> PartialEq<&'a str>,

impl/src/from.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,13 @@ struct Expansion<'a> {
120120
attrs: Option<&'a VariantAttribute>,
121121

122122
/// Struct or enum [`syn::Ident`].
123+
///
124+
/// [`syn::Ident`]: struct@syn::Ident
123125
ident: &'a syn::Ident,
124126

125127
/// Variant [`syn::Ident`] in case of enum expansion.
128+
///
129+
/// [`syn::Ident`]: struct@syn::Ident
126130
variant: Option<&'a syn::Ident>,
127131

128132
/// Struct or variant [`syn::Fields`].
@@ -132,7 +136,7 @@ struct Expansion<'a> {
132136
generics: &'a syn::Generics,
133137

134138
/// Indicator whether one of the enum variants has
135-
/// [`VariantAttribute::From`], [`VariantAttribute::Types`] or
139+
/// [`VariantAttribute::Empty`], [`VariantAttribute::Types`] or
136140
/// [`VariantAttribute::Forward`].
137141
///
138142
/// Always [`false`] for structs.
@@ -254,6 +258,9 @@ impl<'a> Expansion<'a> {
254258
/// Expands fields initialization wrapped into [`token::Brace`]s in case of
255259
/// [`syn::FieldsNamed`], or [`token::Paren`] in case of
256260
/// [`syn::FieldsUnnamed`].
261+
///
262+
/// [`token::Brace`]: struct@token::Brace
263+
/// [`token::Paren`]: struct@token::Paren
257264
fn expand_fields(
258265
&self,
259266
mut wrap: impl FnMut(

impl/src/into.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ pub fn expand(input: &syn::DeriveInput, _: &'static str) -> syn::Result<TokenStr
109109
/// Expansion of an [`Into`] derive macro, generating [`From`] implementations for a struct.
110110
struct Expansion<'a> {
111111
/// [`syn::Ident`] of the struct.
112+
///
113+
/// [`syn::Ident`]: struct@syn::Ident
112114
input_ident: &'a syn::Ident,
113115

114116
/// [`syn::Generics`] of the struct.
@@ -306,13 +308,13 @@ struct Conversions {
306308
/// ```
307309
#[derive(Clone, Debug)]
308310
struct ConversionsAttribute {
309-
/// [`Type`]s wrapped into `owned(...)` or simply `#[into(...)]`.
311+
/// [`syn::Type`]s wrapped into `owned(...)` or simply `#[into(...)]`.
310312
owned: Conversions,
311313

312-
/// [`Type`]s wrapped into `ref(...)`.
314+
/// [`syn::Type`]s wrapped into `ref(...)`.
313315
r#ref: Conversions,
314316

315-
/// [`Type`]s wrapped into `ref_mut(...)`.
317+
/// [`syn::Type`]s wrapped into `ref_mut(...)`.
316318
ref_mut: Conversions,
317319
}
318320

@@ -463,6 +465,8 @@ where
463465
}
464466

465467
/// [`Error`]ors for legacy syntax: `#[into(types(i32, "&str"))]`.
468+
///
469+
/// [`Error`]: syn::Error
466470
fn check_legacy_syntax<'a, F>(tokens: ParseStream<'_>, fields: &'a F) -> syn::Result<()>
467471
where
468472
F: FieldsExt + ?Sized,

impl/src/parsing.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ pub(crate) enum Expr {
2222
}
2323

2424
impl Expr {
25-
/// Returns an [`Ident`] in case this [`Expr`] is represented only by it.
25+
/// Returns a [`syn::Ident`] in case this [`Expr`] is represented only by it.
26+
///
27+
/// [`syn::Ident`]: struct@syn::Ident
2628
pub(crate) fn ident(&self) -> Option<&syn::Ident> {
2729
match self {
2830
Self::Ident(ident) => Some(ident),
@@ -50,12 +52,12 @@ impl Parse for Expr {
5052
take_until1(
5153
alt([
5254
&mut seq([
53-
&mut colon2,
55+
&mut path_sep,
5456
&mut balanced_pair(punct('<'), punct('>')),
5557
]),
5658
&mut seq([
5759
&mut balanced_pair(punct('<'), punct('>')),
58-
&mut colon2,
60+
&mut path_sep,
5961
]),
6062
&mut balanced_pair(punct('|'), punct('|')),
6163
&mut token_tree,
@@ -81,8 +83,10 @@ impl ToTokens for Expr {
8183
/// Result of parsing.
8284
type ParsingResult<'a> = Option<(TokenStream, Cursor<'a>)>;
8385

84-
/// Tries to parse a [`syn::token::Colon2`].
85-
pub fn colon2(c: Cursor<'_>) -> ParsingResult<'_> {
86+
/// Tries to parse a [`token::PathSep`].
87+
///
88+
/// [`token::PathSep`]: struct@syn::token::PathSep
89+
pub fn path_sep(c: Cursor<'_>) -> ParsingResult<'_> {
8690
seq([
8791
&mut punct_with_spacing(':', Spacing::Joint),
8892
&mut punct(':'),

impl/src/try_from.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct Expansion {
6161
attr: Option<ItemAttribute>,
6262

6363
/// [`syn::Ident`] of the enum.
64+
///
65+
/// [`syn::Ident`]: struct@syn::Ident
6466
ident: syn::Ident,
6567

6668
/// [`syn::Generics`] of the enum.

impl/src/utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,7 @@ pub(crate) mod attr {
17801780
/// If there is no explicitly specified primitive integer type, then returns a
17811781
/// [default `isize` discriminant][0].
17821782
///
1783+
/// [`syn::Ident`]: struct@syn::Ident
17831784
/// [0]: https://doc.rust-lang.org/reference/items/enumerations.html#discriminants
17841785
pub(crate) fn ty(&self) -> syn::Ident {
17851786
self.0
@@ -2216,7 +2217,7 @@ mod fields_ext {
22162217

22172218
/// [`syn::Fields`] extension.
22182219
pub(crate) trait FieldsExt: Len {
2219-
/// Validates the provided [`parsing::Type`] against these [`syn::Fields`].
2220+
/// Validates the provided [`syn::Type`] against these [`syn::Fields`].
22202221
fn validate_type<'t>(
22212222
&self,
22222223
ty: &'t syn::Type,

0 commit comments

Comments
 (0)