Lists doc comments fix4041 (#5560)

* add + start of an itemized line

* add test

* fix format

* fix tests

* update doc comment
This commit is contained in:
Thaqib 2023-02-01 22:26:12 -05:00 committed by GitHub
parent 3f36c997bf
commit e2996a807b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -432,7 +432,7 @@ impl CodeBlockAttribute {
/// Block that is formatted as an item.
///
/// An item starts with either a star `*` a dash `-` or a greater-than `>`.
/// An item starts with either a star `*` a dash `-` a greater-than `>` or a plus '+'.
/// Different level of indentation are handled by shrinking the shape accordingly.
struct ItemizedBlock {
/// the lines that are identified as part of an itemized block
@ -449,7 +449,8 @@ impl ItemizedBlock {
/// Returns `true` if the line is formatted as an item
fn is_itemized_line(line: &str) -> bool {
let trimmed = line.trim_start();
trimmed.starts_with("* ") || trimmed.starts_with("- ") || trimmed.starts_with("> ")
let itemized_start = ["* ", "- ", "> ", "+ "];
itemized_start.iter().any(|s| trimmed.starts_with(s))
}
/// Creates a new ItemizedBlock described with the given line.

View File

@ -0,0 +1,5 @@
// rustfmt-wrap_comments: true
//! List:
//! - Sub list:
//! + very long #1 blah blah blah blah blah blah blah blah blah blah blah blah foo baar baxxxxxxxx long line 1231421230912i3091238192038
//! + very long #2 blah blah blah blah blah blah blah blah blah blah blah blah

View File

@ -0,0 +1,6 @@
// rustfmt-wrap_comments: true
//! List:
//! - Sub list:
//! + very long #1 blah blah blah blah blah blah blah blah blah blah blah blah
//! foo baar baxxxxxxxx long line 1231421230912i3091238192038
//! + very long #2 blah blah blah blah blah blah blah blah blah blah blah blah