Open ojeda opened 1 month ago
Just a quick report for future work.
I was working on this for a bit, and found some difficulties in automatically applying this rule.
For example, doc like
/// - First line. Here's an sample object:
/// {
/// 'protocol': 25,
/// 'data': 0xffff
/// }
/// - Second line.
would be fixed into:
/// - First line. Here's an sample object:
/// {
/// 'protocol': 25,
/// 'data': 0xffff
/// }
/// - Second line.
Similar UI test exists here: https://github.com/rust-lang/rust-clippy/blob/ccf7c88386be0f4bfd13bac2ffb616e09c033e55/tests/ui/doc/doc_lazy_list.rs#L54-L76
Thanks for taking a look!
For example, doc like
If I understand correctly, that doc is wrong but for other reasons, which makes it hard to offer fixes for; i.e. it should be e.g.
/// - First line. Here's an sample object:
/// ```json
/// {
/// 'protocol': 25,
/// 'data': 0xffff
/// }
/// ```
/// - Second line.
In any case, please note that even if the lint does not offer fixes (automatic or not), it would still be valuable to have it!
For instance, here it would have detected that broken documentation text.
doc is wrong but for other reasons
Yeah, you're right.
So, it seems like doc in tests/ui/doc/doc_lazy_list.rs
test is also wrong, and we should modify it together.
In any case, please note that even if the lint does not offer fixes (automatic or not), it would still be valuable to have it!
Agreed.
I'll probably take another look later. Thanks!
Yeah, that last example in tests/ui/doc/doc_lazy_list.rs
looks broken to me; however, it seems it was added to test for an ICE (from the comment linked there), i.e. it may be intentionally broken, which would be fine since it is a test. Thanks!
What it does
The lint reports overindented lines, for instance in bullet lists (and potentially elsewhere?).
This could perhaps be considered a false negative of
doc_lazy_continuation
, but "lazy continuation lines" only cover removing indentation, not adding it.Advantage
The advantages would be similar to
doc_lazy_continuation
:Clearer (easier to read) documentation in plain text form, i.e. unrendered, which is important in some projects.
More consistency in documentation comments across a project (and across different projects, for those that enable the lint).
Drawbacks
No response
Example
Could be written as: