Move spotlight next to the return type
This commit is contained in:
parent
3cecd6003b
commit
c90fb7185a
2 changed files with 14 additions and 36 deletions
|
@ -2410,12 +2410,12 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
|
||||||
f.generics.print()
|
f.generics.print()
|
||||||
)
|
)
|
||||||
.len();
|
.len();
|
||||||
write!(w, "{}<pre class='rust fn'>", render_spotlight_traits(it));
|
write!(w, "<pre class='rust fn'>");
|
||||||
render_attributes(w, it, false);
|
render_attributes(w, it, false);
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
|
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
|
||||||
{name}{generics}{decl}{where_clause}</pre>",
|
{name}{generics}{decl}{spotlight}{where_clause}</pre>",
|
||||||
vis = it.visibility.print_with_space(),
|
vis = it.visibility.print_with_space(),
|
||||||
constness = f.header.constness.print_with_space(),
|
constness = f.header.constness.print_with_space(),
|
||||||
asyncness = f.header.asyncness.print_with_space(),
|
asyncness = f.header.asyncness.print_with_space(),
|
||||||
|
@ -2425,7 +2425,8 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
|
||||||
generics = f.generics.print(),
|
generics = f.generics.print(),
|
||||||
where_clause = WhereClause { gens: &f.generics, indent: 0, end_newline: true },
|
where_clause = WhereClause { gens: &f.generics, indent: 0, end_newline: true },
|
||||||
decl = Function { decl: &f.decl, header_len, indent: 0, asyncness: f.header.asyncness }
|
decl = Function { decl: &f.decl, header_len, indent: 0, asyncness: f.header.asyncness }
|
||||||
.print()
|
.print(),
|
||||||
|
spotlight = spotlight_decl(&f.decl),
|
||||||
);
|
);
|
||||||
document(w, cx, it)
|
document(w, cx, it)
|
||||||
}
|
}
|
||||||
|
@ -2614,9 +2615,8 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait)
|
||||||
let id = cx.derive_id(format!("{}.{}", item_type, name));
|
let id = cx.derive_id(format!("{}.{}", item_type, name));
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"<h3 id='{id}' class='method'>{extra}<code>",
|
"<h3 id='{id}' class='method'><code>",
|
||||||
extra = render_spotlight_traits(m),
|
id = id,
|
||||||
id = id
|
|
||||||
);
|
);
|
||||||
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl);
|
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl);
|
||||||
write!(w, "</code>");
|
write!(w, "</code>");
|
||||||
|
@ -2931,7 +2931,7 @@ fn render_assoc_item(
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"{}{}{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
|
"{}{}{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
|
||||||
{generics}{decl}{where_clause}",
|
{generics}{decl}{spotlight}{where_clause}",
|
||||||
if parent == ItemType::Trait { " " } else { "" },
|
if parent == ItemType::Trait { " " } else { "" },
|
||||||
meth.visibility.print_with_space(),
|
meth.visibility.print_with_space(),
|
||||||
header.constness.print_with_space(),
|
header.constness.print_with_space(),
|
||||||
|
@ -2943,6 +2943,7 @@ fn render_assoc_item(
|
||||||
name = name,
|
name = name,
|
||||||
generics = g.print(),
|
generics = g.print(),
|
||||||
decl = Function { decl: d, header_len, indent, asyncness: header.asyncness }.print(),
|
decl = Function { decl: d, header_len, indent, asyncness: header.asyncness }.print(),
|
||||||
|
spotlight = spotlight_decl(&d),
|
||||||
where_clause = WhereClause { gens: g, indent, end_newline }
|
where_clause = WhereClause { gens: g, indent, end_newline }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -3564,16 +3565,6 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_spotlight_traits(item: &clean::Item) -> String {
|
|
||||||
match item.inner {
|
|
||||||
clean::FunctionItem(clean::Function { ref decl, .. })
|
|
||||||
| clean::TyMethodItem(clean::TyMethod { ref decl, .. })
|
|
||||||
| clean::MethodItem(clean::Method { ref decl, .. })
|
|
||||||
| clean::ForeignFunctionItem(clean::Function { ref decl, .. }) => spotlight_decl(decl),
|
|
||||||
_ => String::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn spotlight_decl(decl: &clean::FnDecl) -> String {
|
fn spotlight_decl(decl: &clean::FnDecl) -> String {
|
||||||
let mut out = Buffer::html();
|
let mut out = Buffer::html();
|
||||||
let mut trait_ = String::new();
|
let mut trait_ = String::new();
|
||||||
|
@ -3622,13 +3613,13 @@ fn spotlight_decl(decl: &clean::FnDecl) -> String {
|
||||||
out.insert_str(
|
out.insert_str(
|
||||||
0,
|
0,
|
||||||
&format!(
|
&format!(
|
||||||
"<div class=\"important-traits\"><div class='tooltip'>ⓘ\
|
"<span class=\"important-traits\"><div class='tooltip'>ⓘ\
|
||||||
<span class='tooltiptext'>Important traits for {}</span></div>\
|
<span class='tooltiptext'>Important traits for {}</span></div>\
|
||||||
<div class=\"content hidden\">",
|
<div class=\"content hidden\">",
|
||||||
trait_
|
trait_
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
out.push_str("</code></div></div>");
|
out.push_str("</code></div></span>");
|
||||||
}
|
}
|
||||||
|
|
||||||
out.into_inner()
|
out.into_inner()
|
||||||
|
@ -3740,13 +3731,12 @@ fn render_impl(
|
||||||
(true, " hidden")
|
(true, " hidden")
|
||||||
};
|
};
|
||||||
match item.inner {
|
match item.inner {
|
||||||
clean::MethodItem(clean::Method { ref decl, .. })
|
clean::MethodItem(clean::Method { .. })
|
||||||
| clean::TyMethodItem(clean::TyMethod { ref decl, .. }) => {
|
| clean::TyMethodItem(clean::TyMethod { .. }) => {
|
||||||
// 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);
|
||||||
write!(w, "{}", spotlight_decl(decl));
|
|
||||||
write!(w, "<code>");
|
write!(w, "<code>");
|
||||||
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl);
|
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl);
|
||||||
write!(w, "</code>");
|
write!(w, "</code>");
|
||||||
|
|
|
@ -1082,7 +1082,7 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltip:hover .tooltiptext {
|
.important-traits:hover .tooltiptext {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1150,6 +1150,7 @@ pre.rust {
|
||||||
.important-traits {
|
.important-traits {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h4 > .important-traits {
|
h4 > .important-traits {
|
||||||
|
@ -1555,19 +1556,6 @@ h3.important {
|
||||||
top: 0px;
|
top: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main > div.important-traits {
|
|
||||||
position: absolute;
|
|
||||||
left: -24px;
|
|
||||||
margin-top: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content > .methods > .method > div.important-traits {
|
|
||||||
position: absolute;
|
|
||||||
font-weight: 400;
|
|
||||||
left: -42px;
|
|
||||||
margin-top: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
kbd {
|
kbd {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 3px 5px;
|
padding: 3px 5px;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue