Skip to content

Commit

Permalink
Not check errata link for REC with Candidate/Proposed changes (#1680)
Browse files Browse the repository at this point in the history
* Not check errata link for REC with Candidate/Proposed changes

* Update lib/rules/headers/errata.js

Co-authored-by: Denis Ah-Kang <deniak@users.noreply.github.com>

* Update lib/rules/headers/errata.js

Co-authored-by: Denis Ah-Kang <deniak@users.noreply.github.com>

* address comment #1680 (comment)

* add document

* add document

* Update lib/rules.json

Co-authored-by: Denis Ah-Kang <deniak@users.noreply.github.com>

* fix lint

Co-authored-by: Denis Ah-Kang <deniak@users.noreply.github.com>
  • Loading branch information
jennyliang220 and deniak authored Dec 8, 2022
1 parent 8468288 commit 7600e94
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@
" <p>If this is a modified Recommendation that was modified in place or is a new edition, the document <span class=\"rfc2119\">must</span> include both the original publication date and the modification date. For example:</p> <pre xml:space=\"preserve\">&lt;p id=\"w3c-state\"&gt;<a href=\"https://www.w3.org/standards/types#REC\">W3C Recommendation</a> 7 April 2004, edited in place 19 August2004&lt;/p&gt;</pre>"
],
"docIDFormat": true,
"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><li>Errata - URI to an errata document for any errors or issues reported since publication. See also suggestions on <a href=\"https://www.w3.org/2001/06/manual/#Errata\">errata page structure</a> in the Manual of Style. <strong>Note:</strong> Do not put the errata document in TR space as the expectation is that we will not modify document in TR space after publication; see the policy for <a href=\"https://www.w3.org/2003/01/republishing/\">in-place modification of W3C Technical Reports</a>.</li></ul>",
"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><li>Errata - URI to an errata document for any errors or issues reported since publication. See also suggestions on <a href=\"https://www.w3.org/2001/06/manual/#Errata\">errata page structure</a> in the Manual of Style. <strong>Note:</strong><ul><li> Do not put the errata document in TR space as the expectation is that we will not modify document in TR space after publication; see the policy for <a href=\"https://www.w3.org/2003/01/republishing/\">in-place modification of W3C Technical Reports</a>.</li><li>Recommendations with candidate/proposed changes are treated as inline errata, and these documents don't require an errata link.</li></ul></li></ul>",
"docIDThisVersion": ["REC"],
"docIDDate": true,
"docIDLatestVersion": true,
Expand Down
17 changes: 17 additions & 0 deletions lib/rules/headers/errata.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,32 @@

const self = {
name: 'headers.errata',
section: 'front-matter',
rule: 'docIDOrder',
};

export const { name } = self;

// Check if document is Recommendation, and uses inline changes(REC with Candidate/Proposed changes)
function isRECWithChanges(sr) {
if (sr.config.status !== 'REC') {
return false;
}

const recMeta = sr.getRecMetadata({});
return Object.values(recMeta).length !== 0;
}

/**
* @param sr
* @param done
*/
export function check(sr, done) {
// for REC with Candidate/Proposed changes, no need to check errata link
if (isRECWithChanges(sr)) {
return done();
}

const dts = sr.extractHeaders();
// Check 'Errata:' exist, don't check any further.
if (!dts.Errata) {
Expand Down
16 changes: 16 additions & 0 deletions test/data/TR/Recommendation/REC.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ export const rules = {
data: 'noErrata',
errors: ['headers.errata.no-errata'],
},
{
data: 'recWithProposedSubChanges',
errors: [],
},
{
data: 'recWithProposedNewChanges',
errors: [],
},
{
data: 'recWithCandidateSubChanges',
errors: [],
},
{
data: 'recWithCandidateNewChanges',
errors: [],
},
],
dl: [
...baseRules.headers.dl,
Expand Down
60 changes: 60 additions & 0 deletions test/doc-views/TR/Recommendation/REC.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,66 @@ export default {
needErrata: false,
},
},
recWithProposedSubChanges: {
...good,
config: {
...good.config,
needErrata: false,
},
sotd: {
...good.sotd,
rec: {
...good.sotd.rec,
showAddition: true,
addition: 'It includes proposed corrections.',
},
},
},
recWithProposedNewChanges: {
...good,
config: {
...good.config,
needErrata: false,
},
sotd: {
...good.sotd,
rec: {
...good.sotd.rec,
showProposedAdd: true,
},
},
},
recWithCandidateSubChanges: {
...good,
config: {
...good.config,
needErrata: false,
},
sotd: {
...good.sotd,
rec: {
...good.sotd.rec,
showAddition: true,
addition: 'It includes candidate corrections.',
},
},
},
recWithCandidateNewChanges: {
...good,
config: {
...good.config,
needErrata: false,
},
sotd: {
...good.sotd,
rec: {
...good.sotd.rec,
showAddition: true,
addition:
'It includes candidate additions, introducing new features since the previous Recommendation.',
},
},
},
},
deployment: {
noDeployment: {
Expand Down

0 comments on commit 7600e94

Please sign in to comment.