Skip to content

Commit 04d26d2

Browse files
committed
Update accessibility docs
1 parent 1b3e65e commit 04d26d2

File tree

4 files changed

+130
-76
lines changed

4 files changed

+130
-76
lines changed
Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,58 @@
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+
We would love contributions that add more accessibility checks to our test
37+
suite.
1138

12-
## Accessibility checks as part of our development process
39+
We have also made these tests part of our continuous integration process, so
40+
that they are run in the cloud before we merge in new changes to the theme. We
41+
use GitHub Actions to provision machines in the cloud. We use Tox to install the
42+
needed dependencies on those machines. We use Pytest with the plug-in for
43+
Playwright to run the tests. Look for the string "accessibility" in the file
44+
[CI.yml](https://github.com/pydata/pydata-sphinx-theme/blob/main/.github/workflows/CI.yml)
45+
to find how we have configured GitHub Actions.
1346

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.
47+
## Known limitations and manual auditing
1648

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).
49+
We are well aware that automated checks fall far short of comprehensive
50+
accessibility auditing and testing, so we also conducted an accessibility audit
51+
of three pages from the theme docs. We collected those findings in an issue on
52+
GitHub, [May 2024 PyData Theme audit
53+
findings](https://github.com/Quansight-Labs/czi-scientific-python-mgmt/issues/72)
1954

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.
55+
Nearly all of the issues have been fixed, but of course things do break / have
56+
already broken, and some things may have never been discovered, so please
57+
[create an issue](https://github.com/pydata/pydata-sphinx-theme/issues/new) on
58+
GitHub if you find something broken.

docs/user_guide/accessibility.md

Lines changed: 67 additions & 54 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,71 @@ 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+
If you use both light and dark themes, it's best to provide a logo that works
108+
well in both or to provide an alternative for the dark theme. If you have a
109+
logo, you can add alt-text to it by adding the following to your `conf.py`:
97110

98111
```python
99-
"logo": {
100-
"text": "PyData Theme",
101-
"image_dark": "_static/logo-dark.svg",
102-
"alt_text": "PyData Theme home",
103-
},
112+
"logo": {
113+
"image_dark": "_static/logo-dark.svg",
114+
"alt_text": "<Your Project> home",
115+
},
104116
```
105117

106-
Note the use of "home" in the alt text to indicate that the logo is also a link to the home page.
118+
Note the use of "home" in the alt text to indicate that the logo is also a link
119+
to the home page.
107120

108-
### In the Browser
121+
### Test and inspect your site
109122

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.
123+
Several browser tools exist for interactively debugging the accessibility
124+
of a single page at a time and can be useful during the content development
125+
cycle.
112126

113-
### Built-in tools
127+
Non-interactive tools also exist for use with CI (continuous integration).
114128

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.
129+
#### Browser tools
119130

120-
#### tota11y
131+
Most major browsers, including Firefox and Chrome, have built-in accessibility
132+
tools as part of their web developer tools. These tools can help to quickly
133+
identify accessibility issues and often include links to standards:
121134

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.
135+
- [Firefox Accessibility Inspector](https://developer.mozilla.org/en-US/docs/Tools/Accessibility_inspector)
136+
- [Chrome DevTools Accessibility](https://developer.chrome.com/docs/devtools/accessibility/reference)
125137

126-
#### WAVE
138+
There are also a few browser extensions that some of the maintainers of this
139+
theme use when working to make websites more accessible. Some of these include:
127140

128-
[WAVE](https://wave.webaim.org/extension/) is a proprietary (but _gratis_)
129-
browser extension which can highlight multiple issues.
141+
- [Accessibility Insights for Web](https://accessibilityinsights.io/docs/web/overview/)
142+
- [Axe DevTools](https://www.deque.com/axe/browser-extensions/)
143+
- [WAVE](https://wave.webaim.org/extension/)
130144

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-
:::
145+
#### Continuous Integration tools
136146

137-
### In Continuous Integration
147+
Two accessibility testing tools designed for continuous integration are
148+
[Lighthouse CI](https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/getting-started.md)
149+
and [Pa11y CI](https://github.com/pa11y/pa11y-ci).
138150

139-
Several automated tools are available for assessing _glaring_ accessibility
140-
issues across some pages at once, usually with many configurable options.
151+
The [foo-software/lighthouse-check-action](https://github.com/foo-software/lighthouse-check-action)
152+
may be helpful if the code for your site is hosted on GitHub.
141153

142-
#### Lighthouse
154+
If you are curious about how we do accessibility CI for this theme, refer to the
155+
page [](../community/topics/accessibility.md).
143156

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.
146-
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.
157+
:::{warning}
158+
Note that automated testing and extensions such as the ones mentioned above will
159+
at best catch 30-40% of accessibility issues. They are not a replacement for
160+
manual testing. Having a perfect score on any of these tools does not mean that
161+
your site can be used by disabled users. Instead, a good score signals that your
162+
site follows some best accessibility practices.
150163
:::

docs/user_guide/web-components.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,17 @@ 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, the space bar can be used on a ``<button>``s but
140+
not on ``<a>``-tag links.)
141+
142+
If in your site's :ref:`custom CSS file <custom-css>` you override the :ref:`CSS
143+
custom properties <css-variables>` ``--pst-color-*`` (where ``*`` is one of the
144+
semantic color names, such as ``primary``, ``danger``), badges and buttons will
145+
automatically use the custom color.
143146

144147
Cards
145148
=====

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)