Rollup merge of #92357 - GuillaumeGomez:fix-doc-comment-backline-removal, r=camelid
Fix invalid removal of newlines from doc comments Fixes https://github.com/rust-lang/rust/issues/91201. Before:  After:  r? `@camelid`
This commit is contained in:
commit
d20affbf8d
4 changed files with 12 additions and 9 deletions
|
@ -34,18 +34,11 @@ pub fn beautify_doc_string(data: Symbol) -> Symbol {
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while i < j && lines[i].trim().is_empty() {
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
// like the first, a last line of all stars should be omitted
|
// like the first, a last line of all stars should be omitted
|
||||||
if j > i && !lines[j - 1].is_empty() && lines[j - 1].chars().all(|c| c == '*') {
|
if j > i && !lines[j - 1].is_empty() && lines[j - 1].chars().all(|c| c == '*') {
|
||||||
j -= 1;
|
j -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while j > i && lines[j - 1].trim().is_empty() {
|
|
||||||
j -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if i != 0 || j != lines.len() { Some((i, j)) } else { None }
|
if i != 0 || j != lines.len() { Some((i, j)) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="docblock"><p>Hello world!
|
<div class="docblock"><p>Hello world!</p>
|
||||||
Goodbye!
|
<p>Goodbye!
|
||||||
Hello again!</p>
|
Hello again!</p>
|
||||||
</div>
|
</div>
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div class="docblock"><p>Par 1</p>
|
||||||
|
<p>Par 2</p>
|
||||||
|
</div>
|
|
@ -16,3 +16,10 @@ pub struct S1;
|
||||||
#[doc = "Goodbye!"]
|
#[doc = "Goodbye!"]
|
||||||
/// Hello again!
|
/// Hello again!
|
||||||
pub struct S2;
|
pub struct S2;
|
||||||
|
|
||||||
|
// @has 'foo/struct.S3.html'
|
||||||
|
// @snapshot S3_top-doc - '//details[@class="rustdoc-toggle top-doc"]/div[@class="docblock"]'
|
||||||
|
/** Par 1
|
||||||
|
*/ ///
|
||||||
|
/// Par 2
|
||||||
|
pub struct S3;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue