Skip to content

Commit f2b7e83

Browse files
committed
Move spotlight next to the return type
1 parent 7539451 commit f2b7e83

File tree

2 files changed

+13
-35
lines changed

2 files changed

+13
-35
lines changed

src/librustdoc/html/render.rs

+11-21
Original file line numberDiff line numberDiff line change
@@ -2384,12 +2384,12 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
23842384
f.generics.print()
23852385
)
23862386
.len();
2387-
write!(w, "{}<pre class='rust fn'>", render_spotlight_traits(it));
2387+
write!(w, "<pre class='rust fn'>");
23882388
render_attributes(w, it, false);
23892389
write!(
23902390
w,
23912391
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
2392-
{name}{generics}{decl}{where_clause}</pre>",
2392+
{name}{generics}{decl}{spotlight}{where_clause}</pre>",
23932393
vis = it.visibility.print_with_space(),
23942394
constness = f.header.constness.print_with_space(),
23952395
asyncness = f.header.asyncness.print_with_space(),
@@ -2399,7 +2399,8 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
23992399
generics = f.generics.print(),
24002400
where_clause = WhereClause { gens: &f.generics, indent: 0, end_newline: true },
24012401
decl = Function { decl: &f.decl, header_len, indent: 0, asyncness: f.header.asyncness }
2402-
.print()
2402+
.print(),
2403+
spotlight = spotlight_decl(&f.decl),
24032404
);
24042405
document(w, cx, it)
24052406
}
@@ -2589,8 +2590,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait)
25892590
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
25902591
write!(
25912592
w,
2592-
"<h3 id='{id}' class='method'>{extra}<code id='{ns_id}'>",
2593-
extra = render_spotlight_traits(m),
2593+
"<h3 id='{id}' class='method'><code id='{ns_id}'>",
25942594
id = id,
25952595
ns_id = ns_id
25962596
);
@@ -2907,7 +2907,7 @@ fn render_assoc_item(
29072907
write!(
29082908
w,
29092909
"{}{}{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
2910-
{generics}{decl}{where_clause}",
2910+
{generics}{decl}{spotlight}{where_clause}",
29112911
if parent == ItemType::Trait { " " } else { "" },
29122912
meth.visibility.print_with_space(),
29132913
header.constness.print_with_space(),
@@ -2919,6 +2919,7 @@ fn render_assoc_item(
29192919
name = name,
29202920
generics = g.print(),
29212921
decl = Function { decl: d, header_len, indent, asyncness: header.asyncness }.print(),
2922+
spotlight = spotlight_decl(&d),
29222923
where_clause = WhereClause { gens: g, indent, end_newline }
29232924
)
29242925
}
@@ -3556,16 +3557,6 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
35563557
}
35573558
}
35583559

3559-
fn render_spotlight_traits(item: &clean::Item) -> String {
3560-
match item.inner {
3561-
clean::FunctionItem(clean::Function { ref decl, .. })
3562-
| clean::TyMethodItem(clean::TyMethod { ref decl, .. })
3563-
| clean::MethodItem(clean::Method { ref decl, .. })
3564-
| clean::ForeignFunctionItem(clean::Function { ref decl, .. }) => spotlight_decl(decl),
3565-
_ => String::new(),
3566-
}
3567-
}
3568-
35693560
fn spotlight_decl(decl: &clean::FnDecl) -> String {
35703561
let mut out = Buffer::html();
35713562
let mut trait_ = String::new();
@@ -3614,13 +3605,13 @@ fn spotlight_decl(decl: &clean::FnDecl) -> String {
36143605
out.insert_str(
36153606
0,
36163607
&format!(
3617-
"<div class=\"important-traits\"><div class='tooltip'>ⓘ\
3608+
"<span class=\"important-traits\"><div class='tooltip'>ⓘ\
36183609
<span class='tooltiptext'>Important traits for {}</span></div>\
36193610
<div class=\"content hidden\">",
36203611
trait_
36213612
),
36223613
);
3623-
out.push_str("</code></div></div>");
3614+
out.push_str("</code></div></span>");
36243615
}
36253616

36263617
out.into_inner()
@@ -3732,14 +3723,13 @@ fn render_impl(
37323723
(true, " hidden")
37333724
};
37343725
match item.inner {
3735-
clean::MethodItem(clean::Method { ref decl, .. })
3736-
| clean::TyMethodItem(clean::TyMethod { ref decl, .. }) => {
3726+
clean::MethodItem(clean::Method { .. })
3727+
| clean::TyMethodItem(clean::TyMethod { .. }) => {
37373728
// Only render when the method is not static or we allow static methods
37383729
if render_method_item {
37393730
let id = cx.derive_id(format!("{}.{}", item_type, name));
37403731
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
37413732
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class);
3742-
write!(w, "{}", spotlight_decl(decl));
37433733
write!(w, "<code id='{}'>", ns_id);
37443734
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl);
37453735
write!(w, "</code>");

src/librustdoc/html/static/rustdoc.css

+2-14
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
10781078
font-size: 16px;
10791079
}
10801080

1081-
.tooltip:hover .tooltiptext {
1081+
.important-traits:hover .tooltiptext {
10821082
display: inline;
10831083
}
10841084

@@ -1146,6 +1146,7 @@ pre.rust {
11461146
.important-traits {
11471147
cursor: pointer;
11481148
z-index: 2;
1149+
margin-left: 5px;
11491150
}
11501151

11511152
h4 > .important-traits {
@@ -1551,19 +1552,6 @@ h3.important {
15511552
top: 0px;
15521553
}
15531554

1554-
#main > div.important-traits {
1555-
position: absolute;
1556-
left: -24px;
1557-
margin-top: 16px;
1558-
}
1559-
1560-
.content > .methods > .method > div.important-traits {
1561-
position: absolute;
1562-
font-weight: 400;
1563-
left: -42px;
1564-
margin-top: 2px;
1565-
}
1566-
15671555
kbd {
15681556
display: inline-block;
15691557
padding: 3px 5px;

0 commit comments

Comments
 (0)