Created
April 5, 2022 08:23
-
-
Save jhancock532/96ef67901731af496ff87df92d1c214e to your computer and use it in GitHub Desktop.
Generates a pa11y.config.js file for a Django pattern library site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import re | |
base_url = "http://localhost:8000/pattern-library/render-pattern/patterns" | |
pattern_libray_pages = glob.glob('**/patterns/pages/**/*.html', recursive=True) | |
config = """module.exports = { | |
defaults: { | |
standard: "WCAG2AAA", | |
runners: ["axe"], | |
}, | |
urls: [ | |
""" | |
for html_file in pattern_libray_pages: | |
url = base_url + re.sub(r'^.*?patterns', '', html_file) | |
config += ' "' | |
config += url | |
config += '",\n' | |
config += """ ] | |
}; | |
""" | |
f = open("pa11y.config.js", "w") | |
f.write(config) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment