Skip to content

Commit 51a9639

Browse files
authored
Rollup merge of rust-lang#149931 - lolbinarycat:rustdoc-depr-html-future, r=GuillaumeGomez
rustdoc: don't give depreciation notes special handling based on discussion in rust-lang#149741 we're currently using pre-wrap here which forces us to do a bunch of other hacky weird stuff, but getting rid of all that would likely break some existing docs, so i'm proposing we do it across an edition. r? @GuillaumeGomez
2 parents cef2175 + 438b126 commit 51a9639

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

@@ -1490,10 +1492,10 @@ impl<'a> MarkdownItemInfo<'a> {
14901492
let p = SpannedLinkReplacer::new(p, links);
14911493
let p = footnotes::Footnotes::new(p, existing_footnotes);
14921494
let p = TableWrapper::new(p.map(|(ev, _)| ev));
1493-
let p = p.filter(|event| {
1494-
!matches!(event, Event::Start(Tag::Paragraph) | Event::End(TagEnd::Paragraph))
1495-
});
1496-
html::write_html_fmt(&mut f, p)
1495+
// in legacy wrap mode, strip <p> elements to avoid them inserting newlines
1496+
html::write_html_fmt(&mut f, p)?;
1497+
1498+
Ok(())
14971499
})
14981500
}
14991501
}

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>\n", 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
@@ -1606,7 +1606,6 @@ so that we can apply CSS-filters to change the arrow color in themes */
16061606
color: var(--main-color);
16071607
background-color: var(--stab-background-color);
16081608
width: fit-content;
1609-
white-space: pre-wrap;
16101609
border-radius: 3px;
16111610
display: inline;
16121611
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)