Skip to content

Commit c90fb71

Browse files
committed
Move spotlight next to the return type
1 parent 3cecd60 commit c90fb71

File tree

2 files changed

+14
-36
lines changed

2 files changed

+14
-36
lines changed

src/librustdoc/html/render.rs

+12-22
Original file line numberDiff line numberDiff line change
@@ -2410,12 +2410,12 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
24102410
f.generics.print()
24112411
)
24122412
.len();
2413-
write!(w, "{}<pre class='rust fn'>", render_spotlight_traits(it));
2413+
write!(w, "<pre class='rust fn'>");
24142414
render_attributes(w, it, false);
24152415
write!(
24162416
w,
24172417
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
2418-
{name}{generics}{decl}{where_clause}</pre>",
2418+
{name}{generics}{decl}{spotlight}{where_clause}</pre>",
24192419
vis = it.visibility.print_with_space(),
24202420
constness = f.header.constness.print_with_space(),
24212421
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
24252425
generics = f.generics.print(),
24262426
where_clause = WhereClause { gens: &f.generics, indent: 0, end_newline: true },
24272427
decl = Function { decl: &f.decl, header_len, indent: 0, asyncness: f.header.asyncness }
2428-
.print()
2428+
.print(),
2429+
spotlight = spotlight_decl(&f.decl),
24292430
);
24302431
document(w, cx, it)
24312432
}
@@ -2614,9 +2615,8 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait)
26142615
let id = cx.derive_id(format!("{}.{}", item_type, name));
26152616
write!(
26162617
w,
2617-
"<h3 id='{id}' class='method'>{extra}<code>",
2618-
extra = render_spotlight_traits(m),
2619-
id = id
2618+
"<h3 id='{id}' class='method'><code>",
2619+
id = id,
26202620
);
26212621
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl);
26222622
write!(w, "</code>");
@@ -2931,7 +2931,7 @@ fn render_assoc_item(
29312931
write!(
29322932
w,
29332933
"{}{}{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
2934-
{generics}{decl}{where_clause}",
2934+
{generics}{decl}{spotlight}{where_clause}",
29352935
if parent == ItemType::Trait { " " } else { "" },
29362936
meth.visibility.print_with_space(),
29372937
header.constness.print_with_space(),
@@ -2943,6 +2943,7 @@ fn render_assoc_item(
29432943
name = name,
29442944
generics = g.print(),
29452945
decl = Function { decl: d, header_len, indent, asyncness: header.asyncness }.print(),
2946+
spotlight = spotlight_decl(&d),
29462947
where_clause = WhereClause { gens: g, indent, end_newline }
29472948
)
29482949
}
@@ -3564,16 +3565,6 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
35643565
}
35653566
}
35663567

3567-
fn render_spotlight_traits(item: &clean::Item) -> String {
3568-
match item.inner {
3569-
clean::FunctionItem(clean::Function { ref decl, .. })
3570-
| clean::TyMethodItem(clean::TyMethod { ref decl, .. })
3571-
| clean::MethodItem(clean::Method { ref decl, .. })
3572-
| clean::ForeignFunctionItem(clean::Function { ref decl, .. }) => spotlight_decl(decl),
3573-
_ => String::new(),
3574-
}
3575-
}
3576-
35773568
fn spotlight_decl(decl: &clean::FnDecl) -> String {
35783569
let mut out = Buffer::html();
35793570
let mut trait_ = String::new();
@@ -3622,13 +3613,13 @@ fn spotlight_decl(decl: &clean::FnDecl) -> String {
36223613
out.insert_str(
36233614
0,
36243615
&format!(
3625-
"<div class=\"important-traits\"><div class='tooltip'>ⓘ\
3616+
"<span class=\"important-traits\"><div class='tooltip'>ⓘ\
36263617
<span class='tooltiptext'>Important traits for {}</span></div>\
36273618
<div class=\"content hidden\">",
36283619
trait_
36293620
),
36303621
);
3631-
out.push_str("</code></div></div>");
3622+
out.push_str("</code></div></span>");
36323623
}
36333624

36343625
out.into_inner()
@@ -3740,13 +3731,12 @@ fn render_impl(
37403731
(true, " hidden")
37413732
};
37423733
match item.inner {
3743-
clean::MethodItem(clean::Method { ref decl, .. })
3744-
| clean::TyMethodItem(clean::TyMethod { ref decl, .. }) => {
3734+
clean::MethodItem(clean::Method { .. })
3735+
| clean::TyMethodItem(clean::TyMethod { .. }) => {
37453736
// Only render when the method is not static or we allow static methods
37463737
if render_method_item {
37473738
let id = cx.derive_id(format!("{}.{}", item_type, name));
37483739
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class);
3749-
write!(w, "{}", spotlight_decl(decl));
37503740
write!(w, "<code>");
37513741
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl);
37523742
write!(w, "</code>");

src/librustdoc/html/static/rustdoc.css

+2-14
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
10821082
font-size: 16px;
10831083
}
10841084

1085-
.tooltip:hover .tooltiptext {
1085+
.important-traits:hover .tooltiptext {
10861086
display: inline;
10871087
}
10881088

@@ -1150,6 +1150,7 @@ pre.rust {
11501150
.important-traits {
11511151
cursor: pointer;
11521152
z-index: 2;
1153+
margin-left: 5px;
11531154
}
11541155

11551156
h4 > .important-traits {
@@ -1555,19 +1556,6 @@ h3.important {
15551556
top: 0px;
15561557
}
15571558

1558-
#main > div.important-traits {
1559-
position: absolute;
1560-
left: -24px;
1561-
margin-top: 16px;
1562-
}
1563-
1564-
.content > .methods > .method > div.important-traits {
1565-
position: absolute;
1566-
font-weight: 400;
1567-
left: -42px;
1568-
margin-top: 2px;
1569-
}
1570-
15711559
kbd {
15721560
display: inline-block;
15731561
padding: 3px 5px;

0 commit comments

Comments
 (0)