Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue752 add index utility #951

Merged
merged 26 commits into from
Dec 21, 2018
Merged

Issue752 add index utility #951

merged 26 commits into from
Dec 21, 2018

Conversation

jongund
Copy link
Contributor

@jongund jongund commented Dec 6, 2018

This PR addresses issue #752.

The reference-tables.js is a node utility in the scripts directory that generates an index.html file in the examples directory. The index.html file is very simple with two tables and some navigation links to the practices document.

The appendices section of the aria-practices.html includes a new subsection for index with links to the indexes in examples/index.html.

View the new indexes section in this feature branch.


Preview | Diff

@jongund
Copy link
Contributor Author

jongund commented Dec 6, 2018

It seems to pass all the js linter tests, but required me to user older style Javascript, so while the coding change recommendations worked to generate the index.html file, they would not pass the js linter we are currently using, so I had to modify them to conform to the linter.

@mcking65 mcking65 mentioned this pull request Dec 7, 2018
@mcking65 mcking65 requested a review from jkva December 7, 2018 03:36
@mcking65 mcking65 self-assigned this Dec 7, 2018
@mcking65
Copy link
Contributor

mcking65 commented Dec 7, 2018

@nschonni, could you please review this? I tried requesting a review, but you do not show in the list. It looks like you are not a member of the aria contributors team in github.

Copy link
Contributor

@nschonni nschonni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly minor style stuff. For the node scripts using let and const would probably be a good idea

var examplesDirectory = '../examples/';

var ariaRoles = [
'banner',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, but I'd suggest sorting the array so it's easier to see if anything is missing or when adding another one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see duplication. Could we generate the list from the ARIA spec? We could use ARIA query for this.

@@ -0,0 +1,409 @@
var fs = require('fs');
var i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you mostly use local copies for loops. Maybe drop this and use let

indexStart = content.indexOf('>', indexStart) + 1;
indexEnd = indexStart + 1;

console.log('Replacing at: ' + indexStart + ' .... ' + indexEnd);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aside, since this is for node, you can probably safely use template literals https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

console.log(`Replacing at: ${indexStart} .... ${indexEnd}`);

}
}

var count = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this should be inside the findHTMLFiles function


