Skip to content

Commit 08f2b78

Browse files
gabalafoudrammocktrallardpre-commit-ci[bot]
authored
DOCS - Update accessibility docs (#2039)
This pull request brings the accessibility docs up to date. Some of the changes in this pull request involve hard-wrapping the text in the docs files. I feel like this itself is an accessibility improvement as long lines are harder to read. It's also makes text diffing in git better. --------- Co-authored-by: Daniel McCloy <[email protected]> Co-authored-by: Tania Allard <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 1b3e65e commit 08f2b78

File tree

4 files changed

+134
-78
lines changed

4 files changed

+134
-78
lines changed
Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,63 @@
1-
# Accessibility checks
1+
# Accessibility checks and manual auditing
22

3-
```{note}
4-
April-2023: we are currently
5-
[re-evaluating how we do accessibility checks](https://github.com/pydata/pydata-sphinx-theme/issues/1168)
6-
and reporting, so this may change soon.
3+
As part of our commitment to making this theme accessible, we run automated
4+
checks against all of the pages under [](../../examples/kitchen-sink/index.rst).
5+
6+
The accessibility check is run every time that a pull request is created on
7+
GitHub. We forbid merging a pull request into the codebase if it breaks this
8+
check.
9+
10+
## Running the checks locally
11+
12+
If you are [developing the theme locally](../setup.md), the simplest way to run
13+
the accessibility checks on your computer is:
14+
15+
```sh
16+
tox run -m a11y
717
```
818

9-
In general, accessibility-checking tools can find a limited number of common HTML patterns that assistive technology
10-
can't help users understand.
19+
## Technical details
20+
21+
The main two technologies we use to write and run accessibility checks are
22+
[Playwright for Python](https://playwright.dev/python/) and
23+
[axe-core](https://github.com/dequelabs/axe-core).
24+
25+
Playwright is the successor to a similar library called Puppeteer. It provides a
26+
way to programmatically script a web browser to open, operate, inspect, and test
27+
web pages. Axe-core is a suite of accessibility checks written as a JavaScript
28+
program. The program is meant to be injected into a web page. Once injected, it
29+
examines the page for common accessibility failures, such as low contrast text.
30+
Our accessibility test suite uses Playwright to inject Axe-core into each of the
31+
Kitchen Sink pages plus a few other key pages in this documentation. We also
32+
wrote a few other Playwright scripts to ensure that certain theme components can
33+
be accessed using only the keyboard. All of our tests currently live in a file
34+
called
35+
[test_a11y.py](https://github.com/pydata/pydata-sphinx-theme/blob/main/tests/test_a11y.py).
36+
:::{note}
37+
We would love contributions that add more accessibility checks to our test
38+
suite.
39+
:::
40+
41+
We have also made these tests part of our continuous integration process, so
42+
they are run in the cloud before we merge in new changes to the theme. We
43+
use the following tools:
44+
45+
- GitHub Actions to provision machines in the cloud
46+
- `tox` to install the needed dependencies on those machines
47+
- `Pytest` with the Playwright plug-in to run the tests.
1148

12-
## Accessibility checks as part of our development process
49+
Look for the string "accessibility" in the file
50+
[CI.yml](https://github.com/pydata/pydata-sphinx-theme/blob/main/.github/workflows/CI.yml)
51+
to find how we have configured GitHub Actions.
1352

14-
We run a [Lighthouse](https://developers.google.com/web/tools/lighthouse) job in our CI/CD, which generates a "score" for all pages in our **Kitchen Sink** example documentation.
15-
The configuration for Lighthouse can be found in the `.github/workflows/lighthouserc.json` file.
53+
## Known limitations and manual auditing
1654

17-
For more information about configuring Lighthouse, see [the Lighthouse documentation](https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/configuration.md).
18-
For more information about Accessibility in general, see [](../../user_guide/accessibility.md).
55+
We are well aware that automated checks fall far short of comprehensive
56+
accessibility auditing and testing, so we also conducted an accessibility audit
57+
of three pages from the theme docs. We collected those findings in an issue on
58+
GitHub, [May 2024 PyData Theme audit
59+
findings](https://github.com/Quansight-Labs/czi-scientific-python-mgmt/issues/72)
1960

20-
We have also recently added automated tests using [Playwright](https://playwright.dev/python/) and [axe-core](https://github.com/dequelabs/axe-core) to improve our accessibility testing and reporting.
61+
Nearly all of the issues have been fixed, but of course things do break / have
62+
already broken, and some things may have never been discovered, so please
63+
[create a GitHub issue](https://github.com/pydata/pydata-sphinx-theme/issues/new) if you find something inaccessible.

docs/user_guide/accessibility.md

Lines changed: 65 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Accessibility
22

3-
Creating and publishing content that does not exclude disabled users is a complex and iterative task.
3+
Creating and publishing content that does not exclude disabled users is a
4+
complex and iterative task.
45

56
While there is no one-size-fits-all solution to maintaining accessible content,
6-
the PyData Sphinx Theme and this documentation site use some techniques to avoid common content shortcomings.
7+
the PyData Sphinx Theme and this documentation site use some techniques to avoid
8+
common content shortcomings.
79

810
:::{note}
9-
Issues and pull requests to identify or fix accessibility issues on this theme or site are heartily welcomed!
11+
Issues and pull requests to identify or fix accessibility issues on this theme
12+
or site are heartily welcomed!
1013
:::
1114

1215
## What We've Done
@@ -26,12 +29,15 @@ page that lacks metadata, please open a pull request to add it!
2629
to choose from at https://github.com/Quansight-Labs/accessible-pygments.
2730
- We recently revisited the PyData Sphinx theme color palette to ensure that
2831
the colors we use meet WCAG 2 AA or AAA contrast requirements.
29-
- We also re-defined our `primary` and `secondary` colors to be more accessible and distinct from semantic colors used
30-
to denote success, warning, info, and danger contexts or information.
31-
- We simplified the color palette and removed some colors that were problematic in meeting WCAG 2 AA or AAA contrast requirements
32-
and for certain types of colorblindness.
33-
- We have improved how we assign text colors to interactive elements such as buttons and dropdowns to ensure that they meet
34-
WCAG 2 AA or AAA contrast requirements.
32+
- We also re-defined our `primary` and `secondary` colors to be more accessible
33+
and distinct from semantic colors used to denote success, warning, info, and
34+
danger contexts or information.
35+
- We simplified the color palette and removed some colors that were problematic
36+
in meeting WCAG 2 AA or AAA contrast requirements and for certain types of
37+
colorblindness.
38+
- We have improved how we assign text colors to interactive elements such as
39+
buttons and dropdowns to ensure that they meet WCAG 2 AA or AAA contrast
40+
requirements.
3541

3642
### Keyboard Navigation Support
3743

@@ -41,6 +47,11 @@ links and other interactive elements, we have worked to ensure they:
4147
- Have a visible focus indicator (WCAG 2.4.7)
4248
- Can be accessed via keyboard navigation (WCAG 2.1.1)
4349

50+
### Testing and auditing
51+
52+
We have also added automated tests and conducted manual audits. See
53+
[](../community/topics/accessibility.md).
54+
4455
## What You Can Do
4556

4657
### Site configuration
@@ -55,10 +66,12 @@ specifying at least the baseline natural language will help assistive technology
5566
identify if the content is in a language the reader understands.
5667

5768
:::{hint}
58-
In your `conf.py` file, [specifying the language your docs are written in](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language) will propagate to the top-level `HTML` tag.
69+
In your `conf.py` file,
70+
[specifying the language your docs are written in](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language)
71+
will propagate to the top-level `HTML` tag.
5972

6073
```python
61-
language = "en"
74+
language = "en"
6275
```
6376

6477
:::
@@ -80,71 +93,67 @@ For a simple site (no extra languages or versions), ensure `sphinx-sitemap`
8093
is installed in your documentation environment, and modify your `conf.py`:
8194

8295
```python
83-
extensions += ["sphinx_sitemap"]
96+
extensions += ["sphinx_sitemap"]
8497

85-
html_baseurl = os.environ.get("SPHINX_HTML_BASE_URL", "http://127.0.0.1:8000/")
86-
sitemap_locales = [None]
87-
sitemap_url_scheme = "{link}"
98+
html_baseurl = os.environ.get("SPHINX_HTML_BASE_URL", "http://127.0.0.1:8000/")
99+
sitemap_locales = [None]
100+
sitemap_url_scheme = "{link}"
88101
```
89102

90103
:::
91104

92105
### Logo best practices
93106

94-
If you use both light and dark themes, it's best to provide a logo that works well in both or to provide an alternative for the dark theme.
95-
If you have a logo, you can add alt-text to it by adding the following to your
96-
`conf.py`:
107+
We recommend that you support dark mode by providing either a single version of
108+
your logo that works well in both light and dark modes, or two separate
109+
versions. We also recommend that you provide alt text for your logo if you do
110+
not provide visible text.
97111

98-
```python
99-
"logo": {
100-
"text": "PyData Theme",
101-
"image_dark": "_static/logo-dark.svg",
102-
"alt_text": "PyData Theme home",
103-
},
104-
```
112+
These recommendations are covered in detail at the page [](./branding.rst)
105113

106-
Note the use of "home" in the alt text to indicate that the logo is also a link to the home page.
114+
### Test and inspect your site
107115

108-
### In the Browser
116+
Several browser tools exist for interactively debugging the accessibility
117+
of a single page at a time and can be useful during the content development
118+
cycle.
109119

110-
Several in-browser tools exist for interactively debugging the accessibility
111-
of a single page at a time and can be useful during the content development cycle.
120+
Non-interactive tools also exist for use with CI (continuous integration).
112121

113-
### Built-in tools
122+
#### Browser tools
114123

115-
Most major browsers, including [Firefox](https://developer.mozilla.org/en-US/docs/Tools/Accessibility_inspector)
116-
and [Chrome](https://developers.google.com/web/tools/chrome-devtools/accessibility/reference),
117-
have accessibility tools built-in as part of their web developer tools.
118-
These tools can help to quickly identify accessibility issues and often include links to standards.
124+
Most major browsers, including Firefox and Chrome, have built-in accessibility
125+
tools as part of their web developer tools. These tools can help to quickly
126+
identify accessibility issues and often include links to standards:
119127

120-
#### tota11y
128+
- [Firefox Accessibility Inspector](https://developer.mozilla.org/en-US/docs/Tools/Accessibility_inspector)
129+
- [Chrome DevTools Accessibility](https://developer.chrome.com/docs/devtools/accessibility/reference)
121130

122-
[tota11y](https://khan.github.io/tota11y/#Installation) is an open source
123-
"bookmarklet" which modifies the currently-loaded page in place and highlights
124-
several accessibility issues.
131+
There are also a few browser extensions that some of the maintainers of this
132+
theme use when working to make websites more accessible. Some of these include:
125133

126-
#### WAVE
134+
- [Accessibility Insights for Web](https://accessibilityinsights.io/docs/web/overview/)
135+
- [Axe DevTools](https://www.deque.com/axe/browser-extensions/)
136+
- [WAVE](https://wave.webaim.org/extension/)
127137

128-
[WAVE](https://wave.webaim.org/extension/) is a proprietary (but _gratis_)
129-
browser extension which can highlight multiple issues.
138+
We have also found [Polypane](https://polypane.app/) to be a great tool (but it
139+
is not free and requires a license).
130140

131-
:::{warning}
132-
Note that automated testing and extensions such as the ones mentioned above will at best catch 30-40% of accessibility issues.
133-
They are not a replacement for manual testing and having a perfect score on any of these tools does not mean that
134-
the site can be used by disabled users but instead signals that it follows some accessibility best practices.
135-
:::
136-
137-
### In Continuous Integration
141+
#### Continuous Integration tools
138142

139-
Several automated tools are available for assessing _glaring_ accessibility
140-
issues across some pages at once, usually with many configurable options.
143+
Two accessibility testing tools designed for continuous integration are
144+
[Lighthouse CI](https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/getting-started.md)
145+
and [Pa11y CI](https://github.com/pa11y/pa11y-ci).
141146

142-
#### Lighthouse
147+
The [foo-software/lighthouse-check-action](https://github.com/foo-software/lighthouse-check-action)
148+
may be helpful if the code for your site is hosted on GitHub.
143149

144-
[Lighthouse](https://developers.google.com/web/tools/lighthouse) provides an automated assessment of basic accessibility issues in addition to search engine
145-
automation, page performance, and other best practices.
150+
If you are curious about how we do accessibility CI for this theme, refer to the
151+
page [](../community/topics/accessibility.md).
146152

147-
:::{hint}
148-
Specifically, [foo-software/lighthouse-check-action](https://github.com/foo-software/lighthouse-check-action)
149-
is run on selected pages from the generated documentation site.
153+
:::{warning}
154+
Note that automated testing and extensions such as the ones mentioned above will
155+
at best catch 30-40% of accessibility issues. They are not a replacement for
156+
manual testing. Having a perfect score on any of these tools does not mean that
157+
your site can be used by disabled users. Instead, a good score signals that your
158+
site follows some best accessibility practices.
150159
:::

docs/user_guide/web-components.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,18 @@ Here are some of the available button-style links, also using semantic colors:
132132
.. note::
133133

134134
`Sphinx Design buttons
135-
<https://sphinx-design.readthedocs.io/en/latest/badges_buttons.html>`__
136-
are actually links, meaning they are rendered in HTML with ``<a>`` tags
137-
instead of ``<button>``. Use them if you need a link to look like a button,
138-
however, be aware that they do not follow accessibility best practices for
139-
native button components such as using the correct `ARIA attributes
140-
<https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role>`__.
141-
142-
If in your site's :ref:`custom CSS file <custom-css>` you override the :ref:`CSS custom properties <css-variables>` ``--pst-color-*`` (where ``*`` is one of the semantic color names, such as ``primary``, ``danger``), badges and buttons will automatically use the custom color.
135+
<https://sphinx-design.readthedocs.io/en/latest/badges_buttons.html>`__ are
136+
actually links, meaning they are rendered in HTML with ``<a>`` tags instead
137+
of ``<button>``. Use them if you need a link to look like a button, but try
138+
not to overuse them as they are not considered best practice for
139+
accessibility. (For example, it upsets user interface expectations because
140+
the space bar can be used on ``<button>``-tag buttons but not on ``<a>``-tag
141+
links that look like buttons.)
142+
143+
If in your site's :ref:`custom CSS file <custom-css>` you override the :ref:`CSS
144+
custom properties <css-variables>` ``--pst-color-*`` (where ``*`` is one of the
145+
semantic color names, such as ``primary``, ``danger``), badges and buttons will
146+
automatically use the custom color.
143147

144148
Cards
145149
=====

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-logo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
{% if is_logo %}
2222
{#
2323
Theme switching is only available when JavaScript is enabled.
24-
We thus adds elements that should be present only when javscipt is
24+
We thus adds elements that should be present only when JavaScript is
2525
enabled with a pst-js-only class
2626
#}
2727
{% if default_mode is undefined or default_mode == "auto" %}

0 commit comments

Comments
 (0)