Skip to content

Commit

Permalink
check that the editors are participating in the group producing the s…
Browse files Browse the repository at this point in the history
…pec (#1787)

* check that the editors are participating in the group producing the spec

* fix tests

* add tests on editors group participation
  • Loading branch information
deniak authored Nov 13, 2023
1 parent f3d086f commit 879ef0f
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 15 deletions.
3 changes: 3 additions & 0 deletions lib/l10n-en_GB.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ export const messages = {
'headers.dl.editor-not-found': 'Cannot find any editors for this document.',
'headers.dl.editor-missing-id':
'Missing `data-editor-id` attribute for editor(s): ${names}.',
// headers/editor-participation
'headers.editor-participation.not-participating':
'The user with id ${id} is not participating in the group producing this document.',
// headers/errata
'headers.errata.no-errata':
'"Errata:" not found in the headers (<div class="head">) of the document.',
Expand Down
2 changes: 2 additions & 0 deletions lib/profiles/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import * as detailsSummary from '../rules/headers/details-summary.js';
import * as divHead from '../rules/headers/div-head.js';
import * as dl from '../rules/headers/dl.js';
import * as editorParticipation from '../rules/headers/editor-participation.js';
import * as shortname from '../rules/headers/shortname.js';
import * as h1Title from '../rules/headers/h1-title.js';
import * as h2Toc from '../rules/headers/h2-toc.js';
Expand Down Expand Up @@ -38,6 +39,7 @@ export const rules = [
h1Title,
detailsSummary,
dl,
editorParticipation,
shortname,
w3cState,
h2Toc,
Expand Down
2 changes: 1 addition & 1 deletion lib/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@
"docIDDate": "The title page date and the date at the end of the \"This Version\" URI <span class=\"rfc2119\">must</span> match.",
"docIDLatestVersion": "The syntax of a “latest version” URI <span class=\"rfc2119\">must</span> be <code>https://www.w3.org/TR/shortname/</code>.",
"docIDHistory": "The syntax of a “history” URI <span class=\"rfc2119\">must</span> be <code>https://www.w3.org/standards/history/shortname/</code>, and consistent with the shortname mentioned in 'Latest Version'. <em>Note</em>: If there's a shortname change it <span class=\"rfc2119\">must</span> be specified using the following data attribute <code>data-previous-shortname='previous-shortname'</code> on the <code>&lt;a&gt;</code> element.",
"editorSection": "The editors'/authors' names <span class=\"rfc2119\">must</span> be listed, with attribute <code>data-editor-id=\"@@\"</code>. Affiliations and email addresses are <span class=\"rfc2119\">optional</span>; email addresses are <span class=\"rfc2119\">not recommended</span>. If an editor/author is acknowledged in an earlier version of this document and the individual's affiliation has since changed, list the individual using the notation \"&lt;name&gt;, &lt;affiliation&gt; (until DD Month YYYY)\". If the list of authors is very long (e.g., the entire Working Group), identify the authors in the acknowledgments section, linked from the head of the document. Distinguish any contributors from authors in the acknowledgments section.",
"editorSection": "The editors'/authors' names <span class=\"rfc2119\">must</span> be listed, with attribute <code>data-editor-id=\"@@\"</code>. Affiliations and email addresses are <span class=\"rfc2119\">optional</span>; email addresses are <span class=\"rfc2119\">not recommended</span>. If an editor/author is acknowledged in an earlier version of this document and the individual's affiliation has since changed, list the individual using the notation \"&lt;name&gt;, &lt;affiliation&gt; (until DD Month YYYY)\". If the list of authors is very long (e.g., the entire Working Group), identify the authors in the acknowledgments section, linked from the head of the document. Distinguish any contributors from authors in the acknowledgments section.<br>Note: Editors <span class=\"rfc2119\">must</span> be participating in the group producing the document at the time of its publication.",
"altRepresentations": "Authors <span class=\"rfc2119\">may</span> provide links to alternative (non-normative) representations or packages for the document. For instance: <p> <code> <small>&lt;p&gt;This document is also available in these non-normative formats: &lt;a href=\"@{param1}-shortname-20180101.html\"&gt;single HTML file&lt;/a&gt;, &lt;a href=\"@{param1}-shortname-20180101.tgz\"&gt;gzipped tar file of HTML&lt;/a&gt;.&lt;/p&gt; </small> </code> </p>",
"implReport": "It <span class=\"rfc2119\">must</span> include either: <ul> <li>a link to an interoperability or implementation report if the Director used such a report as part of the decision to advance the specification, or</li> <li>a statement that the Director's decision did not involve such a report.</li> </ul>",
"copyright": "Starting from 01 February 2023, the copyright <span class=\"rfc2119\">must</span> follow the following markup (fill in with the appropriate year, years, or year range). The type of license the document is using can be found in the group's charter. <ol> <li>For documents using W3C Document License: <blockquote class=\"copyright\"><a href=\"https://www.w3.org/policies/#copyright\">Copyright</a> © @{year} <a href=\"https://www.w3.org/\">World Wide Web Consortium</a>. <abbr title=\"World Wide Web Consortium\">W3C</abbr><sup>®</sup> <a href=\"https://www.w3.org/policies/#Legal_Disclaimer\">liability</a>, <a href=\"https://www.w3.org/policies/#W3C_Trademarks\">trademark</a> and <a href=\"https://www.w3.org/copyright/document-license/\">document use</a> rules apply.</blockquote><div class=\"source\"> <span style=\"font-style: italic\">Include this source code</span>:<br><code>&lt;p class=&quot;copyright&quot;&gt;&lt;a href=&quot;https://www.w3.org/policies/#copyright&quot;&gt;Copyright&lt;/a&gt; © @{year} &lt;a href=&quot;https://www.w3.org/&quot;&gt;World Wide Web Consortium&lt;/a&gt;. &lt;abbr title=&quot;World Wide Web Consortium&quot;&gt;W3C&lt;/abbr&gt;&lt;sup&gt;®&lt;/sup&gt; &lt;a href=&quot;https://www.w3.org/policies/#Legal_Disclaimer&quot;&gt;liability&lt;/a&gt;, &lt;a href=&quot;https://www.w3.org/policies/#W3C_Trademarks&quot;&gt;trademark&lt;/a&gt; and &lt;a href=\"https://www.w3.org/copyright/document-license/\"&gt;document use&lt;/a&gt; rules apply.&lt;/p&gt;</code> </div></li><li>For documents using W3C Software and Document License: <blockquote class=\"copyright\"><a href=\"https://www.w3.org/policies/#copyright\">Copyright</a> © @{year} <a href=\"https://www.w3.org/\">World Wide Web Consortium</a>. <abbr title=\"World Wide Web Consortium\">W3C</abbr><sup>®</sup> <a href=\"https://www.w3.org/policies/#Legal_Disclaimer\">liability</a>, <a href=\"https://www.w3.org/policies/#W3C_Trademarks\">trademark</a> and <a href=\"https://www.w3.org/copyright/software-license/\">permissive document license</a> rules apply.</blockquote><div class=\"source\"> <span style=\"font-style: italic\">Include this source code</span>:<br><code>&lt;p class=&quot;copyright&quot;&gt;&lt;a href=&quot;https://www.w3.org/policies/#copyright&quot;&gt;Copyright&lt;/a&gt; © @{year} &lt;a href=&quot;https://www.w3.org/&quot;&gt;World Wide Web Consortium&lt;/a&gt;. &lt;abbr title=&quot;World Wide Web Consortium&quot;&gt;W3C&lt;/abbr&gt;&lt;sup&gt;®&lt;/sup&gt; &lt;a href=&quot;https://www.w3.org/policies/#Legal_Disclaimer&quot;&gt;liability&lt;/a&gt;, &lt;a href=&quot;https://www.w3.org/policies/#W3C_Trademarks&quot;&gt;trademark&lt;/a&gt; and &lt;a href=&quot;https://www.w3.org/copyright/software-license/&quot;&gt;permissive document license&lt;/a&gt; rules apply.&lt;/p&gt;</code> </div></li></ol><p>Note: Exceptions are listed in this <a href=\"https://github.com/w3c/specberus/blob/main/lib/copyright-exceptions.json\">json file</a>.",
Expand Down
38 changes: 38 additions & 0 deletions lib/rules/headers/editor-participation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint-disable */
import w3cApi from 'node-w3capi';

const self = {
name: 'headers.editor-participation',
section: 'front-matter',
rule: 'editorSection',
};
export const name = self.name;

export async function check(sr, done) {
const groups = await sr.getDelivererIDs();
const editors = await sr.getEditorIDs();

const groupUsersPromises = [];
groups.forEach(id => {
groupUsersPromises.push(
new Promise(resolve =>
w3cApi
.group(id)
.users()
.fetch({ embed: true }, (err, data) => {
resolve(data.map(user => user.id));
})
)
);
});

const userIds = (await Promise.all(groupUsersPromises)).flat();

editors.forEach(id => {
if (!userIds.includes(id)) {
sr.error(self, 'not-participating', { id });
}
});

done();
}
6 changes: 6 additions & 0 deletions test/data/TR/TRBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export const rules = {
errors: ['headers.copyright.exception-no-html'],
},
],
'editor-participation': [
{
data: 'noEditorParticipation',
errors: ['headers.editor-participation.not-participating'],
},
],
},
style: {
...baseRules.style,
Expand Down
4 changes: 4 additions & 0 deletions test/doc-views/layout/spec.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
<dt><span class="handlebars-data">{{dl.editorText}}</span>:</dt>
<dd class="p-author h-card vcard" data-editor-id="{{dl.editor.id}}">George Herald (WebFoo)
</dd>
{{#if dl.editor2.show}}
<dd class="p-author h-card vcard" data-editor-id="{{dl.editor2.id}}">John Doe (WebFoo)
</dd>
{{/if}}
{{/if}}

{{#config.isRescinded}}
Expand Down
17 changes: 16 additions & 1 deletion test/doc-views/specBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ export const data = {
},
editor: {
show: true,
id: '56102',
id: '3439',
},
editor2: {
show: false,
},
history: {
show: true,
Expand Down Expand Up @@ -609,6 +612,18 @@ export function buildCommonViewData(base) {
},
},
},
'editor-participation': {
noEditorParticipation: {
...base,
dl: {
...base.dl,
editor2: {
show: true,
id: '3440',
},
},
},
},
shortname: {
shortnameLowercaseFP: {
...base,
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-cr.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1 id="title" class="title p-name">High Resolution Time</h1>
</dd>

<dt>Editor:</dt>
<dd class="p-author h-card vcard" data-editor-id="56102">George Herald
<dd class="p-author h-card vcard" data-editor-id="3439">George Herald
(WebFoo)
</dd>
<dt>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-crd.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h1 id="title" class="title p-name">High Resolution Time</h1>
</dd>

<dt>Editor:</dt>
<dd class="p-author h-card vcard" data-editor-id="56102">George Herald
<dd class="p-author h-card vcard" data-editor-id="3439">George Herald
(WebFoo)
</dd>
<dt>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-disc.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h1 id="title" class="title p-name">Foo Time</h1>
</dd>

<dt>Editor:</dt>
<dd class="p-author h-card vcard" data-editor-id="56102">George Herald
<dd class="p-author h-card vcard" data-editor-id="3439">George Herald
(WebFoo)
</dd>
<dt>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-fpwd.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h1 id="title" class="title p-name">Foo Time</h1>
</dd>

<dt>Editor:</dt>
<dd class="p-author h-card vcard" data-editor-id="56102">George Herald
<dd class="p-author h-card vcard" data-editor-id="3439">George Herald
(WebFoo)
</dd>
<dt>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-pr.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h1 id="title" class="title p-name">High Resolution Time</h1>
</dd>

<dt>Editor:</dt>
<dd class="p-author h-card vcard" data-editor-id="56102">George Herald
<dd class="p-author h-card vcard" data-editor-id="3439">George Herald
(WebFoo)
</dd>
<dt>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-wd-shortname-change.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h1 id="title" class="title p-name">Foo Time</h1>
</dd>

<dt>Editor:</dt>
<dd class="p-author h-card vcard" data-editor-id="56102">George Herald
<dd class="p-author h-card vcard" data-editor-id="3439">George Herald
(WebFoo)
</dd>
<dt>
Expand Down
2 changes: 1 addition & 1 deletion test/docs/2021-wd.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h1 id="title" class="title p-name">Foo Time</h1>
</dd>

<dt>Editor:</dt>
<dd class="p-author h-card vcard" data-editor-id="56102">George Herald
<dd class="p-author h-card vcard" data-editor-id="3439">George Herald
(WebFoo)
</dd>
<dt>
Expand Down
12 changes: 6 additions & 6 deletions test/samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const samples = [
profile: 'FPWD',
title: 'Foo Time',
docDate: '2021-11-4',
editorIDs: [56102],
editorIDs: [3439],
editorNames: ['George Herald'],
informative: false,
process: 'https://www.w3.org/2023/Process-20231103/',
Expand All @@ -23,7 +23,7 @@ export const samples = [
profile: 'WD',
title: 'Foo Time',
docDate: '2021-11-4',
editorIDs: [56102],
editorIDs: [3439],
editorNames: ['George Herald'],
informative: false,
process: 'https://www.w3.org/2023/Process-20231103/',
Expand All @@ -43,7 +43,7 @@ export const samples = [
rectrack: 'Recommendation',
title: 'Foo Time',
docDate: '2021-11-4',
editorIDs: [56102],
editorIDs: [3439],
editorNames: ['George Herald'],
informative: false,
process: 'https://www.w3.org/2023/Process-20231103/',
Expand All @@ -64,7 +64,7 @@ export const samples = [
implementationReport: 'https://wpt.fyi/hr-time/',
title: 'High Resolution Time',
docDate: '2021-11-4',
editorIDs: [56102],
editorIDs: [3439],
editorNames: ['George Herald'],
informative: false,
process: 'https://www.w3.org/2023/Process-20231103/',
Expand All @@ -84,7 +84,7 @@ export const samples = [
implementationReport: 'https://wpt.fyi/hr-time/',
title: 'High Resolution Time',
docDate: '2021-11-4',
editorIDs: [56102],
editorIDs: [3439],
editorNames: ['George Herald'],
informative: false,
process: 'https://www.w3.org/2023/Process-20231103/',
Expand All @@ -105,7 +105,7 @@ export const samples = [
implementationReport: 'https://wpt.fyi/hr-time/',
title: 'High Resolution Time',
docDate: '2021-11-4',
editorIDs: [56102],
editorIDs: [3439],
editorNames: ['George Herald'],
informative: false,
process: 'https://www.w3.org/2023/Process-20231103/',
Expand Down

0 comments on commit 879ef0f

Please sign in to comment.