doc: add main ARIA landmark to API docs

As an accessibility improvement, specify the main landmark for
the column in our docs that contains the main content.

Ref: https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/
Ref: https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA20.html
PR-URL: https://github.com/nodejs/node/pull/49882
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Claudio Wunder <cwunder@gnome.org>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
This commit is contained in:
Rich Trott
2023-09-26 10:35:09 -07:00
parent f416a0f555
commit bc056c2426
2 changed files with 3 additions and 3 deletions

View File

@@ -70,7 +70,7 @@
__TOC__ __TOC__
<div id="apicontent"> <div role="main" id="apicontent">
__CONTENT__ __CONTENT__
<!-- API END --> <!-- API END -->
</div> </div>

View File

@@ -27,7 +27,7 @@ for (const link of toc.match(/<a.*?>/g)) {
const data = fs.readFileSync(new URL(`./${href}`, source), 'utf8'); const data = fs.readFileSync(new URL(`./${href}`, source), 'utf8');
// Split the doc. // Split the doc.
const match = /(<\/ul>\s*)?<\/\w+>\s*<\w+ id="apicontent">/.exec(data); const match = /(<\/ul>\s*)?<\/\w+>\s*<\w+ role="main" id="apicontent">/.exec(data);
// Get module name // Get module name
const moduleName = href.replace(/\.html$/, ''); const moduleName = href.replace(/\.html$/, '');
@@ -89,7 +89,7 @@ all = all.slice(0, tocStart.index + tocStart[0].length) +
all.slice(tocStart.index + tocStart[0].length); all.slice(tocStart.index + tocStart[0].length);
// Replace apicontent with the concatenated set of apicontents from each source. // Replace apicontent with the concatenated set of apicontents from each source.
const apiStart = /<\w+ id="apicontent">\s*/.exec(all); const apiStart = /<\w+ role="main" id="apicontent">\s*/.exec(all);
const apiEnd = all.lastIndexOf('<!-- API END -->'); const apiEnd = all.lastIndexOf('<!-- API END -->');
all = all.slice(0, apiStart.index + apiStart[0].length) all = all.slice(0, apiStart.index + apiStart[0].length)
.replace( .replace(