Skip to content

Commit 6d6d89b

Browse files
authored
Rollup merge of #102158 - notriddle:notriddle/stab-p, r=GuillaumeGomez
rustdoc: clean up CSS/DOM for deprecation warnings Preview: https://notriddle.com/notriddle-rustdoc-test/stab-p/std/macro.try.html
2 parents 0d01869 + 51f335d commit 6d6d89b

File tree

4 files changed

+17
-30
lines changed

4 files changed

+17
-30
lines changed

src/librustdoc/html/markdown.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,9 @@ pub(crate) struct MarkdownWithToc<'a>(
111111
pub(crate) Edition,
112112
pub(crate) &'a Option<Playground>,
113113
);
114-
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags.
115-
pub(crate) struct MarkdownHtml<'a>(
116-
pub(crate) &'a str,
117-
pub(crate) &'a mut IdMap,
118-
pub(crate) ErrorCodes,
119-
pub(crate) Edition,
120-
pub(crate) &'a Option<Playground>,
121-
);
114+
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
115+
/// and includes no paragraph tags.
116+
pub(crate) struct MarkdownItemInfo<'a>(pub(crate) &'a str, pub(crate) &'a mut IdMap);
122117
/// A tuple struct like `Markdown` that renders only the first paragraph.
123118
pub(crate) struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]);
124119

@@ -1072,9 +1067,9 @@ impl MarkdownWithToc<'_> {
10721067
}
10731068
}
10741069

1075-
impl MarkdownHtml<'_> {
1070+
impl MarkdownItemInfo<'_> {
10761071
pub(crate) fn into_string(self) -> String {
1077-
let MarkdownHtml(md, ids, codes, edition, playground) = self;
1072+
let MarkdownItemInfo(md, ids) = self;
10781073

10791074
// This is actually common enough to special-case
10801075
if md.is_empty() {
@@ -1093,7 +1088,9 @@ impl MarkdownHtml<'_> {
10931088
let p = HeadingLinks::new(p, None, ids, HeadingOffset::H1);
10941089
let p = Footnotes::new(p);
10951090
let p = TableWrapper::new(p.map(|(ev, _)| ev));
1096-
let p = CodeBlocks::new(p, codes, edition, playground);
1091+
let p = p.filter(|event| {
1092+
!matches!(event, Event::Start(Tag::Paragraph) | Event::End(Tag::Paragraph))
1093+
});
10971094
html::push_html(&mut s, p);
10981095

10991096
s

src/librustdoc/html/markdown/tests.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{find_testable_code, plain_text_summary, short_markdown_summary};
2-
use super::{ErrorCodes, HeadingOffset, IdMap, Ignore, LangString, Markdown, MarkdownHtml};
2+
use super::{ErrorCodes, HeadingOffset, IdMap, Ignore, LangString, Markdown, MarkdownItemInfo};
33
use rustc_span::edition::{Edition, DEFAULT_EDITION};
44

55
#[test]
@@ -279,14 +279,13 @@ fn test_plain_text_summary() {
279279
fn test_markdown_html_escape() {
280280
fn t(input: &str, expect: &str) {
281281
let mut idmap = IdMap::new();
282-
let output =
283-
MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
282+
let output = MarkdownItemInfo(input, &mut idmap).into_string();
284283
assert_eq!(output, expect, "original: {}", input);
285284
}
286285

287-
t("`Struct<'a, T>`", "<p><code>Struct&lt;'a, T&gt;</code></p>\n");
288-
t("Struct<'a, T>", "<p>Struct&lt;’a, T&gt;</p>\n");
289-
t("Struct<br>", "<p>Struct&lt;br&gt;</p>\n");
286+
t("`Struct<'a, T>`", "<code>Struct&lt;'a, T&gt;</code>");
287+
t("Struct<'a, T>", "Struct&lt;’a, T&gt;");
288+
t("Struct<br>", "Struct&lt;br&gt;");
290289
}
291290

292291
#[test]

src/librustdoc/html/render/mod.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ use crate::html::format::{
7474
PrintWithSpace,
7575
};
7676
use crate::html::highlight;
77-
use crate::html::markdown::{HeadingOffset, IdMap, Markdown, MarkdownHtml, MarkdownSummaryLine};
77+
use crate::html::markdown::{
78+
HeadingOffset, IdMap, Markdown, MarkdownItemInfo, MarkdownSummaryLine,
79+
};
7880
use crate::html::sources;
7981
use crate::html::static_files::SCRAPE_EXAMPLES_HELP_MD;
8082
use crate::scrape_examples::{CallData, CallLocation};
@@ -584,7 +586,6 @@ fn short_item_info(
584586
parent: Option<&clean::Item>,
585587
) -> Vec<String> {
586588
let mut extra_info = vec![];
587-
let error_codes = cx.shared.codes;
588589

589590
if let Some(depr @ Deprecation { note, since, is_since_rustc_version: _, suggestion: _ }) =
590591
item.deprecation(cx.tcx())
@@ -608,13 +609,7 @@ fn short_item_info(
608609

609610
if let Some(note) = note {
610611
let note = note.as_str();
611-
let html = MarkdownHtml(
612-
note,
613-
&mut cx.id_map,
614-
error_codes,
615-
cx.shared.edition(),
616-
&cx.shared.playground,
617-
);
612+
let html = MarkdownItemInfo(note, &mut cx.id_map);
618613
message.push_str(&format!(": {}", html.into_string()));
619614
}
620615
extra_info.push(format!(

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

-4
Original file line numberDiff line numberDiff line change
@@ -1068,10 +1068,6 @@ so that we can apply CSS-filters to change the arrow color in themes */
10681068
font-size: 0.875rem;
10691069
font-weight: normal;
10701070
}
1071-
.stab p {
1072-
display: inline;
1073-
margin: 0;
1074-
}
10751071

10761072
.stab .emoji {
10771073
font-size: 1.25rem;

0 commit comments

Comments
 (0)