1
Fork 0

Auto merge of #84754 - GuillaumeGomez:toggle-migration, r=jsha

Migrate trait and impl blocks' toggles into

Part of #83332

After this, I think only the "global" doc comment will be used as JS toggle. Once this PR is merged, I check what remains and remove them.

There is one change that this PR brings:

![Screenshot from 2021-04-30 15-39-04](https://user-images.githubusercontent.com/3050060/116713412-0f9ce200-a9d5-11eb-979c-2e7a73d16706.png)
![Screenshot from 2021-04-30 15-39-07](https://user-images.githubusercontent.com/3050060/116713415-10357880-a9d5-11eb-9868-1ba9e5ebf65e.png)

As you can see, I had to move the "undocumented" items below, they're not mixed with the others anymore. Unfortunately, I don't see a way to keep the current appearance without JS. As a a reminder, currently it looks like this:

![Screenshot from 2021-04-30 15-39-12](https://user-images.githubusercontent.com/3050060/116713547-31966480-a9d5-11eb-90bb-686042eefeec.png)
![Screenshot from 2021-04-30 15-39-15](https://user-images.githubusercontent.com/3050060/116713549-322efb00-a9d5-11eb-94a9-cfea073120db.png)

r? `@jsha`
This commit is contained in:
bors 2021-05-02 19:46:10 +00:00
commit 6b5de7aaec
12 changed files with 186 additions and 232 deletions

View file

@ -678,10 +678,6 @@ impl ItemKind {
| KeywordItem(_) => [].iter(), | KeywordItem(_) => [].iter(),
} }
} }
crate fn is_type_alias(&self) -> bool {
matches!(self, ItemKind::TypedefItem(..) | ItemKind::AssocTypeItem(..))
}
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]

View file

