diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-06 14:13:47 -0700 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-16 09:58:37 -0700 |
| commit | c90fb7185a5febb00b7f8ccb49abceacd41bad6e (patch) | |
| tree | c74c85b0b0198e4d025975a4341915e238f9839d | |
| parent | 3cecd6003b3eb15168421084a27223596517899c (diff) | |
| download | rust-c90fb7185a5febb00b7f8ccb49abceacd41bad6e.tar.gz rust-c90fb7185a5febb00b7f8ccb49abceacd41bad6e.zip | |
Move spotlight next to the return type
| -rw-r--r-- | src/librustdoc/html/render.rs | 34 | ||||
| -rw-r--r-- | src/librustdoc/html/static/rustdoc.css | 16 |
2 files changed, 14 insertions, 36 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 940d7e87a18..1a96656b6f2 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2410,12 +2410,12 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func f.generics.print() ) .len(); - write!(w, "{}<pre class='rust fn'>", render_spotlight_traits(it)); + write!(w, "<pre class='rust fn'>"); render_attributes(w, it, false); write!( w, "{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(), constness = f.header.constness.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(), where_clause = WhereClause { gens: &f.generics, indent: 0, end_newline: true }, decl = Function { decl: &f.decl, header_len, indent: 0, asyncness: f.header.asyncness } - .print() + .print(), + spotlight = spotlight_decl(&f.decl), ); 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)); write!( w, - "<h3 id='{id}' class='method'>{extra}<code>", - extra = render_spotlight_traits(m), - id = id + "<h3 id='{id}' class='method'><code>", + id = id, ); render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl); write!(w, "</code>"); @@ -2931,7 +2931,7 @@ fn render_assoc_item( write!( w, "{}{}{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\ - {generics}{decl}{where_clause}", + {generics}{decl}{spotlight}{where_clause}", if parent == ItemType::Trait { " " } else { "" }, meth.visibility.print_with_space(), header.constness.print_with_space(), @@ -2943,6 +2943,7 @@ fn render_assoc_item( name = name, generics = g.print(), decl = Function { decl: d, header_len, indent, asyncness: header.asyncness }.print(), + spotlight = spotlight_decl(&d), 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 { let mut out = Buffer::html(); let mut trait_ = String::new(); @@ -3622,13 +3613,13 @@ fn spotlight_decl(decl: &clean::FnDecl) -> String { out.insert_str( 0, &format!( - "<div class=\"important-traits\"><div class='tooltip'>ⓘ\ + "<span class=\"important-traits\"><div class='tooltip'>ⓘ\ <span class='tooltiptext'>Important traits for {}</span></div>\ <div class=\"content hidden\">", trait_ ), ); - out.push_str("</code></div></div>"); + out.push_str("</code></div></span>"); } out.into_inner() @@ -3740,13 +3731,12 @@ fn render_impl( (true, " hidden") }; match item.inner { - clean::MethodItem(clean::Method { ref decl, .. }) - | clean::TyMethodItem(clean::TyMethod { ref decl, .. }) => { + clean::MethodItem(clean::Method { .. }) + | clean::TyMethodItem(clean::TyMethod { .. }) => { // Only render when the method is not static or we allow static methods if render_method_item { let id = cx.derive_id(format!("{}.{}", item_type, name)); write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class); - write!(w, "{}", spotlight_decl(decl)); write!(w, "<code>"); render_assoc_item(w, item, link.anchor(&id), ItemType::Impl); write!(w, "</code>"); diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 3b2a28a0f5e..b780cf5dafb 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -1082,7 +1082,7 @@ h3 > .collapse-toggle, h4 > .collapse-toggle { font-size: 16px; } -.tooltip:hover .tooltiptext { +.important-traits:hover .tooltiptext { display: inline; } @@ -1150,6 +1150,7 @@ pre.rust { .important-traits { cursor: pointer; z-index: 2; + margin-left: 5px; } h4 > .important-traits { @@ -1555,19 +1556,6 @@ h3.important { 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 { display: inline-block; padding: 3px 5px; |
