-
Notifications
You must be signed in to change notification settings - Fork 344
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
Issue 752 example index #947
Issue 752 example index #947
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the ESLint config might need to be updated to look for a few more things
var fileNameTemplate = 'index.template'; | ||
var fileNameIndex = 'index.html'; | ||
|
||
ariaRoles = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var = ariaRoles
unless it's supposed to be a global variable
'tooltip' | ||
]; | ||
|
||
ariaPropertiesAndStates = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var = ariaPropertiesAndStates
unless it's supposed to be a global variable
'aria-setsize' | ||
]; | ||
|
||
indexOfRoles = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global variable?
|
||
var sorted = []; | ||
|
||
for (role in indexOfRoles) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorted = indexOfRoles.slice();
|
||
sorted = []; | ||
|
||
for (prop in indexOfPropertiesAndStates) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorted = indexOfPropertiesAndStates.slice();
]; | ||
|
||
indexOfRoles = []; | ||
indexOfPropertiesAndStates = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global variable?
} | ||
|
||
function getTitle (data) { | ||
title = data.substring(data.indexOf('<title>') + 7, data.indexOf('</title>')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var title = ...
|
||
sorted.sort(); | ||
|
||
html = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In places where HTML is generated via string concatenation, consider using a JS template literal with some utility functions, such as
const html = sorted.reduce((set, role) => {
const examples = indexOfRoles[role];
let examplesHTML = '';
if (examples.length === 1) {
examplesHTML = `<a href="${examples[0].ref}">${examples[0].title}</a>`;
else {
const exampleListItem = item => `<li><a href="${item.ref}">${item.title}</a></li>`;
examplesHTML = `<ul>${examples.map(exampleListItem).join('\n')}</ul>`;
}
return set + `
<tr>
<td><code>${role}</code></td>
<td>${examplesHtml}</td>
</tr>
`;
}, '');
It's available in Node 6 and up. Keep in mind you can still use var
in place of let
and const
if you so wish.
@jongund, what is the benefit of making the index into a separate respec doc? It gives the impression that the index is a separate publication. I don't know if respec still supports doing so, but ARIA 1.0 had a version where each section was split into a separate page. For example, here is the intro: So, respec might somehow be told to strip out all the redundant information and tie it back to the main doc. However, I don't think that buys us anything. It'd be much simpler to have a template that includes the header and footer info we want. |
Wow @jongund, this index is super useful!! One side effect of respec is that it changes the heading content, which then makes for some very confusing table captions:
I was particularly confused by the word "section", which is the accessible name Chrome calculates for the permalink. It gets included in the table caption along with the section number. Somehow it caused me to overlook the presence of the table ... then I looked at the code and understood. |
I see you are trimming the word "example". If the title starts with "example of ", like with the tabs examples, we should trim the " of " as well. |
@jongund, We probably want the example-index.js and index.template files in the root /scripts folder along with travis-deploy.sh, or perhaps in the root folder itself. I think it would be good to name the output file attribute-index.html instead of index.html. We have a plan to change the name of aria-practices.html to index.html. @michael-n-cooper may have an opinion on this. |
I'm afraid I can't tell what you're doing enough to have an opinion, I'm not a code whiz and there are a lot of commits in this pull request to try to figure out. I would have an opinion about the locations of files named index.html, the naming of files meant to serve as indices, etc. But I can't offer an opinion on this specific issue at this time. |
Matt, |
Jon, We do not have to use respec for it to a file in the examples directory. Just like none of the example pages are respec docs, the attribute-index.html file does not have to be a respec doc. |
I will ask Michael tomorrow if having the index in a separate file is better from a build and publication process perspective. |
I am going to move this code over to the issue752-add-index-utility branch in the w3c/practices repo and just make a simple document for the index and look at the js coding recommendations in this issue to update the script. |
@jongund, that sounds great. I did discuss this with Michael today. Here are his preferences:
After you have made these changes and considered the other recommendations above, we'll look for advice from @nschonni wrt integrating into the travis build. Thank you again for taking this one on!!! |
This pull request can be ignored, please see pull request 951 for the latest version of the index based on feedback from Matt King and Michael Cooper. |
Closing because replaced by pull request #951. |
For issue #752, Updated the example index as a separate document using ReSpec.
Updated the generation of the example index to not use Glob, only uses fs (FileSystem) for node.
Preview | Diff