Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 22bbbe8

Browse files
borsGuillaumeGomez
authored andcommittedJul 26, 2021
Rustdoc accessibility: use real headers for doc items
Part of #87059 Partially reverts #84703 Heavily modified for beta backport needs.
1 parent 963e820 commit 22bbbe8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+271
-228
lines changed
 

‎src/librustdoc/html/render/mod.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
12141214
if out.is_empty() {
12151215
write!(
12161216
&mut out,
1217-
"<h3 class=\"notable\">Notable traits for {}</h3>\
1217+
"<div class=\"notable\">Notable traits for {}</div>\
12181218
<code class=\"content\">",
12191219
impl_.for_.print(cx)
12201220
);
@@ -1370,15 +1370,15 @@ fn render_impl(
13701370
"<div id=\"{}\" class=\"{}{} has-srclink\">",
13711371
id, item_type, in_trait_class,
13721372
);
1373-
w.write_str("<code>");
1373+
w.write_str("<h4 class=\"code-header\">");
13741374
render_assoc_item(
13751375
w,
13761376
item,
13771377
link.anchor(source_id.as_ref().unwrap_or(&id)),
13781378
ItemType::Impl,
13791379
cx,
13801380
);
1381-
w.write_str("</code>");
1381+
w.write_str("</h4>");
13821382
render_stability_since_raw(
13831383
w,
13841384
item.stable_since(tcx).as_deref(),
@@ -1396,9 +1396,10 @@ fn render_impl(
13961396
let id = cx.derive_id(source_id.clone());
13971397
write!(
13981398
w,
1399-
"<div id=\"{}\" class=\"{}{} has-srclink\"><code>",
1399+
"<div id=\"{}\" class=\"{}{} has-srclink\">",
14001400
id, item_type, in_trait_class
14011401
);
1402+
w.write_str("<h4 class=\"code-header\">");
14021403
assoc_type(
14031404
w,
14041405
item,
@@ -1408,7 +1409,7 @@ fn render_impl(
14081409
"",
14091410
cx,
14101411
);
1411-
w.write_str("</code>");
1412+
w.write_str("</h4>");
14121413
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
14131414
w.write_str("</div>");
14141415
}
@@ -1417,9 +1418,10 @@ fn render_impl(
14171418
let id = cx.derive_id(source_id.clone());
14181419
write!(
14191420
w,
1420-
"<div id=\"{}\" class=\"{}{} has-srclink\"><code>",
1421+
"<div id=\"{}\" class=\"{}{} has-srclink\">",
14211422
id, item_type, in_trait_class
14221423
);
1424+
w.write_str("<h4 class=\"code-header\">");
14231425
assoc_const(
14241426
w,
14251427
item,
@@ -1429,7 +1431,7 @@ fn render_impl(
14291431
"",
14301432
cx,
14311433
);
1432-
w.write_str("</code>");
1434+
w.write_str("</h4>");
14331435
render_stability_since_raw(
14341436
w,
14351437
item.stable_since(tcx).as_deref(),
@@ -1444,7 +1446,8 @@ fn render_impl(
14441446
clean::AssocTypeItem(ref bounds, ref default) => {
14451447
let source_id = format!("{}.{}", item_type, name);
14461448
let id = cx.derive_id(source_id.clone());
1447-
write!(w, "<div id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class,);
1449+
write!(w, "<div id=\"{}\" class=\"{}{}\">", id, item_type, in_trait_class,);
1450+
w.write_str("<h4 class=\"code-header\">");
14481451
assoc_type(
14491452
w,
14501453
item,
@@ -1454,7 +1457,7 @@ fn render_impl(
14541457
"",
14551458
cx,
14561459
);
1457-
w.write_str("</code>");
1460+
w.write_str("</h4>");
14581461
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
14591462
w.write_str("</div>");
14601463
}
@@ -1638,12 +1641,8 @@ fn render_impl_summary(
16381641
format!(" data-aliases=\"{}\"", aliases.join(","))
16391642
};
16401643
if let Some(use_absolute) = use_absolute {
1641-
write!(
1642-
w,
1643-
"<div id=\"{}\" class=\"impl has-srclink\"{}>\
1644-
<code class=\"in-band\">",
1645-
id, aliases
1646-
);
1644+
write!(w, "<div id=\"{}\" class=\"impl has-srclink\"{}>", id, aliases);
1645+
write!(w, "<h3 class=\"code-header in-band\">");
16471646
write!(w, "{}", i.inner_impl().print(use_absolute, cx));
16481647
if show_def_docs {
16491648
for it in &i.inner_impl().items {
@@ -1654,12 +1653,12 @@ fn render_impl_summary(
16541653
}
16551654
}
16561655
}
1657-
w.write_str("</code>");
1656+
w.write_str("</h3>");
16581657
} else {
16591658
write!(
16601659
w,
16611660
"<div id=\"{}\" class=\"impl has-srclink\"{}>\
1662-
<code class=\"in-band\">{}</code>",
1661+
<h3 class=\"code-header in-band\">{}</h3>",
16631662
id,
16641663
aliases,
16651664
i.inner_impl().print(false, cx)

‎src/librustdoc/html/render/print_item.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,10 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
585585
if toggled {
586586
write!(w, "<details class=\"rustdoc-toggle\" open><summary>");
587587
}
588-
write!(w, "<div id=\"{}\" class=\"method has-srclink\"><code>", id);
588+
write!(w, "<div id=\"{}\" class=\"method has-srclink\">", id);
589+
write!(w, "<h4 class=\"code-header\">");
589590
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx);
590-
w.write_str("</code>");
591+
w.write_str("</h4>");
591592
render_stability_since(w, m, t, cx.tcx());
592593
write_srclink(cx, m, w);
593594
w.write_str("</div>");

0 commit comments

Comments
 (0)