@ -508,23 +508,16 @@ fn document(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, parent: Option
if let Some(ref name) = item.name { if let Some(ref name) = item.name {
info!("Documenting {}", name); info!("Documenting {}", name);
} }
document_item_info(w, cx, item, false, parent); document_item_info(w, cx, item, parent);
document_full(w, item, cx, false); document_full(w, item, cx);
} }
/// Render md_text as markdown. /// Render md_text as markdown.
fn render_markdown( fn render_markdown(w: &mut Buffer, cx: &Context<'_>, md_text: &str, links: Vec<RenderedLink>) {
w: &mut Buffer,
cx: &Context<'_>,
md_text: &str,
links: Vec<RenderedLink>,
is_hidden: bool,
) {
let mut ids = cx.id_map.borrow_mut(); let mut ids = cx.id_map.borrow_mut();
write!( write!(
w, w,
"<div class=\"docblock{}\">{}</div>", "<div class=\"docblock\">{}</div>",
if is_hidden { " hidden" } else { "" },
Markdown( Markdown(
md_text, md_text,
&links, &links,
@ -544,11 +537,10 @@ fn document_short(
item: &clean::Item, item: &clean::Item,
cx: &Context<'_>, cx: &Context<'_>,
link: AssocItemLink<'_>, link: AssocItemLink<'_>,
is_hidden: bool,
parent: &clean::Item, parent: &clean::Item,
show_def_docs: bool, show_def_docs: bool,
) { ) {
document_item_info(w, cx, item, is_hidden, Some(parent)); document_item_info(w, cx, item, Some(parent));
if !show_def_docs { if !show_def_docs {
return; return;
} }
@ -565,19 +557,14 @@ fn document_short(
} }
} }
write!( write!(w, "<div class='docblock'>{}</div>", summary_html,);
w,
"<div class='docblock{}'>{}</div>",
if is_hidden { " hidden" } else { "" },
summary_html,
);
} }
} }
fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>, is_hidden: bool) { fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>) {
if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) { if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) {
debug!("Doc block: =====\n{}\n=====", s); debug!("Doc block: =====\n{}\n=====", s);
render_markdown(w, cx, &s, item.links(cx), is_hidden); render_markdown(w, cx, &s, item.links(cx));
} }
} }
@ -590,16 +577,11 @@ fn document_item_info(
w: &mut Buffer, w: &mut Buffer,
cx: &Context<'_>, cx: &Context<'_>,
item: &clean::Item, item: &clean::Item,
is_hidden: bool,
parent: Option<&clean::Item>, parent: Option<&clean::Item>,
) { ) {
let item_infos = short_item_info(item, cx, parent); let item_infos = short_item_info(item, cx, parent);
if !item_infos.is_empty() { if !item_infos.is_empty() {
if is_hidden { w.write_str("<div class=\"item-info\">");
w.write_str("<div class=\"item-info hidden\">");
} else {
w.write_str("<div class=\"item-info\">");
}
for info in item_infos { for info in item_infos {
w.write_str(&info); w.write_str(&info);
} }
@ -1282,8 +1264,12 @@ fn render_impl(
let trait_ = i.trait_did_full(cache).map(|did| &traits[&did]); let trait_ = i.trait_did_full(cache).map(|did| &traits[&did]);
let mut close_tags = String::new(); let mut close_tags = String::new();
// For trait implementations, the `interesting` output contains all methods that have doc
// comments, and the `boring` output contains all methods that do not. The distinction is
// used to allow hiding the boring methods.
fn doc_impl_item( fn doc_impl_item(
w: &mut Buffer, boring: &mut Buffer,
interesting: &mut Buffer,
cx: &Context<'_>, cx: &Context<'_>,
item: &clean::Item, item: &clean::Item,
parent: &clean::Item, parent: &clean::Item,
@ -1306,15 +1292,46 @@ fn render_impl(
} }
}; };
let (is_hidden, extra_class) =
if (trait_.is_none() || item.doc_value().is_some() || item.kind.is_type_alias())
&& !is_default_item
{
(false, "")
} else {
(true, " hidden")
};
let in_trait_class = if trait_.is_some() { " trait-impl" } else { "" }; let in_trait_class = if trait_.is_some() { " trait-impl" } else { "" };
let mut doc_buffer = Buffer::empty_from(boring);
let mut info_buffer = Buffer::empty_from(boring);
let mut short_documented = true;
if render_method_item {
if !is_default_item {
if let Some(t) = trait_ {
// The trait item may have been stripped so we might not
// find any documentation or stability for it.
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.
if item.doc_value().is_some() {
document_item_info(&mut info_buffer, cx, it, Some(parent));
document_full(&mut doc_buffer, item, cx);
short_documented = false;
} else {
// In case the item isn't documented,
// provide short documentation from the trait.
document_short(&mut doc_buffer, it, cx, link, parent, show_def_docs);
}
}
} else {
document_item_info(&mut info_buffer, cx, item, Some(parent));
if show_def_docs {
document_full(&mut doc_buffer, item, cx);
short_documented = false;
}
}
} else {
document_short(&mut doc_buffer, item, cx, link, parent, show_def_docs);
}
}
let w = if short_documented && trait_.is_some() { interesting } else { boring };
if !doc_buffer.is_empty() {
w.write_str("<details class=\"rustdoc-toggle\" open><summary>");
}
match *item.kind { match *item.kind {
clean::MethodItem(..) | clean::TyMethodItem(_) => { clean::MethodItem(..) | clean::TyMethodItem(_) => {
// Only render when the method is not static or we allow static methods // Only render when the method is not static or we allow static methods
@ -1327,11 +1344,7 @@ fn render_impl(
}) })
}) })
.map(|item| format!("{}.{}", item.type_(), name)); .map(|item| format!("{}.{}", item.type_(), name));
write!( write!(w, "<h4 id=\"{}\" class=\"{}{}\">", id, item_type, in_trait_class,);
w,
"<h4 id=\"{}\" class=\"{}{}{}\">",
id, item_type, extra_class, in_trait_class,
);
w.write_str("<code>"); w.write_str("<code>");
render_assoc_item( render_assoc_item(
w, w,
@ -1356,11 +1369,7 @@ fn render_impl(
clean::TypedefItem(ref tydef, _) => { clean::TypedefItem(ref tydef, _) => {
let source_id = format!("{}.{}", ItemType::AssocType, name); let source_id = format!("{}.{}", ItemType::AssocType, name);
let id = cx.derive_id(source_id.clone()); let id = cx.derive_id(source_id.clone());
write!( write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class);
w,
"<h4 id=\"{}\" class=\"{}{}{}\"><code>",
id, item_type, extra_class, in_trait_class
);
assoc_type( assoc_type(
w, w,
item, item,
@ -1377,11 +1386,7 @@ fn render_impl(
clean::AssocConstItem(ref ty, ref default) => { clean::AssocConstItem(ref ty, ref default) => {
let source_id = format!("{}.{}", item_type, name); let source_id = format!("{}.{}", item_type, name);
let id = cx.derive_id(source_id.clone()); let id = cx.derive_id(source_id.clone());
write!( write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class);
w,
"<h4 id=\"{}\" class=\"{}{}{}\"><code>",
id, item_type, extra_class, in_trait_class
);
assoc_const( assoc_const(
w, w,
item, item,
@ -1406,11 +1411,7 @@ fn render_impl(
clean::AssocTypeItem(ref bounds, ref default) => { clean::AssocTypeItem(ref bounds, ref default) => {
let source_id = format!("{}.{}", item_type, name); let source_id = format!("{}.{}", item_type, name);
let id = cx.derive_id(source_id.clone()); let id = cx.derive_id(source_id.clone());
write!( write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class);
w,
"<h4 id=\"{}\" class=\"{}{}{}\"><code>",
id, item_type, extra_class, in_trait_class
);
assoc_type( assoc_type(
w, w,
item, item,
@ -1428,38 +1429,20 @@ fn render_impl(
_ => panic!("can't make docs for trait item with name {:?}", item.name), _ => panic!("can't make docs for trait item with name {:?}", item.name),
} }
if render_method_item { w.push_buffer(info_buffer);
if !is_default_item { if !doc_buffer.is_empty() {
if let Some(t) = trait_ { w.write_str("</summary>");
// The trait item may have been stripped so we might not w.push_buffer(doc_buffer);
// find any documentation or stability for it. w.push_str("</details>");
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.
if item.doc_value().is_some() {
document_item_info(w, cx, it, is_hidden, Some(parent));
document_full(w, item, cx, is_hidden);
} else {
// In case the item isn't documented,
// provide short documentation from the trait.
document_short(w, it, cx, link, is_hidden, parent, show_def_docs);
}
}
} else {
document_item_info(w, cx, item, is_hidden, Some(parent));
if show_def_docs {
document_full(w, item, cx, is_hidden);
}
}
} else {
document_short(w, item, cx, link, is_hidden, parent, show_def_docs);
}
} }
} }
let mut impl_items = Buffer::empty_from(w); let mut impl_items = Buffer::empty_from(w);
let mut default_impl_items = Buffer::empty_from(w);
for trait_item in &i.inner_impl().items { for trait_item in &i.inner_impl().items {
doc_impl_item( doc_impl_item(
&mut default_impl_items,
&mut impl_items, &mut impl_items,
cx, cx,
trait_item, trait_item,
@ -1475,7 +1458,8 @@ fn render_impl(
} }
fn render_default_items( fn render_default_items(
w: &mut Buffer, boring: &mut Buffer,
interesting: &mut Buffer,
cx: &Context<'_>, cx: &Context<'_>,
t: &clean::Trait, t: &clean::Trait,
i: &clean::Impl, i: &clean::Impl,
@ -1495,7 +1479,8 @@ fn render_impl(
let assoc_link = AssocItemLink::GotoSource(did, &provided_methods); let assoc_link = AssocItemLink::GotoSource(did, &provided_methods);
doc_impl_item( doc_impl_item(
w, boring,
interesting,
cx, cx,
trait_item, trait_item,
parent, parent,
@ -1517,6 +1502,7 @@ fn render_impl(
if show_default_items { if show_default_items {
if let Some(t) = trait_ { if let Some(t) = trait_ {
render_default_items( render_default_items(
&mut default_impl_items,
&mut impl_items, &mut impl_items,
cx, cx,
&t.trait_, &t.trait_,
@ -1529,10 +1515,14 @@ fn render_impl(
); );
} }
} }
let details_str = if impl_items.is_empty() { let toggled = !impl_items.is_empty() || !default_impl_items.is_empty();
"" let open_details = |close_tags: &mut String| {
} else { if toggled {
"<details class=\"rustdoc-toggle implementors-toggle\" open><summary>" close_tags.insert_str(0, "</details>");
"<details class=\"rustdoc-toggle implementors-toggle\" open><summary>"
} else {
""
}
}; };
if render_mode == RenderMode::Normal { if render_mode == RenderMode::Normal {
let id = cx.derive_id(match i.inner_impl().trait_ { let id = cx.derive_id(match i.inner_impl().trait_ {
@ -1554,11 +1544,10 @@ fn render_impl(
write!( write!(
w, w,
"{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">", "{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">",
details_str, id, aliases open_details(&mut close_tags),
id,
aliases
); );
if !impl_items.is_empty() {
close_tags.insert_str(0, "</details>");
}
write!(w, "{}", i.inner_impl().print(use_absolute, cx)); write!(w, "{}", i.inner_impl().print(use_absolute, cx));
if show_def_docs { if show_def_docs {
for it in &i.inner_impl().items { for it in &i.inner_impl().items {
@ -1582,14 +1571,11 @@ fn render_impl(
write!( write!(
w, w,
"{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">{}</code>", "{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">{}</code>",
details_str, open_details(&mut close_tags),
id, id,
aliases, aliases,
i.inner_impl().print(false, cx) i.inner_impl().print(false, cx)
); );
if !impl_items.is_empty() {
close_tags.insert_str(0, "</details>");
}
} }
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id); write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
render_stability_since_raw( render_stability_since_raw(
@ -1600,7 +1586,7 @@ fn render_impl(
outer_const_version, outer_const_version,
); );
write_srclink(cx, &i.impl_item, w); write_srclink(cx, &i.impl_item, w);
if impl_items.is_empty() { if !toggled {
w.write_str("</h3>"); w.write_str("</h3>");
} else { } else {
w.write_str("</h3></summary>"); w.write_str("</h3></summary>");
@ -1629,8 +1615,13 @@ fn render_impl(
); );
} }
} }
if !impl_items.is_empty() { if toggled {
w.write_str("<div class=\"impl-items\">"); w.write_str("<div class=\"impl-items\">");
w.push_buffer(default_impl_items);
if trait_.is_some() && !impl_items.is_empty() {
w.write_str("<details class=\"undocumented\"><summary></summary>");
close_tags.insert_str(0, "</details>");
}
w.push_buffer(impl_items); w.push_buffer(impl_items);
close_tags.insert_str(0, "</div>"); close_tags.insert_str(0, "</div>");
} }

View file

@ -1156,8 +1156,6 @@ function hideThemeButtonState() {
var hideMethodDocs = getSettingValue("auto-hide-method-docs") === "true"; var hideMethodDocs = getSettingValue("auto-hide-method-docs") === "true";
var hideImplementors = getSettingValue("auto-collapse-implementors") !== "false"; var hideImplementors = getSettingValue("auto-collapse-implementors") !== "false";
var hideLargeItemContents = getSettingValue("auto-hide-large-items") !== "false"; var hideLargeItemContents = getSettingValue("auto-hide-large-items") !== "false";
var hideTraitImplementations =
getSettingValue("auto-hide-trait-implementations") !== "false";
var impl_list = document.getElementById("trait-implementations-list"); var impl_list = document.getElementById("trait-implementations-list");
if (impl_list !== null) { if (impl_list !== null) {
@ -1173,39 +1171,18 @@ function hideThemeButtonState() {
}); });
} }
var func = function(e) { if (hideMethodDocs === true) {
var next = e.nextElementSibling; onEachLazy(document.getElementsByClassName("method"), function(e) {
if (next && hasClass(next, "item-info")) { var toggle = e.parentNode;
next = next.nextElementSibling; if (toggle) {
} toggle = toggle.parentNode;
if (!next) {
return;
}
if (hasClass(next, "docblock")) {
var newToggle = toggle.cloneNode(true);
insertAfter(newToggle, e.childNodes[e.childNodes.length - 1]);
if (hideMethodDocs === true && hasClass(e, "method") === true) {
collapseDocs(newToggle, "hide");
} }
} if (toggle && toggle.tagName === "DETAILS") {
}; toggle.open = false;
}
});
}
var funcImpl = function(e) {
var next = e.nextElementSibling;
if (next && hasClass(next, "item-info")) {
next = next.nextElementSibling;
}
if (next && hasClass(next, "docblock")) {
next = next.nextElementSibling;
}
if (!next) {
return;
}
};
onEachLazy(document.getElementsByClassName("method"), func);
onEachLazy(document.getElementsByClassName("associatedconstant"), func);
var impl_call = function() {};
onEachLazy(document.getElementsByTagName("details"), function (e) { onEachLazy(document.getElementsByTagName("details"), function (e) {
var showLargeItem = !hideLargeItemContents && hasClass(e, "type-contents-toggle"); var showLargeItem = !hideLargeItemContents && hasClass(e, "type-contents-toggle");
var showImplementor = !hideImplementors && hasClass(e, "implementors-toggle"); var showImplementor = !hideImplementors && hasClass(e, "implementors-toggle");
@ -1213,60 +1190,6 @@ function hideThemeButtonState() {
e.open = true; e.open = true;
} }
}); });
if (hideMethodDocs === true) {
impl_call = function(e, newToggle) {
if (e.id.match(/^impl(?:-\d+)?$/) === null) {
// Automatically minimize all non-inherent impls
if (hasClass(e, "impl") === true) {
collapseDocs(newToggle, "hide");
}
}
};
}
var newToggle = document.createElement("a");
newToggle.href = "javascript:void(0)";
newToggle.className = "collapse-toggle hidden-default collapsed";
newToggle.innerHTML = "[<span class=\"inner\">" + labelForToggleButton(true) +
"</span>] Show hidden undocumented items";
function toggleClicked() {
if (hasClass(this, "collapsed")) {
removeClass(this, "collapsed");
onEachLazy(this.parentNode.getElementsByClassName("hidden"), function(x) {
if (hasClass(x, "content") === false) {
removeClass(x, "hidden");
addClass(x, "x");
}
}, true);
this.innerHTML = "[<span class=\"inner\">" + labelForToggleButton(false) +
"</span>] Hide undocumented items";
} else {
addClass(this, "collapsed");
onEachLazy(this.parentNode.getElementsByClassName("x"), function(x) {
if (hasClass(x, "content") === false) {
addClass(x, "hidden");
removeClass(x, "x");
}
}, true);
this.innerHTML = "[<span class=\"inner\">" + labelForToggleButton(true) +
"</span>] Show hidden undocumented items";
}
}
onEachLazy(document.getElementsByClassName("impl-items"), function(e) {
onEachLazy(e.getElementsByClassName("associatedconstant"), func);
// We transform the DOM iterator into a vec of DOM elements to prevent performance
// issues on webkit browsers.
var hiddenElems = Array.prototype.slice.call(e.getElementsByClassName("hidden"));
var needToggle = hiddenElems.some(function(hiddenElem) {
return hasClass(hiddenElem, "content") === false &&
hasClass(hiddenElem, "docblock") === false;
});
if (needToggle === true) {
var inner_toggle = newToggle.cloneNode(true);
inner_toggle.onclick = toggleClicked;
e.insertBefore(inner_toggle, e.firstChild);
impl_call(e.previousSibling, inner_toggle);
}
});
var currentType = document.getElementsByClassName("type-decl")[0]; var currentType = document.getElementsByClassName("type-decl")[0];
var className = null; var className = null;

View file

@ -110,7 +110,7 @@ h3 {
font-size: 1.3em; font-size: 1.3em;
} }
h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.notable), h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.notable),
h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) { h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant):not(.associatedtype) {
font-weight: 500; font-weight: 500;
margin: 20px 0 15px 0; margin: 20px 0 15px 0;
padding-bottom: 6px; padding-bottom: 6px;
@ -128,10 +128,10 @@ h1.fqn > .in-band > a:hover {
text-decoration: underline; text-decoration: underline;
} }
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h2, h3:not(.impl):not(.method):not(.type):not(.tymethod),
h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) { h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant):not(.associatedtype) {
border-bottom: 1px solid; border-bottom: 1px solid;
} }
h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant { h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant, h4.associatedtype {
flex-basis: 100%; flex-basis: 100%;
font-weight: 600; font-weight: 600;
margin-top: 16px; margin-top: 16px;
@ -139,7 +139,7 @@ h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant {
position: relative; position: relative;
} }
h3.impl, h3.method, h4.method.trait-impl, h3.type, h3.impl, h3.method, h4.method.trait-impl, h3.type,
h4.type.trait-impl, h4.associatedconstant.trait-impl { h4.type.trait-impl, h4.associatedconstant.trait-impl, h4.associatedtype.trait-impl {
padding-left: 15px; padding-left: 15px;
} }
@ -147,6 +147,9 @@ h1, h2, h3, h4,
.sidebar, a.source, .search-input, .content table td:first-child > a, .sidebar, a.source, .search-input, .content table td:first-child > a,
.collapse-toggle, div.item-list .out-of-band, .collapse-toggle, div.item-list .out-of-band,
#source-sidebar, #sidebar-toggle, #source-sidebar, #sidebar-toggle,
details.rustdoc-toggle > summary::before,
details.undocumented > summary::before,
.content ul.crate a.crate,
/* This selector is for the items listed in the "all items" page. */ /* This selector is for the items listed in the "all items" page. */
#main > ul.docblock > li > a { #main > ul.docblock > li > a {
font-family: "Fira Sans", Arial, sans-serif; font-family: "Fira Sans", Arial, sans-serif;
@ -154,7 +157,6 @@ h1, h2, h3, h4,
.content ul.crate a.crate { .content ul.crate a.crate {
font-size: 16px/1.6; font-size: 16px/1.6;
font-family: "Fira Sans", Arial, sans-serif;
} }
ol, ul { ol, ul {
@ -596,7 +598,10 @@ h4 > code, h3 > code, .invisible > code {
left: -19px; left: -19px;
} }
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant { .content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant,
.impl-items > .associatedtype, .content .impl-items details > summary > .type,
.impl-items details > summary > .associatedconstant,
.impl-items details > summary > .associatedtype {
margin-left: 20px; margin-left: 20px;
} }
@ -656,7 +661,8 @@ a {
} }
.in-band:hover > .anchor, .impl:hover > .anchor, .method.trait-impl:hover > .anchor, .in-band:hover > .anchor, .impl:hover > .anchor, .method.trait-impl:hover > .anchor,
.type.trait-impl:hover > .anchor, .associatedconstant.trait-impl:hover > .anchor { .type.trait-impl:hover > .anchor, .associatedconstant.trait-impl:hover > .anchor,
.associatedtype.trait-impl:hover > .anchor {
display: inline-block; display: inline-block;
position: absolute; position: absolute;
} }
@ -1466,7 +1472,8 @@ h4 > .notable-traits {
margin-left: 0; margin-left: 0;
} }
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant { .content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant,
.impl-items > .associatedtype {
display: flex; display: flex;
} }
@ -1764,7 +1771,10 @@ details.rustdoc-toggle > summary.hideme {
cursor: pointer; cursor: pointer;
} }
details.rustdoc-toggle > summary::-webkit-details-marker { details.rustdoc-toggle > summary::-webkit-details-marker,
details.rustdoc-toggle > summary::marker,
details.undocumented > summary::-webkit-details-marker,
details.undocumented > summary::marker {
display: none; display: none;
} }
@ -1787,6 +1797,14 @@ details.rustdoc-toggle > summary.hideme::before {
details.rustdoc-toggle > summary:not(.hideme)::before { details.rustdoc-toggle > summary:not(.hideme)::before {
position: absolute; position: absolute;
left: -23px; left: -23px;
top: initial;
}
.impl-items > details.rustdoc-toggle > summary:not(.hideme)::before,
.undocumented > details.rustdoc-toggle > summary:not(.hideme)::before {
position: absolute;
top: 3px;
left: -2px;
} }
/* When a "hideme" summary is open and the "Expand description" or "Show /* When a "hideme" summary is open and the "Expand description" or "Show
@ -1798,7 +1816,7 @@ details.rustdoc-toggle[open] > summary.hideme {
position: absolute; position: absolute;
} }
details.rustdoc-toggle[open] { details.rustdoc-toggle, details.undocumented {
position: relative; position: relative;
} }
@ -1810,3 +1828,14 @@ details.rustdoc-toggle[open] > summary::before {
content: "[]"; content: "[]";
display: inline; display: inline;
} }
details.undocumented > summary::before {
content: "[+] Show hidden undocumented items";
cursor: pointer;
font-size: 16px;
font-weight: 300;
}
details.undocumented[open] > summary::before {
content: "[-] Hide undocumented items";
}

View file

@ -226,7 +226,8 @@ a {
.collapse-toggle, .collapse-toggle,
details.rustdoc-toggle > summary.hideme > span, details.rustdoc-toggle > summary.hideme > span,
details.rustdoc-toggle > summary::before { details.rustdoc-toggle > summary::before,
details.undocumented > summary::before {
color: #999; color: #999;
} }

View file

@ -188,7 +188,8 @@ a.test-arrow {
.collapse-toggle, .collapse-toggle,
details.rustdoc-toggle > summary.hideme > span, details.rustdoc-toggle > summary.hideme > span,
details.rustdoc-toggle > summary::before { details.rustdoc-toggle > summary::before,
details.undocumented > summary::before {
color: #999; color: #999;
} }

View file

@ -186,7 +186,8 @@ a.test-arrow {
.collapse-toggle, .collapse-toggle,
details.rustdoc-toggle > summary.hideme > span, details.rustdoc-toggle > summary.hideme > span,
details.rustdoc-toggle > summary::before { details.rustdoc-toggle > summary::before,
details.undocumented > summary::before {
color: #999; color: #999;
} }

View file

@ -88,12 +88,14 @@ impl Qux for Bar {
/// Docs for QUX1 in impl. /// Docs for QUX1 in impl.
const QUX1: i8 = 5; const QUX1: i8 = 5;
// @has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' // @has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16'
// @has - '//*[@class="docblock hidden"]' "Docs for QUX_DEFAULT12 in trait." // @!has - '//div[@class="impl-items"]/details[@open=""]//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait."
// @has - '//div[@class="impl-items"]/details//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait."
const QUX_DEFAULT0: u16 = 6; const QUX_DEFAULT0: u16 = 6;
// @has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' // @has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16'
// @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl." // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl."
/// Docs for QUX_DEFAULT1 in impl. /// Docs for QUX_DEFAULT1 in impl.
const QUX_DEFAULT1: i16 = 7; const QUX_DEFAULT1: i16 = 7;
// @has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' // @has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32'
// @has - '//*[@class="docblock hidden"]' "Docs for QUX_DEFAULT2 in trait." // @!has - '//div[@class="impl-items"]/details[@open=""]//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait."
// @has - '//div[@class="impl-items"]/details//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait."
} }

View file

@ -16,15 +16,18 @@ extern crate assoc_items;
// @has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16' // @has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16'
// @has - '//*[@class="docblock"]' 'dox for ConstNoDefault' // @has - '//*[@class="docblock"]' 'dox for ConstNoDefault'
// @has - '//*[@id="associatedconstant.ConstWithDefault"]' 'const ConstWithDefault: u16' // @has - '//*[@id="associatedconstant.ConstWithDefault"]' 'const ConstWithDefault: u16'
// @has - '//*[@class="docblock hidden"]' 'docs for ConstWithDefault' // @!has - '//details[@open=""]/details/div[@class="docblock"]' 'docs for ConstWithDefault'
// @has - '//details/details/div[@class="docblock"]' 'docs for ConstWithDefault'
// @has - '//*[@id="associatedtype.TypeNoDefault"]' 'type TypeNoDefault = i32' // @has - '//*[@id="associatedtype.TypeNoDefault"]' 'type TypeNoDefault = i32'
// @has - '//*[@class="docblock"]' 'dox for TypeNoDefault' // @has - '//*[@class="docblock"]' 'dox for TypeNoDefault'
// @has - '//*[@id="associatedtype.TypeWithDefault"]' 'type TypeWithDefault = u32' // @has - '//*[@id="associatedtype.TypeWithDefault"]' 'type TypeWithDefault = u32'
// @has - '//*[@class="docblock hidden"]' 'docs for TypeWithDefault' // @!has - '//details[@open=""]/details/div[@class="docblock"]' 'docs for TypeWithDefault'
// @has - '//details/details/div[@class="docblock"]' 'docs for TypeWithDefault'
// @has - '//*[@id="method.method_no_default"]' 'fn method_no_default()' // @has - '//*[@id="method.method_no_default"]' 'fn method_no_default()'
// @has - '//*[@class="docblock"]' 'dox for method_no_default' // @has - '//*[@class="docblock"]' 'dox for method_no_default'
// @has - '//*[@id="method.method_with_default"]' 'fn method_with_default()' // @has - '//*[@id="method.method_with_default"]' 'fn method_with_default()'
// @has - '//*[@class="docblock hidden"]' 'docs for method_with_default' // @!has - '//details[@open=""]/details/div[@class="docblock"]' 'docs for method_with_default'
// @has - '//details/details/div[@class="docblock"]' 'docs for method_with_default'
pub use assoc_items::MyStruct; pub use assoc_items::MyStruct;
// @has foo/trait.MyTrait.html // @has foo/trait.MyTrait.html

View file

@ -8,5 +8,6 @@ extern crate impl_inline_without_trait;
// @has 'foo/struct.MyStruct.html' // @has 'foo/struct.MyStruct.html'
// @has - '//*[@id="method.my_trait_method"]' 'fn my_trait_method()' // @has - '//*[@id="method.my_trait_method"]' 'fn my_trait_method()'
// @has - '//*[@class="docblock hidden"]' 'docs for my_trait_method' // @!has - '//details[@open=""]/details/div[@class="docblock"]' 'docs for my_trait_method'
// @has - '//details/details/div[@class="docblock"]' 'docs for my_trait_method'
pub use impl_inline_without_trait::MyStruct; pub use impl_inline_without_trait::MyStruct;

View file

@ -24,10 +24,13 @@ pub trait T {
// @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.' // @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.'
// @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.' // @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.'
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' // @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait b_method definition.' // @!has - '//div[@class="impl-items"]/details[@open=""]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.'
// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait c_method definition.' // @has - '//div[@class="impl-items"]/details//div[@class="docblock"]' 'Docs associated with the trait b_method definition.'
// @!has - '//div[@class="impl-items"]/details[@open=""]//div[@class="docblock"]' 'Docs associated with the trait c_method definition.'
// @has - '//div[@class="impl-items"]/details//div[@class="docblock"]' 'Docs associated with the trait c_method definition.'
// @!has - '//*[@class="docblock"]' 'There is another line' // @!has - '//*[@class="docblock"]' 'There is another line'
// @has - '//*[@class="docblock hidden"]' 'Read more' // @!has - '//div[@class="impl-items"]/details[@open=""]//div[@class="docblock"]' 'Read more'
// @has - '//div[@class="impl-items"]/details//div[@class="docblock"]' 'Read more'
pub struct S1(usize); pub struct S1(usize);
/// Docs associated with the S1 trait implementation. /// Docs associated with the S1 trait implementation.
@ -42,9 +45,10 @@ impl T for S1 {
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.' // @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.'
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.' // @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.'
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.' // @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.'
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' // @!has - '//details[open=""]/div[@class="docblock"]' 'Docs associated with the trait a_method definition.'
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait c_method definition.' // @!has - '//details[open=""]/div[@class="docblock"]' 'Docs associated with the trait c_method definition.'
// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait b_method definition.' // @!has - '//div[@class="impl-items"]/details[@open=""]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.'
// @has - '//div[@class="impl-items"]/details//div[@class="docblock"]' 'Docs associated with the trait b_method definition.'
pub struct S2(usize); pub struct S2(usize);
/// Docs associated with the S2 trait implementation. /// Docs associated with the S2 trait implementation.
@ -61,9 +65,10 @@ impl T for S2 {
} }
// @has manual_impl/struct.S3.html '//*[@class="trait"]' 'T' // @has manual_impl/struct.S3.html '//*[@class="trait"]' 'T'
// @has - '//*[@class="docblock"]' 'Docs associated with the S3 trait implementation.' // @has - '//details[@open=""]/div[@class="docblock"]' 'Docs associated with the S3 trait implementation.'
// @has - '//*[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.' // @has - '//details[@open=""]/div[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.'
// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait a_method definition.' // @!has - '//div[@class="impl-items"]/details[@open=""]//div[@class="docblock"]' 'Docs associated with the trait a_method definition.'
// @has - '//div[@class="impl-items"]/details//div[@class="docblock"]' 'Docs associated with the trait a_method definition.'
pub struct S3(usize); pub struct S3(usize);
/// Docs associated with the S3 trait implementation. /// Docs associated with the S3 trait implementation.

View file

@ -21,26 +21,27 @@ pub trait Trait {
pub struct Struct; pub struct Struct;
impl Trait for Struct { impl Trait for Struct {
// @has trait_impl/struct.Struct.html '//*[@id="method.a"]/../div/p' 'Some long docs' // @has trait_impl/struct.Struct.html '//*[@id="method.a"]/../../div[@class="docblock"]/p' 'Some long docs'
// @!has - '//*[@id="method.a"]/../div/p' 'link will be added' // @!has - '//*[@id="method.a"]/../../div[@class="docblock"]/p' 'link will be added'
// @has - '//*[@id="method.a"]/../div/p/a' 'Read more' // @has - '//*[@id="method.a"]/../../div[@class="docblock"]/p/a' 'Read more'
// @has - '//*[@id="method.a"]/../div/p/a/@href' 'trait.Trait.html' // @has - '//*[@id="method.a"]/../../div[@class="docblock"]/p/a/@href' 'trait.Trait.html#tymethod.a'
fn a() {} fn a() {}
// @has trait_impl/struct.Struct.html '//*[@id="method.b"]/../div/p' 'These docs contain' // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p' 'These docs contain'
// @has - '//*[@id="method.b"]/../div/p/a' 'reference link' // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a' 'reference link'
// @has - '//*[@id="method.b"]/../div/p/a/@href' 'https://example.com' // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a/@href' 'https://example.com'
// @has - '//*[@id="method.b"]/../div/p/a' 'Read more' // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a' 'Read more'
// @has - '//*[@id="method.b"]/../div/p/a/@href' 'trait.Trait.html' // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a/@href' 'trait.Trait.html#tymethod.b'
fn b() {} fn b() {}
// @!has trait_impl/struct.Struct.html '//*[@id="method.c"]/../div/p' 'code block' // @!has - '//*[@id="method.c"]/../../div[@class="docblock"]/p' 'code block'
// @has - '//*[@id="method.c"]/../div/p/a' 'Read more' // @has - '//*[@id="method.c"]/../../div[@class="docblock"]/a' 'Read more'
// @has - '//*[@id="method.c"]/../div/p/a/@href' 'trait.Trait.html' // @has - '//*[@id="method.c"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.c'
fn c() {} fn c() {}
// @has trait_impl/struct.Struct.html '//*[@id="method.d"]/../div/p' \ // @has - '//*[@id="method.d"]/../../div[@class="docblock"]/p' 'Escaped formatting a*b*c* works'
// 'Escaped formatting a*b*c* works' // @!has - '//*[@id="method.d"]/../../div[@class="docblock"]/p/em'
// @!has trait_impl/struct.Struct.html '//*[@id="method.d"]/../div/p/em'
fn d() {} fn d() {}
// @has - '//*[@id="impl-Trait"]/code/a/@href' 'trait.Trait.html'
} }