| 1 |
# Accessibility |
| 2 |
|
| 3 |
Creating and publishing content that does not exclude disabled users is a |
| 4 |
complex and iterative task. |
| 5 |
|
| 6 |
While there is no one-size-fits-all solution to maintaining accessible content, |
| 7 |
the PyData Sphinx Theme and this documentation site use some techniques to avoid |
| 8 |
common content shortcomings. |
| 9 |
|
| 10 |
:::{note} |
| 11 |
Issues and pull requests to identify or fix accessibility issues on this theme |
| 12 |
or site are heartily welcomed! |
| 13 |
::: |
| 14 |
|
| 15 |
## What We've Done |
| 16 |
|
| 17 |
### Metadata |
| 18 |
|
| 19 |
Several of our documentation pages contain metadata (i.e., `.. meta::` directives |
| 20 |
in reStructuredText) giving summaries of the page contents. If you notice a |
| 21 |
page that lacks metadata, please open a pull request to add it! |
| 22 |
|
| 23 |
### Colors |
| 24 |
|
| 25 |
- Our default code highlighting styles are `a11y-high-contrast-light` and |
| 26 |
`a11y-high-contrast-dark` from https://github.com/Quansight-Labs/accessible-pygments. |
| 27 |
These styles are designed to meet WCAG 2 AA or AAA contrast requirements. |
| 28 |
If you don't like the look of our default code highlighting styles, there are several more |
| 29 |
to choose from at https://github.com/Quansight-Labs/accessible-pygments. |
| 30 |
- We recently revisited the PyData Sphinx theme color palette to ensure that |
| 31 |
the colors we use meet 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. |
| 41 |
|
| 42 |
To learn more about the PyData Sphinx Theme colors, check the [](../community/design-system.md) |
| 43 |
section. |
| 44 |
|
| 45 |
### Keyboard Navigation Support |
| 46 |
|
| 47 |
For all buttons, dropdowns, tabbed panels, hamburger menus, modals, overlays, |
| 48 |
links and other interactive elements, we have worked to ensure they: |
| 49 |
|
| 50 |
- Have a visible focus indicator (WCAG 2.4.7) |
| 51 |
- Can be accessed via keyboard navigation (WCAG 2.1.1) |
| 52 |
|
| 53 |
### Testing and auditing |
| 54 |
|
| 55 |
We have also added automated tests and conducted manual audits. See |
| 56 |
[](../community/topics/accessibility.md). |
| 57 |
|
| 58 |
## What You Can Do |
| 59 |
|
| 60 |
### Site configuration |
| 61 |
|
| 62 |
The following sections include recommendations for settings in the `conf.py` file that can positively impact the |
| 63 |
accessibility of content generated by this theme and Sphinx in general. |
| 64 |
|
| 65 |
### Natural Language |
| 66 |
|
| 67 |
If not using a more robust [internationalization approach](https://www.sphinx-doc.org/en/master/usage/advanced/intl.html), |
| 68 |
specifying at least the baseline natural language will help assistive technology |
| 69 |
identify if the content is in a language the reader understands. |
| 70 |
|
| 71 |
:::{hint} |
| 72 |
In your `conf.py` file, |
| 73 |
[specifying the language your docs are written in](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language) |
| 74 |
will propagate to the top-level `HTML` tag. |
| 75 |
|
| 76 |
```python |
| 77 |
language = "en" |
| 78 |
``` |
| 79 |
|
| 80 |
::: |
| 81 |
|
| 82 |
### Add a Site Map |
| 83 |
|
| 84 |
Site maps, usually served from a file called `sitemap.xml` are a broadly-employed |
| 85 |
approach to telling programs like search engines and assistive technologies where |
| 86 |
different content appears on a website. |
| 87 |
|
| 88 |
If using a service like [ReadTheDocs](https://about.readthedocs.com/), these files |
| 89 |
will be created for you _automatically_, but for some other approaches below, |
| 90 |
it's handy to generate a `sitemap.xml` locally or in CI with a tool like |
| 91 |
[sphinx-sitemap](https://pypi.org/project/sphinx-sitemap/). |
| 92 |
|
| 93 |
:::{hint} |
| 94 |
|
| 95 |
For a simple site (no extra languages or versions), ensure `sphinx-sitemap` |
| 96 |
is installed in your documentation environment, and modify your `conf.py`: |
| 97 |
|
| 98 |
```python |
| 99 |
extensions += ["sphinx_sitemap"] |
| 100 |
|
| 101 |
html_baseurl = os.environ.get("SPHINX_HTML_BASE_URL", "http://127.0.0.1:8000/") |
| 102 |
sitemap_locales = [None] |
| 103 |
sitemap_url_scheme = "{link}" |
| 104 |
``` |
| 105 |
|
| 106 |
::: |
| 107 |
|
| 108 |
### Logo best practices |
| 109 |
|
| 110 |
We recommend that you support dark mode by providing either a single version of |
| 111 |
your logo that works well in both light and dark modes, or two separate |
| 112 |
versions. We also recommend that you supply alt text for your logo in any place |
| 113 |
that the image appears by itself without a visible text version of the logo. |
| 114 |
For example, if you have the Python snake logo all by itself, you should supply |
| 115 |
the alt text "Python," whereas if you have the snake image followed by |
| 116 |
the word "Python" in visible, regular, copy-paste-able text, then you do not |
| 117 |
need to provide alt text. |
| 118 |
|
| 119 |
These recommendations are covered in detail at the page [](./branding.rst) |
| 120 |
|
| 121 |
### Test and inspect your site |
| 122 |
|
| 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. |
| 126 |
|
| 127 |
Non-interactive tools also exist for use with CI (continuous integration). |
| 128 |
|
| 129 |
#### Browser tools |
| 130 |
|
| 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: |
| 134 |
|
| 135 |
- [Firefox Accessibility Inspector](https://firefox-source-docs.mozilla.org/devtools-user/accessibility_inspector/index.html) |
| 136 |
- [Chrome DevTools Accessibility](https://developer.chrome.com/docs/devtools/accessibility/reference) |
| 137 |
|
| 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: |
| 140 |
|
| 141 |
- [Accessibility Insights for Web](https://accessibilityinsights.io/docs/web/overview/) |
| 142 |
- [Axe DevTools](https://www.deque.com/axe/devtools/extension/) |
| 143 |
- [WAVE](https://wave.webaim.org/extension/) |
| 144 |
|
| 145 |
We have also found [Polypane](https://polypane.app/) to be a great tool (but it |
| 146 |
is not free and requires a license). |
| 147 |
|
| 148 |
#### Continuous Integration tools |
| 149 |
|
| 150 |
Two accessibility testing tools designed for continuous integration are |
| 151 |
[Lighthouse CI](https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/getting-started.md) |
| 152 |
and [Pa11y CI](https://github.com/pa11y/pa11y-ci). |
| 153 |
|
| 154 |
The [foo-software/lighthouse-check-action](https://github.com/foo-software/lighthouse-check-action) |
| 155 |
may be helpful if the code for your site is hosted on GitHub. |
| 156 |
|
| 157 |
If you are curious about how we do accessibility CI for this theme, refer to the |
| 158 |
page [](../community/topics/accessibility.md). |
| 159 |
|
| 160 |
:::{warning} |
| 161 |
Note that automated testing and extensions such as the ones mentioned above will |
| 162 |
at best catch 30-40% of accessibility issues. They are not a replacement for |
| 163 |
manual testing. Having a perfect score on any of these tools does not mean that |
| 164 |
your site can be used by disabled users. Instead, a good score signals that your |
| 165 |
site follows some best accessibility practices. |
| 166 |
::: |