Clippy lints / Nursery
Clippy lint · Nursery · checked with Clippy 0.1.99
clippy::too_long_first_doc_paragraph: Checks if the first paragraph in the documentation of items listed in the module page is too long
What it meansChecks if the first paragraph in the documentation of items listed in the module page is too long. It is in the nursery group and off by default.
Does it matter?
Documentation will show the first paragraph of the docstring in the summary page of a module. Having a nice, short summary in the first paragraph is part of writing good docs.
New lints still being finished. Off by default and may have false positives.
How to fix it
Clippy can fix this one for you: run cargo clippy --fix (add --allow-dirty if you have uncommitted changes). Review the diff before you commit.
Flagged
/// A very short summary.
/// A much longer explanation that goes into a lot more detail about
/// how the thing works, possibly with doclinks and so one,
/// and probably spanning a many rows.
struct Foo {}
Write this instead
/// A very short summary.
///
/// A much longer explanation that goes into a lot more detail about
/// how the thing works, possibly with doclinks and so one,
/// and probably spanning a many rows.
struct Foo {}
Turn it off, or on
It is off by default. To use it, set it to warn or deny:
Whole crate (Cargo.toml)
[lints.clippy]
too_long_first_doc_paragraph = "warn"In code
#![warn(clippy::too_long_first_doc_paragraph)]One run
cargo clippy -- -W clippy::too-long-first-doc-paragraphThe [lints] table needs Rust 1.74 or newer. In a workspace, put it under [workspace.lints.clippy] and add [lints] workspace = true to each member.
Clippy's own documentation
What it does
Checks if the first paragraph in the documentation of items listed in the module page is too long.
Why is this bad?
Documentation will show the first paragraph of the docstring in the summary page of a module. Having a nice, short summary in the first paragraph is part of writing good docs.
Example
/// A very short summary.
/// A much longer explanation that goes into a lot more detail about
/// how the thing works, possibly with doclinks and so one,
/// and probably spanning a many rows.
struct Foo {}
Use instead:
/// A very short summary.
///
/// A much longer explanation that goes into a lot more detail about
/// how the thing works, possibly with doclinks and so one,
/// and probably spanning a many rows.
struct Foo {}
From the Clippy lint list (0.1.99), part of the Rust project, MIT or Apache-2.0. Official entry.
Related lints
- redundant_cloneChecks for a redundant clone() (and its relatives) which clones an owned value that is going to be dropped without further use
- string_lit_as_bytesChecks for the as_bytes method called on string literals that contain only ASCII characters
- suboptimal_flopsexponent for bases 2 and e can be computed more accurately
- suspicious_operation_groupingsthis sequence of operators looks suspiciously like a bug
- trailing_empty_arraytrailing zero-sized array in a struct which is not marked with a `repr` attribute
- trait_duplication_in_boundsthis trait bound is already specified in the where clause
- transmute_undefined_reprtransmute from `main::Foo<u32>` to `main::Foo<i32>`, both of which have an undefined layout
All 847 Clippy lints · Rust compiler errors · Cargo.toml checker
Up next
Related lintclippy::redundant_cloneChecks for a redundant clone() (and its relatives) which clones an owned value that is going to be dropped without further useRead it next →Did this answer your question?