Rollup merge of #104772 - GuillaumeGomez:small-accessibility-improvement, r=notriddle
Small accessibility improvements From this [reddit post](https://www.reddit.com/r/rust/comments/z1gyz7/accessible_documentation/), I started to check a bit how to improve accessibility and how we could add test for it. So these two fixes come from the use of the [pa11y tool](https://github.com/pa11y/pa11y). To make it work, I had to update its puppeteer version to the last one but otherwise it seems to be quite nice. I didn't fix all the errors it reported because they were about colors. To get the same result as mine, you can use this config: ```json { "ignore": [ "WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Fail", "WCAG2AA.Principle3.Guideline3_2.3_2_2.H32.2" ] } ``` I think trying to improve accessibility is something we should definitely aim for. I'll try to integrate a tool to enforce this check (very likely `pa11y`) directly into the CI. cc ``@jsha`` r? ``@notriddle``
This commit is contained in:
commit
a3371560ee
@ -1071,7 +1071,7 @@ fn write_impl_section_heading(w: &mut Buffer, title: &str, id: &str) {
|
||||
w,
|
||||
"<h2 id=\"{id}\" class=\"small-section-header\">\
|
||||
{title}\
|
||||
<a href=\"#{id}\" class=\"anchor\"></a>\
|
||||
<a href=\"#{id}\" class=\"anchor\">§</a>\
|
||||
</h2>"
|
||||
);
|
||||
}
|
||||
@ -1536,7 +1536,7 @@ fn render_impl(
|
||||
render_rightside(w, cx, item, containing_item, render_mode);
|
||||
if trait_.is_some() {
|
||||
// Anchors are only used on trait impls.
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\">§</a>", id);
|
||||
}
|
||||
w.write_str("<h4 class=\"code-header\">");
|
||||
render_assoc_item(
|
||||
@ -1562,7 +1562,7 @@ fn render_impl(
|
||||
render_rightside(w, cx, item, containing_item, render_mode);
|
||||
if trait_.is_some() {
|
||||
// Anchors are only used on trait impls.
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\">§</a>", id);
|
||||
}
|
||||
w.write_str("<h4 class=\"code-header\">");
|
||||
assoc_const(
|
||||
@ -1587,7 +1587,7 @@ fn render_impl(
|
||||
write!(w, "<section id=\"{}\" class=\"{}{}\">", id, item_type, in_trait_class);
|
||||
if trait_.is_some() {
|
||||
// Anchors are only used on trait impls.
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\">§</a>", id);
|
||||
}
|
||||
w.write_str("<h4 class=\"code-header\">");
|
||||
assoc_type(
|
||||
@ -1613,7 +1613,7 @@ fn render_impl(
|
||||
);
|
||||
if trait_.is_some() {
|
||||
// Anchors are only used on trait impls.
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\">§</a>", id);
|
||||
}
|
||||
w.write_str("<h4 class=\"code-header\">");
|
||||
assoc_type(
|
||||
@ -1846,7 +1846,7 @@ pub(crate) fn render_impl_summary(
|
||||
};
|
||||
write!(w, "<section id=\"{}\" class=\"impl has-srclink\"{}>", id, aliases);
|
||||
render_rightside(w, cx, &i.impl_item, containing_item, RenderMode::Normal);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\">§</a>", id);
|
||||
write!(w, "<h3 class=\"code-header\">");
|
||||
|
||||
if let Some(use_absolute) = use_absolute {
|
||||
|
@ -717,7 +717,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
|
||||
write!(
|
||||
w,
|
||||
"<h2 id=\"{0}\" class=\"small-section-header\">\
|
||||
{1}<a href=\"#{0}\" class=\"anchor\"></a>\
|
||||
{1}<a href=\"#{0}\" class=\"anchor\">§</a>\
|
||||
</h2>{2}",
|
||||
id, title, extra_content
|
||||
)
|
||||
@ -1147,7 +1147,7 @@ fn item_union(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean:
|
||||
write!(
|
||||
w,
|
||||
"<h2 id=\"fields\" class=\"fields small-section-header\">\
|
||||
Fields<a href=\"#fields\" class=\"anchor\"></a>\
|
||||
Fields<a href=\"#fields\" class=\"anchor\">§</a>\
|
||||
</h2>"
|
||||
);
|
||||
for (field, ty) in fields {
|
||||
@ -1156,7 +1156,7 @@ fn item_union(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean:
|
||||
write!(
|
||||
w,
|
||||
"<span id=\"{id}\" class=\"{shortty} small-section-header\">\
|
||||
<a href=\"#{id}\" class=\"anchor field\"></a>\
|
||||
<a href=\"#{id}\" class=\"anchor field\">§</a>\
|
||||
<code>{name}: {ty}</code>\
|
||||
</span>",
|
||||
id = id,
|
||||
@ -1262,7 +1262,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
|
||||
write!(
|
||||
w,
|
||||
"<h2 id=\"variants\" class=\"variants small-section-header\">\
|
||||
Variants{}<a href=\"#variants\" class=\"anchor\"></a>\
|
||||
Variants{}<a href=\"#variants\" class=\"anchor\">§</a>\
|
||||
</h2>",
|
||||
document_non_exhaustive_header(it)
|
||||
);
|
||||
@ -1273,7 +1273,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
|
||||
write!(
|
||||
w,
|
||||
"<section id=\"{id}\" class=\"variant\">\
|
||||
<a href=\"#{id}\" class=\"anchor\"></a>",
|
||||
<a href=\"#{id}\" class=\"anchor\">§</a>",
|
||||
id = id,
|
||||
);
|
||||
render_stability_since_raw_with_extra(
|
||||
@ -1325,7 +1325,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
|
||||
w,
|
||||
"<div class=\"sub-variant-field\">\
|
||||
<span id=\"{id}\" class=\"small-section-header\">\
|
||||
<a href=\"#{id}\" class=\"anchor field\"></a>\
|
||||
<a href=\"#{id}\" class=\"anchor field\">§</a>\
|
||||
<code>{f}: {t}</code>\
|
||||
</span>",
|
||||
id = id,
|
||||
@ -1477,7 +1477,7 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
|
||||
write!(
|
||||
w,
|
||||
"<h2 id=\"fields\" class=\"fields small-section-header\">\
|
||||
{}{}<a href=\"#fields\" class=\"anchor\"></a>\
|
||||
{}{}<a href=\"#fields\" class=\"anchor\">§</a>\
|
||||
</h2>",
|
||||
if s.ctor_kind.is_none() { "Fields" } else { "Tuple Fields" },
|
||||
document_non_exhaustive_header(it)
|
||||
@ -1490,7 +1490,7 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
|
||||
write!(
|
||||
w,
|
||||
"<span id=\"{id}\" class=\"{item_type} small-section-header\">\
|
||||
<a href=\"#{id}\" class=\"anchor field\"></a>\
|
||||
<a href=\"#{id}\" class=\"anchor field\">§</a>\
|
||||
<code>{name}: {ty}</code>\
|
||||
</span>",
|
||||
item_type = ItemType::StructField,
|
||||
@ -1908,7 +1908,7 @@ fn document_type_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) {
|
||||
writeln!(
|
||||
w,
|
||||
"<h2 id=\"layout\" class=\"small-section-header\"> \
|
||||
Layout<a href=\"#layout\" class=\"anchor\"></a></h2>"
|
||||
Layout<a href=\"#layout\" class=\"anchor\">§</a></h2>"
|
||||
);
|
||||
writeln!(w, "<div class=\"docblock\">");
|
||||
|
||||
|
@ -730,9 +730,6 @@ a {
|
||||
h2.small-section-header > .anchor {
|
||||
padding-right: 6px;
|
||||
}
|
||||
.anchor::before {
|
||||
content: '§';
|
||||
}
|
||||
|
||||
.main-heading a:hover,
|
||||
.example-wrap > pre.rust a:hover,
|
||||
|
@ -115,6 +115,7 @@
|
||||
<input {# -#}
|
||||
class="search-input" {# -#}
|
||||
name="search" {# -#}
|
||||
aria-label="Run search in the documentation" {# -#}
|
||||
autocomplete="off" {# -#}
|
||||
spellcheck="false" {# -#}
|
||||
placeholder="Click or press ‘S’ to search, ‘?’ for more options…" {# -#}
|
||||
|
Loading…
x
Reference in New Issue
Block a user