Skip to content

Commit dd73848

Browse files
Add tooltip for important traits display
1 parent d86621f commit dd73848

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/librustdoc/html/render.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -3255,6 +3255,7 @@ fn render_spotlight_traits(item: &clean::Item) -> Result<String, fmt::Error> {
32553255

32563256
fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> {
32573257
let mut out = String::new();
3258+
let mut trait_ = String::new();
32583259

32593260
if let Some(did) = decl.output.def_id() {
32603261
let c = cache();
@@ -3265,9 +3266,10 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> {
32653266
.map_or(false, |t| t.is_spotlight) {
32663267
if out.is_empty() {
32673268
out.push_str(
3268-
&format!("<h3 class=\"important\">Important traits for {}</h3>",
3269+
&format!("<h3 class=\"important\">Important traits for {}</h3>\
3270+
<code class=\"content\">",
32693271
impl_.for_));
3270-
out.push_str("<code class=\"content\">");
3272+
trait_.push_str(&format!("{}", impl_.for_));
32713273
}
32723274

32733275
//use the "where" class here to make it small
@@ -3288,8 +3290,11 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> {
32883290
}
32893291

32903292
if !out.is_empty() {
3291-
out.insert_str(0, "<div class=\"important-traits\">ⓘ<div class=\"content hidden\">");
3292-
out.push_str("</code></span></div></div>");
3293+
out.insert_str(0, &format!("<div class=\"important-traits\"><div class='tooltip'>ⓘ\
3294+
<span class='tooltiptext'>Important traits for {}</span></div>\
3295+
<div class=\"content hidden\">",
3296+
trait_));
3297+
out.push_str("</code></div></div>");
32933298
}
32943299

32953300
Ok(out)

src/librustdoc/html/static/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@
17371737

17381738
onEach(document.getElementsByClassName('important-traits'), function(e) {
17391739
e.onclick = function() {
1740-
showModal(e.firstElementChild.innerHTML);
1740+
showModal(e.lastElementChild.innerHTML);
17411741
};
17421742
});
17431743

src/librustdoc/html/static/rustdoc.css

+1
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ pre.rust {
958958

959959
.important-traits {
960960
cursor: pointer;
961+
z-index: 2;
961962
}
962963

963964
h4 > .important-traits {

0 commit comments

Comments
 (0)