-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix screen reader accessibility of rustdoc item documentation #87059
Comments
cc @jsha |
@ahicks92 when you say "coming down the pipeline" you specifically mean that these are changes in beta, that haven't made it to stable, right? |
Also, a broader question: your suggested changes seem fine to me, and I will try to make sure one or more of them land before the beta release, but how can we avoid regressions like this in the future? Do you know some software that can "rate" how accessible a page is, something like Google PageSpeed insights but for HTML layouts? Or are you maybe willing to donate a bit of your time every six weeks before a release? I can ask contributors to try their changes with a screen reader, but that seems like a burden to contributing to me; neither they nor I would really know what to look for. |
Is there a way to tell screen readers not to read aloud certain buttons/divs? That seems like a better fix than just moving the buttons between the content. |
Looking at the accessiblity panel in the Firefox Developer tools it seems like at least as far as
Using
Alas, the CSS pseudo elements are still included into the screen reader output and removing it is not trivial. It doesn't seem like WAI-ARIA has (ahem…) a way to specifically target CSS pseudo elements either. We need to re-factor the DOM somewhat significantly here to get things work out I suspect.
From looking at the accessibility trees and given the descriptions it seems like that's the correct interpretation.
I believe this refers to the fact that what previously was a <h4 id="method.clear" class="method">
<code>pub fn <a href="#method.clear" class="fnname">clear</a>(&mut self)</code><a href="#method.clear" class="anchor"></a><a class="srclink" href="../../src/alloc/collections/btree/map.rs.html#512" title="goto source code">[src]</a><a href="javascript:void(0)" class="collapse-toggle">[<span class="inner">−</span>]</a>
</h4> is now a <summary><div id="method.clear" class="method has-srclink">
<code>pub fn <a href="#method.clear" class="fnname">clear</a>(&mut self)</code><a href="#method.clear" class="anchor"></a><a class="srclink" href="../../src/alloc/collections/btree/map.rs.html#512" title="goto source code">[src]</a>
</div></summary> (i.e. the
I don't believe there is a way to hide the ToC (sidebar)… EDIT: Ah, I see what you mean. It is hidden into a hamburger menu in mobile layout. And the button to display it is… not focus-able. There is attempt to make this hamburger act like a button:
but for some reason that doesn't work? |
I mention the Firefox's accessibility developer tools panel in the post above. It can be used to intuit what a screen reader would read without having to set up a full accessibility stack. It also has some lints in there, though they are pretty anemic still, as well as an ability to display tab order in a nice way. |
Maybe I'm missing something but it has always been on the left of the items.
This button is only relevant on mobile or on devices with small width. There is no way to hide the sidebar otherwise. Also, overall our heading strategy was a complete mess, which was simplified/fixed by using the
This button is only relevant for mobile devices where you can't have the sidebar alongside the content. Anyway, we have a lot of progress to make on accessibility. I think integrated tools to ensure there is no big stepback in this regard would be a very nice improvement. |
Previously at the DOM level they came after the <h4 id="method.clear" class="method">
<code>pub fn
<a href="#method.clear" class="fnname">clear</a>
(&mut self)</code>
<a href="#method.clear" class="anchor"></a>
<a class="srclink" href="../../src/alloc/collections/btree/map.rs.html#512" title="goto source code">[src]</a>
<a href="javascript:void(0)" class="collapse-toggle">[<span class="inner">−</span>]</a>
<!-- ^^^ HERE ^^^ -->
</h4>
@ahicks92's complaint was specifically about the ToC only appearing when the browser window is maximized. Given that people using screenreaders don't usually need browsers rendering an entire screen worth of content, windows could get pretty small during their normal use. |
Oh I see! I'm way to used at thinking about display and not about DOM... Thanks for the clarification!
Is there a way to check if the page is rendered on a screenreader? If so, we could simply ignore the width in such a case and put the sidebar anyway. |
Happy to see quick feedback. To answer questions in no particular order and hopefully without missing anything: It does seem to be beta only. I've got an ongoing project in 1.53 which renders the old way, for lack of better phrasing. For some reason my browser starts not fully maximized. When I maximize it I get the table of contents. Screen readers like to read things in DOM order, so "end of the line" is indeed not really the best term for that. You can use CSS to make the visual order not match DOM and the screen readers still generally follow DOM order.
Fixing the table of contents probably "fixes" the order of elements on the line of the item itself, because the workflow here is/was using the h tags to find out what is available, and the point as far as I'm concerned is fixing the workflow. For myself, I'm satisfied as long as there's a quick way to skim method names. To the best of my knowledge, there isn't any good software for detecting this sort of accessibility issue, because this sort of accessibility issue is kind of subjective. You'd have to try very hard to make rustdoc so bad it's literally unusable at all, and the sorts of things like this aren't nearly so simple as "this font is white on white". I've never heard anyone managing to automate a screen reader navigation efficiency test. But I'm a non-accessibility backend dev so maybe there is. I believe there's more objective linters (e.g. this is an unlabeled link) but you would have to ask someone else for them, and frankly every browser/screen reader pair has different and uniquely special bugs. There's at least 16 that can matter before you even consider version numbers. You can find a lot of good accessibility-related info at WebAIM or in the WCAG and the various guides and things people have written about WCAG. It's not all entirely on point though, and it's also kind of interesting in that by the time someone is a programmer they're also a power user and efficiency starts mattering and shifts the trade-off from nice, long labels to a preference for terseness (or does for me--but that may be subjective). I probably don't have the bandwidth to do a lengthy audit every 6 weeks, but I'm happy to at least try to serve as a smoke test if someone pings me about it. |
Going to also drop this here: https://docs.rs/prost/0.8.0/prost/trait.Message.html Which has "left bracket minus right bracket go to source code" before everything. Looking at rust beta stdlib, that's not there for at least |
Hello, |
One thing I thought about to fix the "table of content" not being visible for screen readers would be to move it outside of the viewport when not being used. Would that work for you? |
Assigning priority as discussed in the Zulip thread of the Prioritization Working Group. @rustbot label -I-prioritize +P-high |
Usually moving things out of the viewport works. There is info on making screen reader only content here that I believe works: https://webaim.org/techniques/css/invisiblecontent/ That said, if we go that route you then need a way to skip it. My preference would be for us to overall fix the header hierarchy because most screen readers including myself use those by reflex and nothing else in HTML land to my knowledge offers the same thing, but that would require rewriting user markdown I think, so as alternatives we could look at aria landmarks. Putting these before every function just means that screen readers hear every function twice because the screen reader will read the landmark and the heading, so care should be taken not to do that. It solves only the problem of e.g. "contents", "impl block", "trait impls" sorts of navigation. Also, it will be easy to walk another step down the rabbit hole and end up at aria regions, which are incredibly verbose and not something I would personally like to see here (though others may disagree). |
…le, r=notriddle Fix sidebar display on small devices Part of rust-lang#87059. Instead of hiding the sidebar on small devices, we instead move it out of the viewport so that it remains "visible" to our text only users. Could you confirm it works for you `@ahicks92` and `@DataTriny` please? You can give it a try at [this URL](https://guillaume-gomez.fr/rustdoc-test/test_docs/index.html). r? `@notriddle`
This way, we can show the plus and minus buttons on screens, while voice control will read off actual words "Collapse" and "Expand" instead of reading "open brace minus close brace" and "open brace plus close brace". Part of rust-lang#87059
that definitely does what we want with NVDA. The example on that page also appears to work with Voiceover on Big Sur. I don't have access to jaws to see what it does here. Practically speaking narrator isn't relevant: I have yet to hear of anyone using it as a primary screen reader. I doubt anyone reads docs on the phones for the same reasons no one programs on their phone so we probably needn't worry about those so much in this case. Good find. I'll have to remember that those tests exist for the next time this comes up. |
I do. ^^' |
…-headers, r=GuillaumeGomez Rustdoc accessibility: make the sidebar headers actual headers Part of rust-lang#87059 Preview it at: https://notriddle.com/notriddle-rustdoc-test/rustdoc-sidebar-header/std/index.html
Adding to the "the table of contents doesn't do what we want" discussion, observe this page from nalgebra: https://docs.rs/nalgebra/0.28.0/nalgebra/geometry/struct.Isometry.html Which manages to have duplicates for all the methods due to the duplicate impl blocks, but not sorted by or indicating the impl block they go with unless you go find that another way. This seems like a bug/improvement/something-unrelated-to-this-discussion, but nonetheless gives another reason why I'm not so fond of saying "the answer is the table of contents". The heading-based solution is to jump up by heading which loses you your place, but at least offers efficiency in one direction if that makes sense. |
Part of rust-lang#87059 Partially reverts rust-lang#84703 Preview at: https://notriddle.com/notriddle-rustdoc-test/real-headers/std/index.html
…atch, r=GuillaumeGomez Rustdoc accessibility: use real headers for doc items Part of rust-lang#87059 Partially reverts rust-lang#84703 Preview at: https://notriddle.com/notriddle-rustdoc-test/real-headers/std/index.html
Part of rust-lang#87059 Partially reverts rust-lang#84703 Heavily modified for beta backport needs.
Part of rust-lang#87059 Partially reverts rust-lang#84703 Backport of rust-lang#87390 Preview at: https://notriddle.com/notriddle-rustdoc-test/real-headers/std/index.html
Hello @ahicks92! Rust 1.54.0 is going to be released this Thursday, and I think I backported all the PRs referenced in this issue to the upcoming stable. Could you check whether the pre-release documentation still presents regressions compared to 1.53.0? |
Yeah, that looks good. Specifically I hit Vec. Thanks for prioritizing this. |
Sorry for the double comment. If there's further specific tests you want I'm happy to do them. |
@ahicks92 that's great! Are there any further fixes you'd like, or can the issue be closed? |
Part of rust-lang#87059 Partially reverts rust-lang#84703 Preview at: https://notriddle.com/notriddle-rustdoc-test/real-headers/std/index.html
We can close this out and I'll open more issues if I find other things. In terms of the urgent my entire workflow broke things, we're done. Thanks. |
Thanks for the feedback! |
This way, we can show the plus and minus buttons on screens, while voice control will read off actual words "Collapse" and "Expand" instead of reading "open brace minus close brace" and "open brace plus close brace". Part of rust-lang#87059
…brace, r=notriddle Rustdoc accessibility: use an icon for the [-]/[+] controls This is a reopening of rust-lang#87207 with improvement for the way of generating the `background-image` CSS property. I quote from the original PR: > This way, we can show the plus and minus buttons on screens, while voice > control will read off actual words "Collapse" and "Expand" instead of reading > "open brace minus close brace" and "open brace plus close brace". Part of rust-lang#87059 r? `@notriddle`
…brace, r=notriddle Rustdoc accessibility: use an icon for the [-]/[+] controls This is a reopening of rust-lang#87207 with improvement for the way of generating the `background-image` CSS property. I quote from the original PR: > This way, we can show the plus and minus buttons on screens, while voice > control will read off actual words "Collapse" and "Expand" instead of reading > "open brace minus close brace" and "open brace plus close brace". Part of rust-lang#87059 r? ``@notriddle``
I opened this as one issue because the overarching problem is the problem, if you will. if I should have made a bunch, let me know.
Looks like the following applies to beta. Example page: https://doc.rust-lang.org/beta/std/collections/struct.BTreeMap.html
I'm a screen reader user (e.g. blind). Specifically NVDA. Whatever changes are coming down the pipeline with Rustdoc make the above-linked page difficult to navigate. It used to be the case that you could get used to the weird heading structure (specifically that Rustdoc headings are higher levels than example/error headings) then be mostly fine. But now:
[-]
, which screen readers are forced to listen to as "left bracket dash right bracket", e.g. "left bracket dash right bracket pub fn".I manage because I'm a screen reader power user who has previous familiarity with these pages, which meant that mostly getting around/through this was working out what actually changed rather than how to do it from scratch. It still hit my efficiency quite a bit. Most screen reader users aren't going to know to maximize their browser and ctrl+f "methods" and so on, or work out that actually sometimes you need next heading and sometimes you need next button.
Some concrete fixes:
h
tags back (maybe we can do this with aria, if the buttons are important).[-]
to the end of the line, where it used to be. I think this can be faked with css if we need the visual representation to stay the same, but I'm a backend guy.I'm happy to discuss other fixes as well; my goal is to provide some sort of conversation starter.
The text was updated successfully, but these errors were encountered: