Skip to content

Commit

Permalink
feat: generate ARIA supported documentation for roles and attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeyyy committed May 18, 2018
1 parent 5644b95 commit 6f095dd
Show file tree
Hide file tree
Showing 5 changed files with 311 additions and 20 deletions.
110 changes: 90 additions & 20 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-retire');
grunt.loadNpmTasks('grunt-mocha');
grunt.loadTasks('build/tasks');
grunt.loadNpmTasks('grunt-parallel');
grunt.loadNpmTasks('grunt-markdownlint');
grunt.loadTasks('build/tasks');

var langs;
if (grunt.option('lang')) {
Expand Down Expand Up @@ -129,6 +129,14 @@ module.exports = function (grunt) {
dest: 'tmp/commons.js'
}
},
'aria-supported': {
data: {
entry: 'lib/commons/aria/index.js',
tmpDest: 'tmp/aria',
tmpFile: 'tmp/aria/index.js',
destFile: 'doc/aria-supported.md'
}
},
configure: {
rules: {
tmp: 'tmp/rules.js',
Expand All @@ -153,7 +161,7 @@ module.exports = function (grunt) {
dest: './locales/' + (grunt.option('lang') || 'new-locale') + '.json'
}
},
langs : {
langs: {
generate: {
check: 'lib/commons/utils/valid-langs'
}
Expand Down Expand Up @@ -206,9 +214,9 @@ module.exports = function (grunt) {
};
}),
options: {
preserveComments: function(node, comment) {
preserveComments: function (node, comment) {
// preserve comments that start with a bang
return /^!/.test( comment.value );
return /^!/.test(comment.value);
},
mangle: {
reserved: ['commons', 'utils', 'axe', 'window', 'document']
Expand Down Expand Up @@ -330,8 +338,13 @@ module.exports = function (grunt) {
reporterOutput: grunt.option('report') ? 'tmp/lint.xml' : undefined
},
src: [
'lib/**/*.js', 'test/**/*.js', 'build/**/*.js',
'doc/**/*.js', '!doc/examples/jest_react/*.js', 'Gruntfile.js',
'lib/**/*.js',
'test/**/*.js',
'build/**/*.js',
'doc/**/*.js',
'!doc/examples/jest_react/*.js',
'Gruntfile.js',
'!build/tasks/aria-supported.js',
'!**/node_modules/**/*.js'
]
}
Expand All @@ -340,7 +353,7 @@ module.exports = function (grunt) {
all: {
options: {
config: grunt.file.readJSON('.markdownlint.json')
},
},
src: [
'README.md',
'.github/*.md',
Expand All @@ -350,24 +363,81 @@ module.exports = function (grunt) {
}
});

grunt.registerTask('default', ['build']);
grunt.registerTask('default', [
'build'
]);

grunt.registerTask('build', [
'clean',
'eslint',
'validate',
'concat:commons',
'configure',
'babel',
'concat:engine',
'uglify',
'aria-supported'
]);

grunt.registerTask('build', ['clean', 'eslint', 'validate', 'concat:commons', 'configure',
'babel', 'concat:engine', 'uglify']);
grunt.registerTask('test', [
'build',
'retire',
'testconfig',
'fixture',
'connect',
'mocha',
'parallel',
'eslint',
'markdownlint'
]);

grunt.registerTask('test', ['build', 'retire', 'testconfig', 'fixture', 'connect',
'mocha', 'parallel', 'eslint', 'markdownlint']);
grunt.registerTask('ci-build', [
'build',
'retire',
'testconfig',
'fixture',
'connect',
'parallel',
'eslint'
]);

grunt.registerTask('ci-build', ['build', 'retire', 'testconfig', 'fixture', 'connect',
'parallel', 'eslint']);
grunt.registerTask('test-fast', [
'build',
'testconfig',
'fixture',
'connect',
'mocha',
'eslint'
]);

grunt.registerTask('test-fast', ['build', 'testconfig', 'fixture', 'connect',
'mocha', 'eslint']);
grunt.registerTask('translate', [
'clean',
'eslint',
'validate',
'concat:commons',
'add-locale'
]);

grunt.registerTask('translate', ['clean', 'eslint', 'validate', 'concat:commons', 'add-locale']);
grunt.registerTask('dev', [
'build',
'testconfig',
'fixture',
'connect',
'watch'
]);

grunt.registerTask('dev', ['build', 'testconfig', 'fixture', 'connect', 'watch']);
grunt.registerTask('dev:no-lint', [
'clean',
'validate',
'concat:commons',
'configure',
'babel',
'concat:engine',
'uglify',
'testconfig',
'fixture',
'connect',
'watch'
]);

grunt.registerTask('dev:no-lint', ['clean', 'validate', 'concat:commons', 'configure',
'babel', 'concat:engine', 'uglify', 'testconfig', 'fixture', 'connect', 'watch']);
};
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ To create a new translation for aXe, start by running `grunt translate --lang=<l

To update existing translation file, re-run `grunt translate --lang=<langcode>`. This will add new messages used in English and remove messages which were not used in English.

## Supported ARIA Roles and Attributes.

Refer [aXe ARIA support](./doc/aria-supported.md) for a complete list of ARIA supported roles and attrubites by axe.

## Contributing

Read the [Proposing Axe-core Rules guide](./doc/rule-proposal.md)
Expand Down
37 changes: 37 additions & 0 deletions build/tasks/aria-supported.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*eslint-env node */
'use strict';

const aQ = require('aria-query');

module.exports = function (grunt) {
grunt.registerMultiTask(
'aria-supported',
'Task for generating a diff of supported aria-roles.',
function () {
const entry = this.data.entry;
const destFile = this.data.destFile;
const axe = require('../../axe');

const getDiff = (base, subject) => {
return [...[...new Map([...base.entries()].sort())]]
.reduce((out, [key] = item) => {
return `${out} | ${key} | ${subject.includes(key) ? 'Yes' : 'No'} |\n`
}, ``);
}

const getMdContent = (roles, attributes) => {
return `# ARIA Roles supported by axe-core. \n \n \n | aria-role | axe-core support | \n | :------- | :------- | \n ${roles} \n \n \n # ARIA Attributes supported by axe-core. \n \n \n | aria-attribute | axe-core support| \n | :------- | :------- | \n ${attributes}`;
}

const generateDoc = () => {
const content = getMdContent(
getDiff(aQ.roles, Object.keys(axe.commons.aria.lookupTable.role)),
getDiff(aQ.aria, Object.keys(axe.commons.aria.lookupTable.attributes))
);
grunt.file.write(destFile, content)
}

generateDoc();
}
);
};
179 changes: 179 additions & 0 deletions doc/aria-supported.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# ARIA Roles supported by axe-core.


