Skip to content

Commit 73a5c1f

Browse files
committed
Toggle-wrap items differently than top-doc.
This makes sure things like trait methods get wrapped at the `<h3><code>` level rather than at the `.docblock` level. Also it ensures that only the actual top documentation gets the `.top-doc` class.
1 parent 754d171 commit 73a5c1f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/librustdoc/html/render/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,11 @@ fn document(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, parent: Option
509509
info!("Documenting {}", name);
510510
}
511511
document_item_info(w, cx, item, parent);
512-
document_full_collapsible(w, item, cx);
512+
if parent.is_none() {
513+
document_full_collapsible(w, item, cx);
514+
} else {
515+
document_full(w, item, cx);
516+
}
513517
}
514518

515519
/// Render md_text as markdown.

src/librustdoc/html/render/print_item.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,13 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
578578
info!("Documenting {} on {:?}", name, t.name);
579579
let item_type = m.type_();
580580
let id = cx.derive_id(format!("{}.{}", item_type, name));
581+
write!(w, "<details class=\"rustdoc-toggle\" open><summary>");
581582
write!(w, "<h3 id=\"{id}\" class=\"method\"><code>", id = id,);
582583
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx);
583584
w.write_str("</code>");
584585
render_stability_since(w, m, t, cx.tcx());
585586
write_srclink(cx, m, w);
586-
w.write_str("</h3>");
587+
w.write_str("</h3></summary>");
587588
document(w, cx, m, Some(t));
588589
}
589590

0 commit comments

Comments
 (0)