diff options
| author | bors <bors@rust-lang.org> | 2018-09-12 21:20:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-09-12 21:20:05 +0000 |
| commit | f2302daef3608c09e2b50193a64611b18ced86f3 (patch) | |
| tree | 587c28333ce12e085b33c5890e70f4303a162c10 /src/librustdoc | |
| parent | 06d2448f1fde4005bddd2f349f9dce4c79adce65 (diff) | |
| parent | 86141797dbeb406a6b0a7c6442cc715d3f7bcc75 (diff) | |
| download | rust-f2302daef3608c09e2b50193a64611b18ced86f3.tar.gz rust-f2302daef3608c09e2b50193a64611b18ced86f3.zip | |
Auto merge of #53409 - GuillaumeGomez:associated-const-value, r=QuietMisdreavus
Don't show associated const value anymore Part of #44348. Before: <img width="1440" alt="screen shot 2018-08-16 at 00 48 30" src="https://user-images.githubusercontent.com/3050060/44177414-20ef1480-a0ee-11e8-80d4-7caf082cf0de.png"> After: <img width="1440" alt="screen shot 2018-08-16 at 00 48 23" src="https://user-images.githubusercontent.com/3050060/44177417-251b3200-a0ee-11e8-956a-4229275e3342.png"> cc @nox r? @QuietMisdreavus
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/html/render.rs | 56 | ||||
| -rw-r--r-- | src/librustdoc/html/static/main.js | 7 | ||||
| -rw-r--r-- | src/librustdoc/html/static/rustdoc.css | 8 |
3 files changed, 27 insertions, 44 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 45a5e5115a3..867b2a32905 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2213,8 +2213,7 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re info!("Documenting {}", name); } document_stability(w, cx, item)?; - let prefix = render_assoc_const_value(item); - document_full(w, item, cx, &prefix)?; + document_full(w, item, cx, "")?; Ok(()) } @@ -2246,20 +2245,6 @@ fn document_short(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item, link Ok(()) } -fn render_assoc_const_value(item: &clean::Item) -> String { - match item.inner { - clean::AssociatedConstItem(ref ty, Some(ref default)) => { - highlight::render_with_highlighting( - &format!("{}: {:#} = {}", item.name.as_ref().unwrap(), ty, default), - None, - None, - None, - ) - } - _ => String::new(), - } -} - fn document_full(w: &mut fmt::Formatter, item: &clean::Item, cx: &Context, prefix: &str) -> fmt::Result { if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) { @@ -2609,27 +2594,15 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S stability } -struct Initializer<'a>(&'a str); - -impl<'a> fmt::Display for Initializer<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let Initializer(s) = *self; - if s.is_empty() { return Ok(()); } - write!(f, "<code> = </code>")?; - write!(f, "<code>{}</code>", Escape(s)) - } -} - fn item_constant(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, c: &clean::Constant) -> fmt::Result { write!(w, "<pre class='rust const'>")?; render_attributes(w, it)?; write!(w, "{vis}const \ - {name}: {typ}{init}</pre>", + {name}: {typ}</pre>", vis = VisSpace(&it.visibility), name = it.name.as_ref().unwrap(), - typ = c.type_, - init = Initializer(&c.expr))?; + typ = c.type_)?; document(w, cx, it) } @@ -2638,12 +2611,11 @@ fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, write!(w, "<pre class='rust static'>")?; render_attributes(w, it)?; write!(w, "{vis}static {mutability}\ - {name}: {typ}{init}</pre>", + {name}: {typ}</pre>", vis = VisSpace(&it.visibility), mutability = MutableSpace(s.mutability), name = it.name.as_ref().unwrap(), - typ = s.type_, - init = Initializer(&s.expr))?; + typ = s.type_)?; document(w, cx, it) } @@ -3878,7 +3850,13 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi write!(w, "<h4 id='{}' class=\"{}\">", id, item_type)?; write!(w, "<span id='{}' class='invisible'><code>", ns_id)?; assoc_const(w, item, ty, default.as_ref(), link.anchor(&id))?; - write!(w, "</code></span></h4>\n")?; + let src = if let Some(l) = (Item { cx, item }).src_href() { + format!("<a class='srclink' href='{}' title='{}'>[src]</a>", + l, "goto source code") + } else { + String::new() + }; + write!(w, "</code>{}</span></h4>\n", src)?; } clean::AssociatedTypeItem(ref bounds, ref default) => { let id = cx.derive_id(format!("{}.{}", item_type, name)); @@ -3893,8 +3871,6 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi } if render_method_item || render_mode == RenderMode::Normal { - let prefix = render_assoc_const_value(item); - if !is_default_item { if let Some(t) = trait_ { // The trait item may have been stripped so we might not @@ -3904,23 +3880,23 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi // because impls can't have a stability. document_stability(w, cx, it)?; if item.doc_value().is_some() { - document_full(w, item, cx, &prefix)?; + document_full(w, item, cx, "")?; } else if show_def_docs { // In case the item isn't documented, // provide short documentation from the trait. - document_short(w, cx, it, link, &prefix)?; + document_short(w, cx, it, link, "")?; } } } else { document_stability(w, cx, item)?; if show_def_docs { - document_full(w, item, cx, &prefix)?; + document_full(w, item, cx, "")?; } } } else { document_stability(w, cx, item)?; if show_def_docs { - document_short(w, cx, item, link, &prefix)?; + document_short(w, cx, item, link, "")?; } } } diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index a3af621a8a4..a6027a54657 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2028,7 +2028,8 @@ if (!next) { return; } - if ((checkIfThereAreMethods(next.childNodes) || hasClass(e, 'method')) && + if ((hasClass(e, 'method') || hasClass(e, 'associatedconstant') || + checkIfThereAreMethods(next.childNodes)) && (hasClass(next, 'docblock') || hasClass(e, 'impl') || (hasClass(next, 'stability') && @@ -2037,10 +2038,8 @@ } }; onEach(document.getElementsByClassName('method'), func); + onEach(document.getElementsByClassName('associatedconstant'), func); onEach(document.getElementsByClassName('impl'), func); - onEach(document.getElementsByClassName('impl-items'), function(e) { - onEach(e.getElementsByClassName('associatedconstant'), func); - }); function createToggle(otherMessage, fontSize, extraClass) { var span = document.createElement('span'); diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 3a54cb6389b..923a486060a 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -575,6 +575,14 @@ a { text-decoration: underline; } +.invisible > .srclink { + position: absolute; + top: 0; + right: 0; + font-size: 17px; + font-weight: normal; +} + .block a.current.crate { font-weight: 500; } .search-container { |
