Add tooltip for important traits display
This commit is contained in:
parent
d86621f69e
commit
6047a03659
@ -3255,6 +3255,7 @@ fn render_spotlight_traits(item: &clean::Item) -> Result<String, fmt::Error> {
|
|||||||
|
|
||||||
fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> {
|
fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> {
|
||||||
let mut out = String::new();
|
let mut out = String::new();
|
||||||
|
let mut trait_ = String::new();
|
||||||
|
|
||||||
if let Some(did) = decl.output.def_id() {
|
if let Some(did) = decl.output.def_id() {
|
||||||
let c = cache();
|
let c = cache();
|
||||||
@ -3265,9 +3266,10 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> {
|
|||||||
.map_or(false, |t| t.is_spotlight) {
|
.map_or(false, |t| t.is_spotlight) {
|
||||||
if out.is_empty() {
|
if out.is_empty() {
|
||||||
out.push_str(
|
out.push_str(
|
||||||
&format!("<h3 class=\"important\">Important traits for {}</h3>",
|
&format!("<h3 class=\"important\">Important traits for {}</h3>\
|
||||||
|
<code class=\"content\">",
|
||||||
impl_.for_));
|
impl_.for_));
|
||||||
out.push_str("<code class=\"content\">");
|
trait_.push_str(&format!("{}", impl_.for_));
|
||||||
}
|
}
|
||||||
|
|
||||||
//use the "where" class here to make it small
|
//use the "where" class here to make it small
|
||||||
@ -3288,8 +3290,11 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !out.is_empty() {
|
if !out.is_empty() {
|
||||||
out.insert_str(0, "<div class=\"important-traits\">ⓘ<div class=\"content hidden\">");
|
out.insert_str(0, &format!("<div class=\"important-traits\"><div class='tooltip'>ⓘ\
|
||||||
out.push_str("</code></span></div></div>");
|
<span class='tooltiptext'>Important traits for {}</span></div>\
|
||||||
|
<div class=\"content hidden\">",
|
||||||
|
trait_));
|
||||||
|
out.push_str("</code></div></div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(out)
|
Ok(out)
|
||||||
|
@ -1737,7 +1737,7 @@
|
|||||||
|
|
||||||
onEach(document.getElementsByClassName('important-traits'), function(e) {
|
onEach(document.getElementsByClassName('important-traits'), function(e) {
|
||||||
e.onclick = function() {
|
e.onclick = function() {
|
||||||
showModal(e.firstElementChild.innerHTML);
|
showModal(e.lastElementChild.innerHTML);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -958,6 +958,7 @@ pre.rust {
|
|||||||
|
|
||||||
.important-traits {
|
.important-traits {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
h4 > .important-traits {
|
h4 > .important-traits {
|
||||||
|
@ -19,7 +19,7 @@ impl<T: SomeTrait> SomeTrait for Wrapper<T> {}
|
|||||||
#[doc(spotlight)]
|
#[doc(spotlight)]
|
||||||
pub trait SomeTrait {
|
pub trait SomeTrait {
|
||||||
// @has doc_spotlight/trait.SomeTrait.html
|
// @has doc_spotlight/trait.SomeTrait.html
|
||||||
// @has - '//code[@class="spotlight"]' 'impl<T: SomeTrait> SomeTrait for Wrapper<T>'
|
// @has - '//code[@class="content"]' 'impl<T: SomeTrait> SomeTrait for Wrapper<T>'
|
||||||
fn wrap_me(self) -> Wrapper<Self> where Self: Sized {
|
fn wrap_me(self) -> Wrapper<Self> where Self: Sized {
|
||||||
Wrapper {
|
Wrapper {
|
||||||
inner: self,
|
inner: self,
|
||||||
@ -32,15 +32,15 @@ impl SomeTrait for SomeStruct {}
|
|||||||
|
|
||||||
impl SomeStruct {
|
impl SomeStruct {
|
||||||
// @has doc_spotlight/struct.SomeStruct.html
|
// @has doc_spotlight/struct.SomeStruct.html
|
||||||
// @has - '//code[@class="spotlight"]' 'impl SomeTrait for SomeStruct'
|
// @has - '//code[@class="content"]' 'impl SomeTrait for SomeStruct'
|
||||||
// @has - '//code[@class="spotlight"]' 'impl<T: SomeTrait> SomeTrait for Wrapper<T>'
|
// @has - '//code[@class="content"]' 'impl<T: SomeTrait> SomeTrait for Wrapper<T>'
|
||||||
pub fn new() -> SomeStruct {
|
pub fn new() -> SomeStruct {
|
||||||
SomeStruct
|
SomeStruct
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @has doc_spotlight/fn.bare_fn.html
|
// @has doc_spotlight/fn.bare_fn.html
|
||||||
// @has - '//code[@class="spotlight"]' 'impl SomeTrait for SomeStruct'
|
// @has - '//code[@class="content"]' 'impl SomeTrait for SomeStruct'
|
||||||
pub fn bare_fn() -> SomeStruct {
|
pub fn bare_fn() -> SomeStruct {
|
||||||
SomeStruct
|
SomeStruct
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user