mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
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:
parent
3f36c997bf
commit
e2996a807b
@ -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.
|
||||
|
5
tests/source/issue-4041.rs
Normal file
5
tests/source/issue-4041.rs
Normal 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
|
6
tests/target/issue-4041.rs
Normal file
6
tests/target/issue-4041.rs
Normal 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
|
Loading…
Reference in New Issue
Block a user