| aria-role | axe-core support |
| :------- | :------- |
| alert | Yes |
| alertdialog | Yes |
| application | Yes |
| article | Yes |
| banner | Yes |
| button | Yes |
| cell | Yes |
| checkbox | Yes |
| columnheader | Yes |
| combobox | Yes |
| command | Yes |
| complementary | Yes |
| composite | Yes |
| contentinfo | Yes |
| definition | Yes |
| dialog | Yes |
| directory | Yes |
| doc-abstract | Yes |
| doc-acknowledgments | Yes |
| doc-afterword | Yes |
| doc-appendix | Yes |
| doc-backlink | Yes |
| doc-biblioentry | Yes |
| doc-bibliography | Yes |
| doc-biblioref | Yes |
| doc-chapter | Yes |
| doc-colophon | Yes |
| doc-conclusion | Yes |
| doc-cover | Yes |
| doc-credit | Yes |
| doc-credits | Yes |
| doc-dedication | Yes |
| doc-endnote | Yes |
| doc-endnotes | Yes |
| doc-epigraph | Yes |
| doc-epilogue | Yes |
| doc-errata | Yes |
| doc-example | Yes |
| doc-footnote | Yes |
| doc-foreword | Yes |
| doc-glossary | Yes |
| doc-glossref | Yes |
| doc-index | Yes |
| doc-introduction | Yes |
| doc-noteref | Yes |
| doc-notice | Yes |
| doc-pagebreak | Yes |
| doc-pagelist | Yes |
| doc-part | Yes |
| doc-preface | Yes |
| doc-prologue | Yes |
| doc-pullquote | Yes |
| doc-qna | Yes |
| doc-subtitle | Yes |
| doc-tip | Yes |
| doc-toc | Yes |
| document | Yes |
| feed | Yes |
| figure | No |
| form | Yes |
| grid | Yes |
| gridcell | Yes |
| group | Yes |
| heading | Yes |
| img | Yes |
| input | Yes |
| landmark | Yes |
| link | Yes |
| list | Yes |
| listbox | Yes |
| listitem | Yes |
| log | Yes |
| main | Yes |
| marquee | Yes |
| math | Yes |
| menu | Yes |
| menubar | Yes |
| menuitem | Yes |
| menuitemcheckbox | Yes |
| menuitemradio | Yes |
| navigation | Yes |
| none | Yes |
| note | Yes |
| option | Yes |
| presentation | Yes |
| progressbar | Yes |
| radio | Yes |
| radiogroup | Yes |
| range | Yes |
| region | Yes |
| roletype | Yes |
| row | Yes |
| rowgroup | Yes |
| rowheader | Yes |
| scrollbar | Yes |
| search | Yes |
| searchbox | Yes |
| section | Yes |
| sectionhead | Yes |
| select | Yes |
| separator | Yes |
| slider | Yes |
| spinbutton | Yes |
| status | Yes |
| structure | Yes |
| switch | Yes |
| tab | Yes |
| table | Yes |
| tablist | Yes |
| tabpanel | Yes |
| term | Yes |
| textbox | Yes |
| timer | Yes |
| toolbar | Yes |
| tooltip | Yes |
| tree | Yes |
| treegrid | Yes |
| treeitem | Yes |
| widget | Yes |
| window | Yes |



