Improve accessibility:
* Set aria-label attribute on search input * Put anchor text directly into the DOM and not in the CSS
This commit is contained in:
parent
4e0d0d757e
commit
aa73e29799
@ -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 doc_impl_item(
|
||||
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 doc_impl_item(
|
||||
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 doc_impl_item(
|
||||
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 doc_impl_item(
|
||||
);
|
||||
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 write_small_section_header(w: &mut Buffer, id: &str, title: &str, extra_conte
|
||||
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 write_size_of_layout(w: &mut Buffer, layout: Layout<'_>, tag_size: u64) {
|
||||
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\">");
|
||||
|
||||
|
@ -728,9 +728,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…
Reference in New Issue
Block a user