Skip to content

Commit

Permalink
Add check for lowercase new shortname (#1579)
Browse files Browse the repository at this point in the history
* add check for lowercase new shortname

* fix lint

* restore package.json

* fix prettier

* add check for shortname change, use first-public

* resolve test.only

Co-authored-by: Denis Ah-Kang <[email protected]>
  • Loading branch information
jennyliang220 and deniak authored Apr 15, 2022
1 parent 5b5825c commit bf01c44
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/l10n-en_GB.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export const messages = {
"Content of title and h1 do not match. Text of title is '${titleText}' while h1 is (transformed into) '${h1Text}'.",
// headers/dl
'headers.dl.this-version': 'This Version is missing.',
'headers.dl.shortname-lowercase':
'The shortname of the document must in lowercase, but `${shortname}` is found.',
'headers.dl.latest-version': 'Latest Version is missing.',
'headers.dl.no-history': 'History link is missing.',
'headers.dl.this-latest-order':
Expand Down
2 changes: 1 addition & 1 deletion lib/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@
"dateState": "The document's status and date <span class=\"rfc2119\">must</span> be in a <code>&lt;p id=\"w3c-state\"&gt;</code> element as follows (see also <a href=\"#datesFormat\">date syntax</a>): <pre xml:space=\"preserve\">&lt;p id=\"w3c-state\"&gt;<a href=\"https://www.w3.org/standards/types#@@Profile\">W3C @{param1}</a> DD Month YYYY&lt;/p&gt;</pre>@{param2}",
"docIDFormat": "Document identifier information <span class=\"rfc2119\">must</span> be presented in a <code>dl</code> list, where each <code>dt</code> element marks up an identifier role (\"This Version\", \"Latest Version\", \"History\", etc.) and each <code>dd</code> element includes a link whose link text is the identifier. That <code>dl</code> <span class=\"rfc2119\">must</span> itself be placed in a <code>details</code> element. <p><span style=\"font-style: italic\">Include this source code:</span><br/><code>&lt;details open&gt;&lt;summary&gt;More details about this document&lt;/summary&gt;&lt;dl&gt;...&lt;/dl&gt;&lt;/details&gt;</code></p>",
"docIDOrder": "Document identifier information <span class=\"rfc2119\">must</span> be present in this order: <ul><li>'This version' - URI to that version</li><li>'Latest version' - URI to the latest version. See also the (non-normative) <cite> <a href=\"https://www.w3.org/2005/05/tr-versions\">Version Management in W3C Technical Reports</a> </cite> for information about \"latest version\" URI and version management.</li><li class=\"historyuri\">'History' - URI to the history of the specification</li><li>Editor(s)</li><li>Feedback - GitHub repository issue links are required in the &lt;dl&gt;after &lt;dt&gt;Feedback:&lt;/dt&gt; in the headers (&lt;div class=\"head\"&gt;) of the document. Links are expected to be of the form <code>https://github.com/&lt;USER_OR_ORG&gt;/&lt;REPO_NAME&gt;/[issues|labels][/&hellip;]</code>.)</li></ul>",
"docIDThisVersion": "The syntax of a “this version” URI <span class=\"rfc2119\">must</span> be <code>https://www.w3.org/TR/YYYY/@{param1}-shortname-YYYYMMDD/</code>.",
"docIDThisVersion": "The syntax of a “this version” URI <span class=\"rfc2119\">must</span> be <code>https://www.w3.org/TR/YYYY/@{param1}-shortname-YYYYMMDD/</code>. If the document introduces a new shortname, it <span class=\"rfc2119\">must</span> use lowercase letters.",
"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.",
Expand Down
8 changes: 8 additions & 0 deletions lib/rules/headers/dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ export async function check(sr, done) {
)
sr.error(self, 'this-date');
} else sr.warning(self, 'no-date');

// Require new /TR shortnames to use lowercase.
const shortnameChange =
dts.History &&
dts.History.dd.querySelector('a').dataset.previousShortname;
const needLowercase = shortnameChange || (await sr.isFP());
if (needLowercase && shortname.toLowerCase() !== shortname)
sr.error(thisError, 'shortname-lowercase', { shortname });
} else sr.error(thisError, 'this-syntax');
}
}
Expand Down
10 changes: 10 additions & 0 deletions test/data/TR/Note/DNOTE.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,14 @@ export const rules = {
...baseRules.sotd,
'draft-stability': draftStabilityRules,
},
headers: {
...baseRules.headers,
dl: [
...baseRules.headers.dl,
{
data: 'shortnameLowercaseFP',
errors: ['headers.dl.shortname-lowercase'],
},
],
},
};
15 changes: 14 additions & 1 deletion test/data/TR/Note/NOTE.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
import noteBase from './noteBase.js';

export const { rules } = noteBase;
export const { rules: baseRules } = noteBase;

export const rules = {
...baseRules,
headers: {
...baseRules.headers,
dl: [
...baseRules.headers.dl,
{
data: 'shortnameLowercase',
},
],
},
};
9 changes: 9 additions & 0 deletions test/data/TR/Recommendation/CR.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ export const rules = {
...baseRules.structure,
'security-privacy': securityPrivacyRules,
},
headers: {
...baseRules.headers,
dl: [
...baseRules.headers.dl,
{
data: 'shortnameLowercase',
},
],
},
};
10 changes: 10 additions & 0 deletions test/data/TR/Recommendation/FPWD.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,14 @@ export const rules = {
...baseRules.sotd,
'draft-stability': draftStabilityRules,
},
headers: {
...baseRules.headers,
dl: [
...baseRules.headers.dl,
{
data: 'shortnameLowercaseFP',
errors: ['headers.dl.shortname-lowercase'],
},
],
},
};
6 changes: 6 additions & 0 deletions test/data/TR/Recommendation/REC.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,11 @@ export const rules = {
errors: ['headers.errata.no-errata'],
},
],
dl: [
...baseRules.headers.dl,
{
data: 'shortnameLowercase',
},
],
},
};
9 changes: 9 additions & 0 deletions test/data/TR/Registry/CRYD.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@ export const rules = {
...baseRules.sotd,
'draft-stability': draftStabilityRulesForDraft,
},
headers: {
...baseRules.headers,
dl: [
...baseRules.headers.dl,
{
data: 'shortnameLowercase',
},
],
},
};
10 changes: 10 additions & 0 deletions test/data/TR/Registry/DRY.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,14 @@ export const rules = {
...baseRules.sotd,
'draft-stability': draftStabilityRules,
},
headers: {
...baseRules.headers,
dl: [
...baseRules.headers.dl,
{
data: 'shortnameLowercaseFP',
errors: ['headers.dl.shortname-lowercase'],
},
],
},
};
24 changes: 24 additions & 0 deletions test/doc-views/specBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,30 @@ export function buildCommonViewData(base) {
status: 'FWD',
},
},
shortnameLowercaseFP: {
...base,
dl: {
...base.dl,
shortName: 'UPPERcase-name',
seriesShortName: 'UPPERcase-name',
history: {
...base.dl.history,
shortName: 'UPPERcase-name',
},
},
},
shortnameLowercase: {
...base,
dl: {
...base.dl,
shortName: 'FileAPI',
seriesShortName: 'FileAPI',
history: {
...base.dl.history,
shortName: 'FileAPI',
},
},
},
noLatestLinkExist: {
...base,
dl: {
Expand Down

0 comments on commit bf01c44

Please sign in to comment.