Preserve two or more trailing spaces in doc comment
rustdoc treats two or more trailing spaces as a line break.
This commit is contained in:
parent
296018afe7
commit
6f38a4aeab
3 changed files with 5 additions and 7 deletions
|
|
@ -508,11 +508,9 @@ pub fn recover_missing_comment_in_span(
|
|||
}
|
||||
}
|
||||
|
||||
/// Trim trailing whitespaces unless they consist of two whitespaces.
|
||||
/// Trim trailing whitespaces unless they consist of two or more whitespaces.
|
||||
fn trim_right_unless_two_whitespaces(s: &str, is_doc_comment: bool) -> &str {
|
||||
if is_doc_comment && s.ends_with(" ")
|
||||
&& !s.chars().rev().nth(2).map_or(true, char::is_whitespace)
|
||||
{
|
||||
if is_doc_comment && s.ends_with(" ") {
|
||||
s
|
||||
} else {
|
||||
s.trim_right()
|
||||
|
|
@ -541,7 +539,7 @@ fn light_rewrite_comment(
|
|||
} else {
|
||||
""
|
||||
};
|
||||
// Preserve markdown's double-space line break syntax.
|
||||
// Preserve markdown's double-space line break syntax in doc comment.
|
||||
trim_right_unless_two_whitespaces(left_trimmed, is_doc_comment)
|
||||
})
|
||||
.collect();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
//! hello world
|
||||
//! hello world
|
||||
|
||||
/// hello world
|
||||
/// hello world
|
||||
/// hello world
|
||||
/// hello world
|
||||
fn foo() {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
//! hello world
|
||||
//! hello world
|
||||
|
||||
/// hello world
|
||||
/// hello world
|
||||
/// hello world
|
||||
/// hello world
|
||||
fn foo() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue