Fix hover on impls
This commit is contained in:
parent
c318691407
commit
d65c8636d9
4 changed files with 47 additions and 39 deletions
|
@ -2678,7 +2678,6 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||||
|
|
||||||
fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter,
|
fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter,
|
||||||
implementor_dups: &FxHashMap<&str, (DefId, bool)>) -> fmt::Result {
|
implementor_dups: &FxHashMap<&str, (DefId, bool)>) -> fmt::Result {
|
||||||
write!(w, "<li><table class='table-display'><tbody><tr><td><code>")?;
|
|
||||||
// If there's already another implementor that has the same abbridged name, use the
|
// If there's already another implementor that has the same abbridged name, use the
|
||||||
// full path, for example in `std::iter::ExactSizeIterator`
|
// full path, for example in `std::iter::ExactSizeIterator`
|
||||||
let use_absolute = match implementor.inner_impl().for_ {
|
let use_absolute = match implementor.inner_impl().for_ {
|
||||||
|
@ -2689,22 +2688,8 @@ fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter,
|
||||||
} => implementor_dups[path.last_name()].1,
|
} => implementor_dups[path.last_name()].1,
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
fmt_impl_for_trait_page(&implementor.inner_impl(), w, use_absolute)?;
|
render_impl(w, cx, implementor, AssocItemLink::Anchor(None), RenderMode::Normal,
|
||||||
for it in &implementor.inner_impl().items {
|
implementor.impl_item.stable_since(), true, Some(use_absolute))?;
|
||||||
if let clean::TypedefItem(ref tydef, _) = it.inner {
|
|
||||||
write!(w, "<span class=\"where fmt-newline\"> ")?;
|
|
||||||
assoc_type(w, it, &[], Some(&tydef.type_), AssocItemLink::Anchor(None))?;
|
|
||||||
write!(w, ";</span>")?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
write!(w, "</code><td>")?;
|
|
||||||
if let Some(l) = (Item { cx, item: &implementor.impl_item }).src_href() {
|
|
||||||
write!(w, "<div class='out-of-band'>")?;
|
|
||||||
write!(w, "<a class='srclink' href='{}' title='{}'>[src]</a>",
|
|
||||||
l, "goto source code")?;
|
|
||||||
write!(w, "</div>")?;
|
|
||||||
}
|
|
||||||
writeln!(w, "</td></tr></tbody></table></li>")?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2715,7 +2700,7 @@ fn render_impls(cx: &Context, w: &mut fmt::Formatter,
|
||||||
let did = i.trait_did().unwrap();
|
let did = i.trait_did().unwrap();
|
||||||
let assoc_link = AssocItemLink::GotoSource(did, &i.inner_impl().provided_trait_methods);
|
let assoc_link = AssocItemLink::GotoSource(did, &i.inner_impl().provided_trait_methods);
|
||||||
render_impl(w, cx, i, assoc_link,
|
render_impl(w, cx, i, assoc_link,
|
||||||
RenderMode::Normal, containing_item.stable_since(), true)?;
|
RenderMode::Normal, containing_item.stable_since(), true, None)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -2964,7 +2949,8 @@ fn item_trait(
|
||||||
&implementor.inner_impl().provided_trait_methods
|
&implementor.inner_impl().provided_trait_methods
|
||||||
);
|
);
|
||||||
render_impl(w, cx, &implementor, assoc_link,
|
render_impl(w, cx, &implementor, assoc_link,
|
||||||
RenderMode::Normal, implementor.impl_item.stable_since(), false)?;
|
RenderMode::Normal, implementor.impl_item.stable_since(), false,
|
||||||
|
None)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2973,7 +2959,7 @@ fn item_trait(
|
||||||
for implementor in concrete {
|
for implementor in concrete {
|
||||||
render_implementor(cx, implementor, w, &implementor_dups)?;
|
render_implementor(cx, implementor, w, &implementor_dups)?;
|
||||||
}
|
}
|
||||||
write!(w, "</ul>")?;
|
write!(w, "</div>")?;
|
||||||
|
|
||||||
if t.auto {
|
if t.auto {
|
||||||
write!(w, "{}", synthetic_impl_header)?;
|
write!(w, "{}", synthetic_impl_header)?;
|
||||||
|
@ -2983,17 +2969,17 @@ fn item_trait(
|
||||||
);
|
);
|
||||||
render_implementor(cx, implementor, w, &implementor_dups)?;
|
render_implementor(cx, implementor, w, &implementor_dups)?;
|
||||||
}
|
}
|
||||||
write!(w, "</ul>")?;
|
write!(w, "</div>")?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// even without any implementations to write in, we still want the heading and list, so the
|
// even without any implementations to write in, we still want the heading and list, so the
|
||||||
// implementors javascript file pulled in below has somewhere to write the impls into
|
// implementors javascript file pulled in below has somewhere to write the impls into
|
||||||
write!(w, "{}", impl_header)?;
|
write!(w, "{}", impl_header)?;
|
||||||
write!(w, "</ul>")?;
|
write!(w, "</div>")?;
|
||||||
|
|
||||||
if t.auto {
|
if t.auto {
|
||||||
write!(w, "{}", synthetic_impl_header)?;
|
write!(w, "{}", synthetic_impl_header)?;
|
||||||
write!(w, "</ul>")?;
|
write!(w, "</div>")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(w, r#"<script type="text/javascript">window.inlined_types=new Set({});</script>"#,
|
write!(w, r#"<script type="text/javascript">window.inlined_types=new Set({});</script>"#,
|
||||||
|
@ -3616,7 +3602,7 @@ fn render_assoc_items(w: &mut fmt::Formatter,
|
||||||
};
|
};
|
||||||
for i in &non_trait {
|
for i in &non_trait {
|
||||||
render_impl(w, cx, i, AssocItemLink::Anchor(None), render_mode,
|
render_impl(w, cx, i, AssocItemLink::Anchor(None), render_mode,
|
||||||
containing_item.stable_since(), true)?;
|
containing_item.stable_since(), true, None)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let AssocItemRender::DerefFor { .. } = what {
|
if let AssocItemRender::DerefFor { .. } = what {
|
||||||
|
@ -3797,15 +3783,29 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> {
|
||||||
|
|
||||||
fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLink,
|
fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLink,
|
||||||
render_mode: RenderMode, outer_version: Option<&str>,
|
render_mode: RenderMode, outer_version: Option<&str>,
|
||||||
show_def_docs: bool) -> fmt::Result {
|
show_def_docs: bool, use_absolute: Option<bool>) -> fmt::Result {
|
||||||
if render_mode == RenderMode::Normal {
|
if render_mode == RenderMode::Normal {
|
||||||
let id = cx.derive_id(match i.inner_impl().trait_ {
|
let id = cx.derive_id(match i.inner_impl().trait_ {
|
||||||
Some(ref t) => format!("impl-{}", small_url_encode(&format!("{:#}", t))),
|
Some(ref t) => format!("impl-{}", small_url_encode(&format!("{:#}", t))),
|
||||||
None => "impl".to_string(),
|
None => "impl".to_string(),
|
||||||
});
|
});
|
||||||
|
if let Some(use_absolute) = use_absolute {
|
||||||
|
write!(w, "<h3 id='{}' class='impl'><span class='in-band'><table class='table-display'>\
|
||||||
|
<tbody><tr><td><code>", id)?;
|
||||||
|
fmt_impl_for_trait_page(&i.inner_impl(), w, use_absolute)?;
|
||||||
|
for it in &i.inner_impl().items {
|
||||||
|
if let clean::TypedefItem(ref tydef, _) = it.inner {
|
||||||
|
write!(w, "<span class=\"where fmt-newline\"> ")?;
|
||||||
|
assoc_type(w, it, &vec![], Some(&tydef.type_), AssocItemLink::Anchor(None))?;
|
||||||
|
write!(w, ";</span>")?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
write!(w, "</code>")?;
|
||||||
|
} else {
|
||||||
write!(w, "<h3 id='{}' class='impl'><span class='in-band'><table class='table-display'>\
|
write!(w, "<h3 id='{}' class='impl'><span class='in-band'><table class='table-display'>\
|
||||||
<tbody><tr><td><code>{}</code>",
|
<tbody><tr><td><code>{}</code>",
|
||||||
id, i.inner_impl())?;
|
id, i.inner_impl())?;
|
||||||
|
}
|
||||||
write!(w, "<a href='#{}' class='anchor'></a>", id)?;
|
write!(w, "<a href='#{}' class='anchor'></a>", id)?;
|
||||||
write!(w, "</span></td><td><span class='out-of-band'>")?;
|
write!(w, "</span></td><td><span class='out-of-band'>")?;
|
||||||
let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]);
|
let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]);
|
||||||
|
|
|
@ -114,7 +114,7 @@ h3.impl, h3.method, h3.type {
|
||||||
|
|
||||||
h1, h2, h3, h4,
|
h1, h2, h3, h4,
|
||||||
.sidebar, a.source, .search-input, .content table :not(code)>a,
|
.sidebar, a.source, .search-input, .content table :not(code)>a,
|
||||||
.collapse-toggle, ul.item-list > li > .out-of-band {
|
.collapse-toggle, div.item-list .out-of-band {
|
||||||
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,10 +367,6 @@ h4.method > .out-of-band {
|
||||||
font-size: 19px;
|
font-size: 19px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.item-list > li > .out-of-band {
|
|
||||||
font-size: 19px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h4 > code, h3 > code, .invisible > code {
|
h4 > code, h3 > code, .invisible > code {
|
||||||
max-width: calc(100% - 41px);
|
max-width: calc(100% - 41px);
|
||||||
display: block;
|
display: block;
|
||||||
|
@ -436,10 +432,6 @@ h4 > code, h3 > code, .invisible > code {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content .item-list li {
|
|
||||||
margin-bottom: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content .multi-column {
|
.content .multi-column {
|
||||||
-moz-column-count: 5;
|
-moz-column-count: 5;
|
||||||
-moz-column-gap: 2.5em;
|
-moz-column-gap: 2.5em;
|
||||||
|
@ -473,6 +465,11 @@ h4 > code, h3 > code, .invisible > code {
|
||||||
.content .impl-items .docblock, .content .impl-items .stability {
|
.content .impl-items .docblock, .content .impl-items .stability {
|
||||||
margin-bottom: .6em;
|
margin-bottom: .6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.content .impl-items > .stability {
|
||||||
|
margin-left: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
.content .docblock > .impl-items {
|
.content .docblock > .impl-items {
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
margin-top: -34px;
|
margin-top: -34px;
|
||||||
|
@ -1363,6 +1360,15 @@ kbd {
|
||||||
font-size: 19px;
|
font-size: 19px;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
#implementors-list > .impl-items .table-display .out-of-band {
|
||||||
|
font-size: 17px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-display td:hover .anchor {
|
||||||
|
display: block;
|
||||||
|
top: 2px;
|
||||||
|
left: -5px;
|
||||||
|
}
|
||||||
|
|
||||||
#main > ul {
|
#main > ul {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub mod unix_only {
|
||||||
// @has doc_cfg/unix_only/trait.ArmOnly.html \
|
// @has doc_cfg/unix_only/trait.ArmOnly.html \
|
||||||
// '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
|
// '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
|
||||||
// 'This is supported on Unix and ARM only.'
|
// 'This is supported on Unix and ARM only.'
|
||||||
// @count - '//*[@class="stab portability"]' 2
|
// @count - '//*[@class="stab portability"]' 3
|
||||||
#[doc(cfg(target_arch = "arm"))]
|
#[doc(cfg(target_arch = "arm"))]
|
||||||
pub trait ArmOnly {
|
pub trait ArmOnly {
|
||||||
fn unix_and_arm_only_function();
|
fn unix_and_arm_only_function();
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// ignore-tidy-linelength
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
// @has issue_29503/trait.MyTrait.html
|
// @has issue_29503/trait.MyTrait.html
|
||||||
|
@ -15,7 +17,7 @@ pub trait MyTrait {
|
||||||
fn my_string(&self) -> String;
|
fn my_string(&self) -> String;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @has - "//ul[@id='implementors-list']/li" "impl<T> MyTrait for T where T: Debug"
|
// @has - "//div[@id='implementors-list']/h3[@id='impl-MyTrait']//code" "impl<T> MyTrait for T where T: Debug"
|
||||||
impl<T> MyTrait for T where T: fmt::Debug {
|
impl<T> MyTrait for T where T: fmt::Debug {
|
||||||
fn my_string(&self) -> String {
|
fn my_string(&self) -> String {
|
||||||
format!("{:?}", self)
|
format!("{:?}", self)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue