-
Notifications
You must be signed in to change notification settings - Fork 57
Upgrade the github issue template for wide review #397
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
Open
plehegar
wants to merge
5
commits into
main
Choose a base branch
from
wd-gh-template
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+157
−67
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
55883d5
Upgrade the github issue template for wide review
plehegar b32015c
Allow repo= as a URL parameter
plehegar 30b24f3
Update documentreview/create-github-issue.js
plehegar 00eaa25
Update documentreview/create-github-issue.js
plehegar 4969dbc
Update documentreview/create-github-issue.js
plehegar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,54 +1,144 @@ | ||
| window.addEventListener('load', addGitHubIssueButton); | ||
| /** | ||
| * Script that adds a button to the Document review page that readers may use | ||
| * to draft a meta issue in the GitHub repository of their choice to track wide | ||
| * review steps. | ||
| * | ||
| * The script expects to find specific anchors in the Document review page, | ||
| * including a definition list for each horizontal flagged with a `data-type` | ||
| * attribute whose value matches the prefix used in GitHub labels | ||
| * `[foo]-needs-resolution` and `[foo]-tracker`, with individual steps flagged | ||
| * as such. | ||
| */ | ||
|
|
||
| const repositories = fetch('https://w3c.github.io/groups/repositories.json').then(res => res.ok ? res.json() : []) | ||
| .catch(() => []); | ||
|
|
||
| const template = `# Wide review tracker for a specification | ||
|
|
||
| This is a meta issue to track wide review steps for the specification. | ||
| See [How to do wide review](https://www.w3.org/guide/documentreview/#who-to-ask-for-wide-review) for details. | ||
|
|
||
| >Legend: | ||
| >🔴 Review request not submitted | ||
| >🟡 Review request submitted | ||
| >🔵 Review feedback received | ||
| >🟢 Review closed as completed | ||
|
Comment on lines
+21
to
+25
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forgot one thing: how is that legend supposed to be applied? Are people supposed to manually update the colored circles of individual horizontal reviews in the issue description as progress gets made? That may be nice-looking but seems easy to get wrong. |
||
|
|
||
| ## Horizontal groups | ||
|
|
||
| An important part of wide review is horizontal review from W3C's [key horizontal groups](https://www.w3.org/guide/documentreview/#how-to-get-horizontal-review) listed below. | ||
|
|
||
| {{HORIZONTAL_GROUPS_LIST}} | ||
| ## Group Dependencies | ||
|
|
||
| The [charter](https://www.w3.org/groups/YOURGROUP) contains a list of dependency groups. If you skip one of those, simply provide a rational. | ||
|
|
||
| 🔴 ?? Group: | ||
|
|
||
| - [ ] feedback requested | ||
| - [ ] feedback received | ||
| - [ ] Review closed as completed | ||
|
|
||
| ## Other stakeholders | ||
|
|
||
| From [who to ask for review](https://www.w3.org/Guide/documentreview/#who_to_ask_for_review): | ||
| >Horizontal reviews [...] are only a subset of a full wide review, which must also include other stakeholders including Web developers, technology providers and implementers not active in the Working Group, external groups and standards organizations working on related areas, etc. | ||
|
|
||
| `; | ||
|
|
||
| function addGitHubIssueButton() { | ||
| document.querySelector('#githubissue button').addEventListener('click', createGitHubIssue); | ||
| const params = new URLSearchParams(window.location.search); | ||
| const repo = params.get('repo'); | ||
| if (repo) { | ||
| document.getElementById('repository').value = repo; | ||
| } | ||
| document.getElementById('githubissue').hidden = false; | ||
| } | ||
|
|
||
|
|
||
| function createGitHubIssue(event) { | ||
| async function createGitHubIssue(event) { | ||
| event.preventDefault(); | ||
| const value = document.getElementById('repository').value.trim(); | ||
| const match = value.match(/github\.com\/(.*?)\/?$/); | ||
| const repo = match ? match[1] : value; | ||
| if (!repo.match(/^[^\s\/]+\/[^\s\/]+$/)) { | ||
| let match = value.match(/github\.com\/(.*?)\/?$/); | ||
| match = (match ? match[1] : value).match(/^([^\s\/]+)\/([^\s\/]+)$/); | ||
| if (!match) { | ||
| console.warn('Invalid repository name entered', value); | ||
| window.alert(`Invalid repository name: "${value}".\nExpected format: "owner/repo", e.g. "w3c/foobar".`); | ||
| return; | ||
| } | ||
|
|
||
| const repo = { owner: match[1], name: match[2] }; | ||
| console.log(`Creating GitHub issue for repository: ${repo.owner}/${repo.name}`); | ||
|
|
||
| const title = encodeURIComponent('Seek wide review'); | ||
| const body = encodeURIComponent(generateGitHubIssueBody()); | ||
| window.open(`https://github.com/${repo}/issues/new?title=${title}&body=${body}`); | ||
| try { | ||
| const body = encodeURIComponent(await generateGitHubIssueBody(repo)); | ||
| window.open(`https://github.com/${repo.owner}/${repo.name}/issues/new?title=${title}&body=${body}`); | ||
| } catch (error) { | ||
| console.error('Error creating GitHub issue:', error); | ||
| window.alert('Failed to create GitHub issue. Please try again later.'); | ||
| } | ||
| } | ||
|
|
||
| async function generateGitHubIssueBody(repo) { | ||
|
|
||
| function generateGitHubIssueBody() { | ||
| const dl = document.querySelector('#how-to-get-horizontal-review ~ dl'); | ||
| if (!dl) { | ||
| console.error('Could not find right anchor in "How to get horizontal review" section'); | ||
| throw new Error('Could not find right anchor in "How to get horizontal review" section'); | ||
| } | ||
|
|
||
| const bullets = [...dl.querySelectorAll('dt')].map(dt => { | ||
| const horizontal = dt.dataset.type || 'unknown'; | ||
| const dd = dt.nextElementSibling; | ||
| if (dd.tagName !== 'DD') { | ||
| console.error('Could not find a DD tag after DT', dt); | ||
| return; | ||
| throw new Error('Could not find a DD tag after DT in one of the horizontal sections'); | ||
| } | ||
|
|
||
| const subContents = [...dd.querySelectorAll('.step')].map(el => ` - [ ] ${el.innerHTML}`); | ||
| const subContents = [...dd.querySelectorAll('.step')].map(el => `- [ ] ${html2Markdown(el)}`); | ||
|
|
||
| const after = `- [ ] Address [${horizontal}-needs-resolution](https://github.com/${repo.owner}/${repo.name}/labels/${horizontal}-needs-resolution) issues | ||
| - [ ] Consider [${horizontal}-tracker](https://github.com/${repo.owner}/${repo.name}/labels/${horizontal}-tracker) issues | ||
| - [ ] feedback integrated | ||
| - [ ] Review confirmed completed`; | ||
|
|
||
| return ` - ${dt.textContent}\n${subContents.join('\n')}`; | ||
| return `🔴 **${dt.textContent}**\n\n${subContents.join('\n')}\n${after}\n`; | ||
| }); | ||
|
|
||
| const group = await findGroup(repo); | ||
|
|
||
| return `This is a meta issue to track wide review steps for the specification. | ||
| See [How to do wide review](https://www.w3.org/guide/documentreview/#who-to-ask-for-wide-review) for details. | ||
| return template | ||
| .replace('{{HORIZONTAL_GROUPS_LIST}}', bullets.join('\n')) | ||
| .replace(/YOURGROUP/g, (group) ? `${group}/charters/active/#coordination` : ''); | ||
| } | ||
|
|
||
| - [ ] the groups listed in the WG's charter, especially those who manage dependencies | ||
| - [ ] the groups jointly responsible for a particular document (if any). | ||
| - the horizontal groups: | ||
| ${bullets.join('\n')} | ||
| - Other outreach (if applicable) | ||
| `; | ||
| function html2Markdown(element) { | ||
| let markdown = element.innerHTML; | ||
| markdown = markdown.replace(/<strong>(.*?)<\/strong>/g, '**$1**'); | ||
| markdown = markdown.replace(/<em>(.*?)<\/em>/g, '*$1*'); | ||
| markdown = markdown.replace(/ rel="[^"]+"/g, ''); | ||
| markdown = markdown.replace(/ class="[^"]+"/g, ''); | ||
| markdown = markdown.replace(/<a href="(.*?)">(.*?)<\/a>/g, '[$2]($1)'); | ||
| markdown = markdown.replace(/<[^>]+>/g, ''); | ||
| return markdown.trim(); | ||
| } | ||
|
|
||
| async function findGroup(repo) { | ||
| const repoInfo = (await repositories).find(r => r.name.toLowerCase() === repo.name.toLowerCase() && r.owner.login.toLowerCase() === repo.owner.toLowerCase()); | ||
| const groups = (repoInfo && repoInfo.w3cjson) ? repoInfo.w3cjson.group : null; | ||
|
|
||
| if (groups && groups.length > 0) { | ||
| const wgs = groups.filter(g => g.startsWith('wg/')); | ||
| const igs = groups.filter(g => g.startsWith('ig/')); | ||
| if (wgs.length > 0) { | ||
| return wgs[0]; | ||
| } else if (igs.length > 0) { | ||
| return igs[0]; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| if (document.readyState === 'loading') { | ||
| document.addEventListener('DOMContentLoaded', addGitHubIssueButton); | ||
| } else { | ||
| addGitHubIssueButton(); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.