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``
This commit is contained in:
Matthias Krüger 2022-08-20 19:45:14 +02:00 committed by GitHub
commit aaa5574a18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 9 deletions

View File

@ -569,7 +569,10 @@ fn short_item_info(
message.push_str(&format!(": {}", html.into_string()));
}
extra_info.push(format!(
"<div class=\"stab deprecated\"><span class=\"emoji\">👎</span> {}</div>",
"<div class=\"stab deprecated\">\
<span class=\"emoji\">👎</span>\
<span>{}</span>\
</div>",
message,
));
}
@ -582,8 +585,9 @@ fn short_item_info(
.filter(|stab| stab.feature != sym::rustc_private)
.map(|stab| (stab.level, stab.feature))
{
let mut message =
"<span class=\"emoji\">🔬</span> This is a nightly-only experimental API.".to_owned();
let mut message = "<span class=\"emoji\">🔬</span>\
<span>This is a nightly-only experimental API."
.to_owned();
let mut feature = format!("<code>{}</code>", Escape(feature.as_str()));
if let (Some(url), Some(issue)) = (&cx.shared.issue_tracker_base_url, issue) {
@ -594,7 +598,7 @@ fn short_item_info(
));
}
message.push_str(&format!(" ({})", feature));
message.push_str(&format!(" ({})</span>", feature));
extra_info.push(format!("<div class=\"stab unstable\">{}</div>", message));
}

View File

@ -1164,6 +1164,7 @@ so that we can apply CSS-filters to change the arrow color in themes */
.stab .emoji {
font-size: 1.25rem;
margin-right: 0.3rem;
}
/* Black one-pixel outline around emoji shapes */

View File

@ -8,20 +8,24 @@
// 'Experimental'
// @matches issue_32374/index.html '//*[@class="item-right docblock-short"]/text()' 'Docs'
// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]' \
// '👎 Deprecated since 1.0.0: text'
// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' '👎'
// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' \
// 'Deprecated since 1.0.0: text'
// @hasraw - '<code>test</code>&nbsp;<a href="https://issue_url/32374">#32374</a>'
// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' '🔬'
// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \
// '🔬 This is a nightly-only experimental API. \(test\s#32374\)$'
// 'This is a nightly-only experimental API. \(test\s#32374\)$'
/// Docs
#[deprecated(since = "1.0.0", note = "text")]
#[unstable(feature = "test", issue = "32374")]
pub struct T;
// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' '👎'
// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' \
// '👎 Deprecated since 1.0.0: deprecated'
// 'Deprecated since 1.0.0: deprecated'
// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' '🔬'
// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' \
// '🔬 This is a nightly-only experimental API. (test #32374)'
// 'This is a nightly-only experimental API. (test #32374)'
#[deprecated(since = "1.0.0", note = "deprecated")]
#[unstable(feature = "test", issue = "32374", reason = "unstable")]
pub struct U;