Skip to content

Commit

Permalink
Rollup merge of rust-lang#100718 - GuillaumeGomez:fix-item-info, r=jsha
Browse files Browse the repository at this point in the history
[rustdoc] Fix item info display

Fixes  rust-lang#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`
  • Loading branch information
matthiaskrgr authored Aug 20, 2022
2 parents 5859af4 + 0df1c69 commit 1aaab54
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
));
}
Expand All @@ -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) {
Expand All @@ -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));
}
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
14 changes: 9 additions & 5 deletions src/test/rustdoc/issue-32374.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 1aaab54

Please sign in to comment.