function findHTMLFiles (path) {
fs.readdirSync(path).forEach(function (file) {
var newPath = path + '/' + file;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably safer for multiplatform to use the node path module and use path.join(filePath, file)


var count = 0;

function findHTMLFiles (path) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to use the glob pack to just filter the files you want


// Handle landmark examples separately
if (res[r].indexOf('landmark') < 0) {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing in this condition, so right now this loop isn't doing anything


exampleIndexFile = replaceSection('examples_by_role_tbody', exampleIndexFile, html);

sorted = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably clearer to use a new variable than re-using the existing one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter we use flas let and const as errors

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, there should probably be some overrides for the scripts in this folder since they're node rather than browser based. That can be done afterwards though

@mcking65
Copy link
Contributor

mcking65 commented Dec 7, 2018

@jongund,

It seems some roles are being left out of the index. For instance, radiogroup is in the role index, but radio is not. Similarly, tablist is included, but tab is not.

I pushed b1bf298 to make two minor editorial changes to the template.

I tried to run the script to update the index with the changes, but it failed with an error related to an invalid call back.

@jongund
Copy link
Contributor Author

jongund commented Dec 7, 2018

@mcking65 I just get a deprecation error and it generates the index, so I will look it to getting the bug fixed. I think making it a Respec document is a little distracting, I liked the index as you originally proposed as a simple document that indexes the examples. The simpler document though should have a table of contents.

@jongund
Copy link
Contributor Author

jongund commented Dec 7, 2018

@mcking65 I will look into the problem of missing roles from the table.

@jongund
Copy link
Contributor Author

jongund commented Dec 7, 2018

@mcking65 sorry for the confusion about respec, I was looked at the wrong local directory on my computer, I am working on the role problem

@jongund
Copy link
Contributor Author

jongund commented Dec 7, 2018

@mcking65 I fixed the bug that was not including all the roles in the index, I am working on the issue of the the call back issue.

@jongund
Copy link
Contributor Author

jongund commented Dec 7, 2018

@mcking65 I fixed the bug related to the callback error, let me know if you can run the script now

@jongund
Copy link
Contributor Author

jongund commented Dec 7, 2018

@mcking65 I added two links at the beginning of the document to the two types of indexes on the page. I think it makes it easier for people to know there is an index of properties and states without having to scroll through the document.

* Simplified labels on nav regions because the nav regions at top and bottom are identical and have identical purpose, so  they do not need unique labels.
* Added a 1-sentence intro paragraph to make it more clear that this page is part of the APG. This would be important if google landed someone on this index page.
Copy link
Contributor

@mcking65 mcking65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jongund,

We are getting very close here. I fixed lint errors, made a couple more changes to the template, and integrated into aria-practices.html in the appendices.

Please:

  1. Reply to my questions about changes in package.json
  2. In scripts/reference-tables.js, sort ariaRoles or consider my suggestion about aria.query.
  3. In scripts/reference-tables.js, sort ariaPropertiesAndStates or consider my suggestion about aria.query.

package.json Outdated
@@ -28,8 +28,8 @@
"ava": "^0.25.0",
"cheerio": "^1.0.0-rc.2",
"eslint": "^4.19.1",
"geckodriver": "^1.11.0",
"geckodriver": "^1.14.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jongund, was this change necessary for this PR? It seems unrelated.

It should be thoroughly tested. I believe I recall @spectranaut finding geckodriver versions being a factor in performance of tests, race conditions, etc. It seems like we might want to isolate changes like this so they are easy to roll back given that our regression testing has geckodriver as a primary dependency.

I might be making noise about nothing. Perhaps @sh0ji, or @spectranaut if available, should chime in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't modify this file, but I changed the values back

package.json Outdated
"selenium-webdriver": "^4.0.0-alpha.1",
"vnu-jar": "^18.7.23"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar question here ... Is this change related to this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcking65 I didn't directly modify this file, but I will change the value back

<script src="js/app.js"></script>
</head>
<body>
<nav aria-label="ARIA Practices">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed aria-label here and in the footer. It was previously "Top link to ARIA Practices". Per our landmark guidance, if two nav sections have identical content and identical purpose, they should have the same label, not distinct labels. Distinguishing regions with positional terms, "top" and "bottom" is not recommended.

@mcking65 mcking65 added this to the 1.1 APG Release 3 milestone Dec 12, 2018
@mcking65 mcking65 added enhancement Any addition or improvement that doesn't fix a code bug or prose inaccuracy appendix labels Dec 12, 2018
@jongund
Copy link
Contributor Author

jongund commented Dec 19, 2018

@mcking65 The aria-query project maybe useful, but it provides more information than we need for the current index and it is not clear how files from the project should be merged into this pull request.

@jongund
Copy link
Contributor Author

jongund commented Dec 20, 2018

@mcking65 I have sorted the lists for roles, properties and state lists in the source code.

var ariaPropertiesAndStates = [
'aria-activedescendant',
'aria-atomic',
'aria-atomic',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate. There is a few more below, but I'll skip commenting them each individually

@jongund
Copy link
Contributor Author

jongund commented Dec 20, 2018

@mcking65 removed duplicate properties and states from list.

@mcking65 mcking65 merged commit 5ec6c8f into master Dec 21, 2018
@mcking65
Copy link
Contributor

@nschonni, could you help us integrate this into travis build? I suppose it would go into travis-before_deploy.sh?

If you have time to spin up a PR, that would be great!

michael-n-cooper pushed a commit that referenced this pull request Dec 21, 2018
Add index utility (pull #951)

For issue #752, adds a node script for generating two indexes:
* Example by role
* Examples by state or property

The script lands the generated index.html in the /examples directory.
@nschonni
Copy link
Contributor

@mcking65 do you want to exclude the file from the regular branch and just generate it as part of the gh-pages build?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any addition or improvement that doesn't fix a code bug or prose inaccuracy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants