Skip to content

Commit 88d9df0

Browse files
committed
rustdoc: don't give depreciation notes special handling
1 parent 8c52f73 commit 88d9df0

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/librustdoc/html/markdown.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ pub(crate) struct MarkdownWithToc<'a> {
109109
pub(crate) edition: Edition,
110110
pub(crate) playground: &'a Option<Playground>,
111111
}
112-
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
112+
113+
/// A struct like `Markdown` that renders the markdown escaping HTML tags
113114
/// and includes no paragraph tags.
114115
pub(crate) struct MarkdownItemInfo<'a> {
115116
pub(crate) content: &'a str,
116117
pub(crate) links: &'a [RenderedLink],
117118
pub(crate) ids: &'a mut IdMap,
118119
}
120+
119121
/// A tuple struct like `Markdown` that renders only the first paragraph.
120122
pub(crate) struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]);
121123

@@ -1497,10 +1499,10 @@ impl<'a> MarkdownItemInfo<'a> {
14971499
let p = SpannedLinkReplacer::new(p, links);
14981500
let p = footnotes::Footnotes::new(p, existing_footnotes);
14991501
let p = TableWrapper::new(p.map(|(ev, _)| ev));
1500-
let p = p.filter(|event| {
1501-
!matches!(event, Event::Start(Tag::Paragraph) | Event::End(TagEnd::Paragraph))
1502-
});
1503-
html::write_html_fmt(&mut f, p)
1502+
// in legacy wrap mode, strip <p> elements to avoid them inserting newlines
1503+
html::write_html_fmt(&mut f, p)?;
1504+
1505+
Ok(())
15041506
})
15051507
}
15061508
}

src/librustdoc/html/markdown/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ fn test_markdown_html_escape() {
472472
let mut idmap = IdMap::new();
473473
let mut output = String::new();
474474
MarkdownItemInfo::new(input, &[], &mut idmap).write_into(&mut output).unwrap();
475-
assert_eq!(output, expect, "original: {}", input);
475+
assert_eq!(output, format!("<p>{}</p>", expect), "original: {}", input);
476476
}
477477

478478
t("`Struct<'a, T>`", "<code>Struct&lt;'a, T&gt;</code>");

src/librustdoc/html/static/css/rustdoc.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,6 @@ so that we can apply CSS-filters to change the arrow color in themes */
15851585
color: var(--main-color);
15861586
background-color: var(--stab-background-color);
15871587
width: fit-content;
1588-
white-space: pre-wrap;
15891588
border-radius: 3px;
15901589
display: inline;
15911590
vertical-align: baseline;

tests/rustdoc-html/deprecated.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ pub struct W;
3030
// 'Deprecated: shorthand reason: code$'
3131
#[deprecated = "shorthand reason: `code`"]
3232
pub struct X;
33+
34+
//@ matches deprecated/struct.Y.html '//*[@class="stab deprecated"]//p[1]' 'multiple'
35+
//@ matches deprecated/struct.Y.html '//*[@class="stab deprecated"]//p[2]' 'paragraphs'
36+
#[deprecated = "multiple\n\nparagraphs"]
37+
pub struct Y;

0 commit comments

Comments
 (0)