Skip to content

Commit

Permalink
Merge pull request #156 from akcano/main
Browse files Browse the repository at this point in the history
add a target for running pa11y
  • Loading branch information
akcano authored Dec 15, 2023
2 parents b685bda + 1bfff06 commit d08ed8d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
.sphinx/warnings.txt
.sphinx/.wordlist.dic
.sphinx/.doctrees/
.sphinx/node_modules/
package*.json
_build
.DS_Store
__pycache__
Expand Down
15 changes: 15 additions & 0 deletions .sphinx/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,18 @@ details summary {
.highlight button.copybtn {
opacity: 0;
}

/* Mimicking the 'Give feedback' button for UX consistency */
.sidebar-search-container input[type=submit] {
color: #FFFFFF;
border: 2px solid #D6410D;
padding: var(--sidebar-search-input-spacing-vertical) var(--sidebar-search-input-spacing-horizontal);
background: #D6410D;
font-weight: bold;
font-size: var(--font-size--small);
cursor: pointer;
}

.sidebar-search-container input[type=submit]:hover {
text-decoration: underline;
}
2 changes: 1 addition & 1 deletion .sphinx/_static/github_issue_links.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.github-issue-link {
font-size: var(--font-size--small);
font-weight: bold;
background-color: #DD4814;
background-color: #D6410D;
padding: 13px 23px;
text-decoration: none;
}
Expand Down
7 changes: 7 additions & 0 deletions .sphinx/_templates/sidebar/search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<form class="sidebar-search-container" method="get" action="{{ pathto('search') }}" role="search">
<input class="sidebar-search" placeholder="{{ _("Search") }}" name="q" aria-label="{{ _("Search" ) }}">
<input type="submit" value="Go">
<input type="hidden" name="check_keywords" value="yes">
<input type="hidden" name="area" value="default">
</form>
<div id="searchbox"></div>
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ SPHINXDIR = .sphinx
SOURCEDIR = .
BUILDDIR = _build
VENVDIR = $(SPHINXDIR)/venv
PA11Y = $(SPHINXDIR)/node_modules/pa11y/bin/pa11y.js
VENV = $(VENVDIR)/bin/activate

.PHONY: help woke-install install run html epub serve clean clean-doc \
spelling linkcheck woke Makefile
.PHONY: help woke-install pa11y-install install run html epub serve clean \
clean-doc spelling linkcheck woke pa11y Makefile

# Put it first so that "make" without argument is like "make help".
help: $(VENVDIR)
Expand Down Expand Up @@ -42,6 +43,7 @@ $(VENVDIR): $(SPHINXDIR)/requirements.txt
"* check links: make linkcheck \n" \
"* check spelling: make spelling \n" \
"* check inclusive language: make woke \n" \
"* check accessibility: make pa11y \n" \
"* other possible targets: make <press TAB twice> \n" \
"--------------------------------------------------------------- \n"
@touch $(VENVDIR)
Expand All @@ -50,6 +52,13 @@ woke-install:
@type woke >/dev/null 2>&1 || \
{ echo "Installing \"woke\" snap... \n"; sudo snap install woke; }

pa11y-install:
@type $(PA11Y) >/dev/null 2>&1 || { \
echo "Installing \"pa11y\" from npm... \n"; \
mkdir -p $(SPHINXDIR)/node_modules/ ; \
npm install --prefix $(SPHINXDIR) pa11y; \
}

install: $(VENVDIR) woke-install

run: install
Expand Down Expand Up @@ -83,6 +92,9 @@ woke: woke-install
woke *.rst **/*.rst --exit-1-on-failure \
-c https://github.com/canonical/Inclusive-naming/raw/main/config.yml

pa11y: pa11y-install html
find $(BUILDDIR) -name *.html -exec $(PA11Y) {} \;

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
Expand Down
9 changes: 9 additions & 0 deletions pa11y.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"chromeLaunchConfig": {
"args": [
"--no-sandbox"
]
},
"reporter": "cli",
"standard": "WCAG2AA"
}

0 comments on commit d08ed8d

Please sign in to comment.