Skip to content

Commit 9457380

Browse files
committed
rustdoc: remove docblock class from item-decl
This class was originally added in 73b97c7 to support hiding and showing the item, because `main.js` went through all `docblock` elements in the DOM and added toggles to them. https://github.com/rust-lang/rust/blob/73b97c7e7c9cfac4dfa4804654b1db6ab687b589/src/librustdoc/html/static/main.js#L1856-L1867 The `item-decl` is no longer auto-hidden since c96f86d removed it. `item-decl` used to be called `type-decl`: that name was changed in 8b7a2dd. The `docblock` class is no longer used for implementing toggles, since rustdoc switched to using `<details>` elements.
1 parent a37499a commit 9457380

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

src/librustdoc/html/render/print_item.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ fn item_function(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, f: &cle
514514
+ name.as_str().len()
515515
+ generics_len;
516516

517-
wrap_into_docblock(w, |w| {
517+
wrap_into_item_decl(w, |w| {
518518
wrap_item(w, "fn", |w| {
519519
render_attributes_in_pre(w, it, "");
520520
w.reserve(header_len);
@@ -553,7 +553,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
553553
cx.tcx().trait_def(t.def_id).must_implement_one_of.clone();
554554

555555
// Output the trait definition
556-
wrap_into_docblock(w, |w| {
556+
wrap_into_item_decl(w, |w| {
557557
wrap_item(w, "trait", |w| {
558558
render_attributes_in_pre(w, it, "");
559559
write!(
@@ -1033,7 +1033,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
10331033
}
10341034

10351035
fn item_trait_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::TraitAlias) {
1036-
wrap_into_docblock(w, |w| {
1036+
wrap_into_item_decl(w, |w| {
10371037
wrap_item(w, "trait-alias", |w| {
10381038
render_attributes_in_pre(w, it, "");
10391039
write!(
@@ -1057,7 +1057,7 @@ fn item_trait_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &
10571057
}
10581058

10591059
fn item_opaque_ty(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::OpaqueTy) {
1060-
wrap_into_docblock(w, |w| {
1060+
wrap_into_item_decl(w, |w| {
10611061
wrap_item(w, "opaque", |w| {
10621062
render_attributes_in_pre(w, it, "");
10631063
write!(
@@ -1096,7 +1096,7 @@ fn item_typedef(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clea
10961096
});
10971097
}
10981098

1099-
wrap_into_docblock(w, |w| write_content(w, cx, it, t));
1099+
wrap_into_item_decl(w, |w| write_content(w, cx, it, t));
11001100

11011101
document(w, cx, it, None, HeadingOffset::H2);
11021102

@@ -1110,7 +1110,7 @@ fn item_typedef(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clea
11101110
}
11111111

11121112
fn item_union(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean::Union) {
1113-
wrap_into_docblock(w, |w| {
1113+
wrap_into_item_decl(w, |w| {
11141114
wrap_item(w, "union", |w| {
11151115
render_attributes_in_pre(w, it, "");
11161116
render_union(w, it, Some(&s.generics), &s.fields, "", cx);
@@ -1174,7 +1174,7 @@ fn print_tuple_struct_fields(w: &mut Buffer, cx: &Context<'_>, s: &[clean::Item]
11741174

11751175
fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::Enum) {
11761176
let count_variants = e.variants().count();
1177-
wrap_into_docblock(w, |w| {
1177+
wrap_into_item_decl(w, |w| {
11781178
wrap_item(w, "enum", |w| {
11791179
render_attributes_in_pre(w, it, "");
11801180
write!(
@@ -1333,14 +1333,14 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
13331333
}
13341334

13351335
fn item_macro(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::Macro) {
1336-
wrap_into_docblock(w, |w| {
1336+
wrap_into_item_decl(w, |w| {
13371337
highlight::render_macro_with_highlighting(&t.source, w);
13381338
});
13391339
document(w, cx, it, None, HeadingOffset::H2)
13401340
}
13411341

13421342
fn item_proc_macro(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, m: &clean::ProcMacro) {
1343-
wrap_into_docblock(w, |w| {
1343+
wrap_into_item_decl(w, |w| {
13441344
let name = it.name.expect("proc-macros always have names");
13451345
match m.kind {
13461346
MacroKind::Bang => {
@@ -1387,7 +1387,7 @@ fn item_primitive(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item) {
13871387
}
13881388

13891389
fn item_constant(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, c: &clean::Constant) {
1390-
wrap_into_docblock(w, |w| {
1390+
wrap_into_item_decl(w, |w| {
13911391
wrap_item(w, "const", |w| {
13921392
render_attributes_in_code(w, it);
13931393

@@ -1436,7 +1436,7 @@ fn item_constant(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, c: &cle
14361436
}
14371437

14381438
fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean::Struct) {
1439-
wrap_into_docblock(w, |w| {
1439+
wrap_into_item_decl(w, |w| {
14401440
wrap_item(w, "struct", |w| {
14411441
render_attributes_in_code(w, it);
14421442
render_struct(w, it, Some(&s.generics), s.struct_type, &s.fields, "", true, cx);
@@ -1489,7 +1489,7 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
14891489
}
14901490

14911491
fn item_static(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean::Static) {
1492-
wrap_into_docblock(w, |w| {
1492+
wrap_into_item_decl(w, |w| {
14931493
wrap_item(w, "static", |w| {
14941494
render_attributes_in_code(w, it);
14951495
write!(
@@ -1506,7 +1506,7 @@ fn item_static(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
15061506
}
15071507

15081508
fn item_foreign_type(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item) {
1509-
wrap_into_docblock(w, |w| {
1509+
wrap_into_item_decl(w, |w| {
15101510
wrap_item(w, "foreigntype", |w| {
15111511
w.write_str("extern {\n");
15121512
render_attributes_in_code(w, it);
@@ -1595,11 +1595,11 @@ fn bounds(t_bounds: &[clean::GenericBound], trait_alias: bool, cx: &Context<'_>)
15951595
bounds
15961596
}
15971597

1598-
fn wrap_into_docblock<F>(w: &mut Buffer, f: F)
1598+
fn wrap_into_item_decl<F>(w: &mut Buffer, f: F)
15991599
where
16001600
F: FnOnce(&mut Buffer),
16011601
{
1602-
w.write_str("<div class=\"docblock item-decl\">");
1602+
w.write_str("<div class=\"item-decl\">");
16031603
f(w);
16041604
w.write_str("</div>")
16051605
}

src/librustdoc/html/static/css/rustdoc.css

-3
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,6 @@ code, pre, a.test-arrow, .code-header {
372372
pre {
373373
padding: 14px;
374374
}
375-
.docblock.item-decl {
376-
margin-left: 0;
377-
}
378375
.item-decl pre {
379376
overflow-x: auto;
380377
}

0 commit comments

Comments
 (0)