Skip to content

Commit aaa5574

Browse files
authored
Rollup merge of #100718 - GuillaumeGomez:fix-item-info, r=jsha
[rustdoc] Fix item info display Fixes #100369. The solution I came up with was simply to wrap the "text part" of the `item-info` into another span so that `flex` wouldn't mess with it. Live demo is [here](https://rustdoc.crud.net/imperio/fix-item-info/foo/struct.ItemInfo.html). r? ``@jsha``
2 parents e81b994 + 0df1c69 commit aaa5574

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

src/librustdoc/html/render/mod.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,10 @@ fn short_item_info(
569569
message.push_str(&format!(": {}", html.into_string()));
570570
}
571571
extra_info.push(format!(
572-
"<div class=\"stab deprecated\"><span class=\"emoji\">👎</span> {}</div>",
572+
"<div class=\"stab deprecated\">\
573+
<span class=\"emoji\">👎</span>\
574+
<span>{}</span>\
575+
</div>",
573576
message,
574577
));
575578
}
@@ -582,8 +585,9 @@ fn short_item_info(
582585
.filter(|stab| stab.feature != sym::rustc_private)
583586
.map(|stab| (stab.level, stab.feature))
584587
{
585-
let mut message =
586-
"<span class=\"emoji\">🔬</span> This is a nightly-only experimental API.".to_owned();
588+
let mut message = "<span class=\"emoji\">🔬</span>\
589+
<span>This is a nightly-only experimental API."
590+
.to_owned();
587591

588592
let mut feature = format!("<code>{}</code>", Escape(feature.as_str()));
589593
if let (Some(url), Some(issue)) = (&cx.shared.issue_tracker_base_url, issue) {
@@ -594,7 +598,7 @@ fn short_item_info(
594598
));
595599
}
596600

597-
message.push_str(&format!(" ({})", feature));
601+
message.push_str(&format!(" ({})</span>", feature));
598602

599603
extra_info.push(format!("<div class=\"stab unstable\">{}</div>", message));
600604
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,7 @@ so that we can apply CSS-filters to change the arrow color in themes */
11641164

11651165
.stab .emoji {
11661166
font-size: 1.25rem;
1167+
margin-right: 0.3rem;
11671168
}
11681169

11691170
/* Black one-pixel outline around emoji shapes */

src/test/rustdoc/issue-32374.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,24 @@
88
// 'Experimental'
99
// @matches issue_32374/index.html '//*[@class="item-right docblock-short"]/text()' 'Docs'
1010

11-
// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]' \
12-
// '👎 Deprecated since 1.0.0: text'
11+
// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' '👎'
12+
// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' \
13+
// 'Deprecated since 1.0.0: text'
1314
// @hasraw - '<code>test</code>&nbsp;<a href="https://issue_url/32374">#32374</a>'
15+
// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' '🔬'
1416
// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \
15-
// '🔬 This is a nightly-only experimental API. \(test\s#32374\)$'
17+
// 'This is a nightly-only experimental API. \(test\s#32374\)$'
1618
/// Docs
1719
#[deprecated(since = "1.0.0", note = "text")]
1820
#[unstable(feature = "test", issue = "32374")]
1921
pub struct T;
2022

23+
// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' '👎'
2124
// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' \
22-
// '👎 Deprecated since 1.0.0: deprecated'
25+
// 'Deprecated since 1.0.0: deprecated'
26+
// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' '🔬'
2327
// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' \
24-
// '🔬 This is a nightly-only experimental API. (test #32374)'
28+
// 'This is a nightly-only experimental API. (test #32374)'
2529
#[deprecated(since = "1.0.0", note = "deprecated")]
2630
#[unstable(feature = "test", issue = "32374", reason = "unstable")]
2731
pub struct U;

0 commit comments

Comments
 (0)