# ARIA Attributes supported by axe-core.


| aria-attribute | axe-core support|
| :------- | :------- |
| aria-activedescendant | Yes |
| aria-atomic | Yes |
| aria-autocomplete | Yes |
| aria-busy | Yes |
| aria-checked | Yes |
| aria-colcount | Yes |
| aria-colindex | Yes |
| aria-colspan | Yes |
| aria-controls | Yes |
| aria-current | Yes |
| aria-describedby | Yes |
| aria-disabled | Yes |
| aria-dropeffect | Yes |
| aria-expanded | Yes |
| aria-flowto | Yes |
| aria-grabbed | Yes |
| aria-haspopup | Yes |
| aria-hidden | Yes |
| aria-invalid | Yes |
| aria-keyshortcuts | Yes |
| aria-label | Yes |
| aria-labelledby | Yes |
| aria-level | Yes |
| aria-live | Yes |
| aria-modal | Yes |
| aria-multiline | Yes |
| aria-multiselectable | Yes |
| aria-orientation | Yes |
| aria-owns | Yes |
| aria-placeholder | Yes |
| aria-posinset | Yes |
| aria-pressed | Yes |
| aria-readonly | Yes |
| aria-relevant | Yes |
| aria-required | Yes |
| aria-roledescription | No |
| aria-rowcount | Yes |
| aria-rowindex | Yes |
| aria-rowspan | Yes |
| aria-selected | Yes |
| aria-setsize | Yes |
| aria-sort | Yes |
| aria-valuemax | Yes |
| aria-valuemin | Yes |
| aria-valuenow | Yes |
| aria-valuetext | Yes |
Loading

0 comments on commit 6f095dd

Please sign in to comment.