diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index dda0f37c3f95b..bb95696c5130e 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2259,8 +2259,8 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re if let Some(ref name) = item.name { info!("Documenting {}", name); } - document_stability(w, cx, item)?; - document_full(w, item, cx, "")?; + document_stability(w, cx, item, false)?; + document_full(w, item, cx, "", false)?; Ok(()) } @@ -2269,15 +2269,19 @@ fn render_markdown(w: &mut fmt::Formatter, cx: &Context, md_text: &str, links: Vec<(String, String)>, - prefix: &str) + prefix: &str, + is_hidden: bool) -> fmt::Result { let mut ids = cx.id_map.borrow_mut(); - write!(w, "
", ns_id)?;
assoc_type(w, item, &Vec::new(), Some(&tydef.type_), link.anchor(&id))?;
write!(w, "
", ns_id)?;
assoc_const(w, item, ty, default.as_ref(), link.anchor(&id))?;
let src = if let Some(l) = (Item { cx, item }).src_href() {
@@ -3923,7 +3938,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
clean::AssociatedTypeItem(ref bounds, ref default) => {
let id = cx.derive_id(format!("{}.{}", item_type, name));
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
- write!(w, "", id, item_type)?;
+ write!(w, "", id, item_type, extra_class)?;
write!(w, "", ns_id)?;
assoc_type(w, item, bounds, default.as_ref(), link.anchor(&id))?;
write!(w, "
\n")?;
@@ -3940,25 +3955,25 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
if let Some(it) = t.items.iter().find(|i| i.name == item.name) {
// We need the stability of the item from the trait
// because impls can't have a stability.
- document_stability(w, cx, it)?;
+ document_stability(w, cx, it, is_hidden)?;
if item.doc_value().is_some() {
- document_full(w, item, cx, "")?;
+ document_full(w, item, cx, "", is_hidden)?;
} else if show_def_docs {
// In case the item isn't documented,
// provide short documentation from the trait.
- document_short(w, cx, it, link, "")?;
+ document_short(w, cx, it, link, "", is_hidden)?;
}
}
} else {
- document_stability(w, cx, item)?;
+ document_stability(w, cx, item, is_hidden)?;
if show_def_docs {
- document_full(w, item, cx, "")?;
+ document_full(w, item, cx, "", is_hidden)?;
}
}
} else {
- document_stability(w, cx, item)?;
+ document_stability(w, cx, item, is_hidden)?;
if show_def_docs {
- document_short(w, cx, item, link, "")?;
+ document_short(w, cx, item, link, "", is_hidden)?;
}
}
}
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 6307dda454da8..75e8eaf57532e 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -2057,6 +2057,36 @@
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);
+ if (e.getElementsByClassName('hidden').length > 0) {
+ var newToggle = document.createElement('a');
+ newToggle.href = 'javascript:void(0)';
+ newToggle.className = 'collapse-toggle hidden-default collapsed';
+ newToggle.innerHTML = "[" + labelForToggleButton(true) + "" +
+ "] Show hidden default items";
+ newToggle.onclick = function() {
+ if (hasClass(this, "collapsed")) {
+ removeClass(this, "collapsed");
+ onEach(this.parentNode.getElementsByClassName("hidden"), function(x) {
+ removeClass(x, "hidden");
+ addClass(x, "x");
+ }, true);
+ this.innerHTML = "[" + labelForToggleButton(false) +
+ "] Hide default items"
+ } else {
+ addClass(this, "collapsed");
+ onEach(this.parentNode.getElementsByClassName("x"), function(x) {
+ addClass(x, "hidden");
+ removeClass(x, "x");
+ }, true);
+ this.innerHTML = "[" + labelForToggleButton(true) +
+ "] Show hidden default items";
+ }
+ };
+ e.insertBefore(newToggle, e.firstChild);
+ }
+ });
function createToggle(otherMessage, fontSize, extraClass, show) {
var span = document.createElement('span');
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index 8640f5da1332c..848d02440b5d2 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -816,6 +816,11 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
text-align: center;
}
+.collapse-toggle.hidden-default {
+ position: relative;
+ margin-left: 20px;
+}
+
.ghost {
display: none;
}
diff --git a/src/librustdoc/html/static/storage.js b/src/librustdoc/html/static/storage.js
index e10e330402f5e..5f7a8c75d3c5f 100644
--- a/src/librustdoc/html/static/storage.js
+++ b/src/librustdoc/html/static/storage.js
@@ -15,11 +15,19 @@ var mainTheme = document.getElementById("mainThemeStyle");
var savedHref = [];
-function onEach(arr, func) {
+function onEach(arr, func, reversed) {
if (arr && arr.length > 0 && func) {
- for (var i = 0; i < arr.length; i++) {
- if (func(arr[i]) === true) {
- return true;
+ if (reversed !== true) {
+ for (var i = 0; i < arr.length; ++i) {
+ if (func(arr[i]) === true) {
+ return true;
+ }
+ }
+ } else {
+ for (var i = arr.length - 1; i >= 0; --i) {
+ if (func(arr[i]) === true) {
+ return true;
+ }
}
}
}