add anchors links on hover to items from trait impl
This commit is contained in:
parent
e1b6bb214f
commit
45964368f4
2 changed files with 16 additions and 8 deletions
|
@ -1453,12 +1453,13 @@ fn render_impl(
|
||||||
} else {
|
} else {
|
||||||
(true, " hidden")
|
(true, " hidden")
|
||||||
};
|
};
|
||||||
|
let in_trait_class = if trait_.is_some() { " trait-impl" } else { "" };
|
||||||
match *item.kind {
|
match *item.kind {
|
||||||
clean::MethodItem(..) | clean::TyMethodItem(_) => {
|
clean::MethodItem(..) | clean::TyMethodItem(_) => {
|
||||||
// Only render when the method is not static or we allow static methods
|
// Only render when the method is not static or we allow static methods
|
||||||
if render_method_item {
|
if render_method_item {
|
||||||
let id = cx.derive_id(format!("{}.{}", item_type, name));
|
let id = cx.derive_id(format!("{}.{}", item_type, name));
|
||||||
write!(w, "<h4 id=\"{}\" class=\"{}{}\">", id, item_type, extra_class);
|
write!(w, "<h4 id=\"{}\" class=\"{}{}{}\">", id, item_type, extra_class, in_trait_class);
|
||||||
w.write_str("<code>");
|
w.write_str("<code>");
|
||||||
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl, cx);
|
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl, cx);
|
||||||
w.write_str("</code>");
|
w.write_str("</code>");
|
||||||
|
@ -1469,13 +1470,14 @@ fn render_impl(
|
||||||
outer_version,
|
outer_version,
|
||||||
outer_const_version,
|
outer_const_version,
|
||||||
);
|
);
|
||||||
|
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||||
write_srclink(cx, item, w);
|
write_srclink(cx, item, w);
|
||||||
w.write_str("</h4>");
|
w.write_str("</h4>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clean::TypedefItem(ref tydef, _) => {
|
clean::TypedefItem(ref tydef, _) => {
|
||||||
let id = cx.derive_id(format!("{}.{}", ItemType::AssocType, name));
|
let id = cx.derive_id(format!("{}.{}", ItemType::AssocType, name));
|
||||||
write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, extra_class);
|
write!(w, "<h4 id=\"{}\" class=\"{}{}{}\"><code>", id, item_type, extra_class, in_trait_class);
|
||||||
assoc_type(
|
assoc_type(
|
||||||
w,
|
w,
|
||||||
item,
|
item,
|
||||||
|
@ -1486,11 +1488,13 @@ fn render_impl(
|
||||||
cx.cache(),
|
cx.cache(),
|
||||||
tcx,
|
tcx,
|
||||||
);
|
);
|
||||||
w.write_str("</code></h4>");
|
w.write_str("</code>");
|
||||||
|
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||||
|
w.write_str("</h4>");
|
||||||
}
|
}
|
||||||
clean::AssocConstItem(ref ty, ref default) => {
|
clean::AssocConstItem(ref ty, ref default) => {
|
||||||
let id = cx.derive_id(format!("{}.{}", item_type, name));
|
let id = cx.derive_id(format!("{}.{}", item_type, name));
|
||||||
write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, extra_class);
|
write!(w, "<h4 id=\"{}\" class=\"{}{}{}\"><code>", id, item_type, extra_class, in_trait_class);
|
||||||
assoc_const(w, item, ty, default.as_ref(), link.anchor(&id), "", cx);
|
assoc_const(w, item, ty, default.as_ref(), link.anchor(&id), "", cx);
|
||||||
w.write_str("</code>");
|
w.write_str("</code>");
|
||||||
render_stability_since_raw(
|
render_stability_since_raw(
|
||||||
|
@ -1500,12 +1504,13 @@ fn render_impl(
|
||||||
outer_version,
|
outer_version,
|
||||||
outer_const_version,
|
outer_const_version,
|
||||||
);
|
);
|
||||||
|
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||||
write_srclink(cx, item, w);
|
write_srclink(cx, item, w);
|
||||||
w.write_str("</h4>");
|
w.write_str("</h4>");
|
||||||
}
|
}
|
||||||
clean::AssocTypeItem(ref bounds, ref default) => {
|
clean::AssocTypeItem(ref bounds, ref default) => {
|
||||||
let id = cx.derive_id(format!("{}.{}", item_type, name));
|
let id = cx.derive_id(format!("{}.{}", item_type, name));
|
||||||
write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, extra_class);
|
write!(w, "<h4 id=\"{}\" class=\"{}{}{}\"><code>", id, item_type, extra_class, in_trait_class);
|
||||||
assoc_type(
|
assoc_type(
|
||||||
w,
|
w,
|
||||||
item,
|
item,
|
||||||
|
@ -1516,7 +1521,9 @@ fn render_impl(
|
||||||
cx.cache(),
|
cx.cache(),
|
||||||
tcx,
|
tcx,
|
||||||
);
|
);
|
||||||
w.write_str("</code></h4>");
|
w.write_str("</code>");
|
||||||
|
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||||
|
w.write_str("</h4>");
|
||||||
}
|
}
|
||||||
clean::StrippedItem(..) => return,
|
clean::StrippedItem(..) => return,
|
||||||
_ => panic!("can't make docs for trait item with name {:?}", item.name),
|
_ => panic!("can't make docs for trait item with name {:?}", item.name),
|
||||||
|
|
|
@ -133,7 +133,7 @@ h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
h3.impl, h3.method, h3.type {
|
h3.impl, h3.method, h4.method.trait-impl, h3.type, h4.type.trait-impl, h4.associatedconstant.trait-impl {
|
||||||
padding-left: 15px;
|
padding-left: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,7 +655,8 @@ a {
|
||||||
display: initial;
|
display: initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
.in-band:hover > .anchor, .impl:hover > .anchor {
|
.in-band:hover > .anchor, .impl:hover > .anchor, .method.trait-impl:hover > .anchor,
|
||||||
|
.type.trait-impl:hover > .anchor, .associatedconstant.trait-impl:hover > .anchor {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue