rustdoc: use details tag for trait implementors
This switches from JS-generated toggles to using the HTML <details> tag for expanding and collapsing entries in the "Implementors" section.
This commit is contained in:
parent
392ba2ba1a
commit
569096cbaf
25 changed files with 68 additions and 66 deletions
|
@ -1313,6 +1313,7 @@ fn render_impl(
|
|||
let cache = cx.cache();
|
||||
let traits = &cache.traits;
|
||||
let trait_ = i.trait_did_full(cache).map(|did| &traits[&did]);
|
||||
let mut close_tags = String::new();
|
||||
|
||||
if render_mode == RenderMode::Normal {
|
||||
let id = cx.derive_id(match i.inner_impl().trait_ {
|
||||
|
@ -1331,7 +1332,12 @@ fn render_impl(
|
|||
format!(" aliases=\"{}\"", aliases.join(","))
|
||||
};
|
||||
if let Some(use_absolute) = use_absolute {
|
||||
write!(w, "<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">", id, aliases);
|
||||
write!(
|
||||
w,
|
||||
"<details class=\"rustdoc-toggle implementors-toggle\"><summary><h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">",
|
||||
id, aliases
|
||||
);
|
||||
close_tags.insert_str(0, "</details>");
|
||||
write!(w, "{}", i.inner_impl().print(use_absolute, cx));
|
||||
if show_def_docs {
|
||||
for it in &i.inner_impl().items {
|
||||
|
@ -1354,11 +1360,12 @@ fn render_impl(
|
|||
} else {
|
||||
write!(
|
||||
w,
|
||||
"<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">{}</code>",
|
||||
"<details class=\"rustdoc-toggle implementors-toggle\"><summary><h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">{}</code>",
|
||||
id,
|
||||
aliases,
|
||||
i.inner_impl().print(false, cx)
|
||||
);
|
||||
close_tags.insert_str(0, "</details>");
|
||||
}
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
render_stability_since_raw(
|
||||
|
@ -1370,6 +1377,7 @@ fn render_impl(
|
|||
);
|
||||
write_srclink(cx, &i.impl_item, w);
|
||||
w.write_str("</h3>");
|
||||
w.write_str("</summary>");
|
||||
|
||||
if trait_.is_some() {
|
||||
if let Some(portability) = portability(&i.impl_item, Some(parent)) {
|
||||
|
@ -1580,6 +1588,7 @@ fn render_impl(
|
|||
}
|
||||
|
||||
w.write_str("<div class=\"impl-items\">");
|
||||
close_tags.insert_str(0, "</div>");
|
||||
for trait_item in &i.inner_impl().items {
|
||||
doc_impl_item(
|
||||
w,
|
||||
|
@ -1650,7 +1659,7 @@ fn render_impl(
|
|||
);
|
||||
}
|
||||
}
|
||||
w.write_str("</div>");
|
||||
w.write_str(&close_tags);
|
||||
}
|
||||
|
||||
fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue