From 7600e943acd5fddc949f18b10a52ac810b9d4ae8 Mon Sep 17 00:00:00 2001 From: JiayingL Date: Thu, 8 Dec 2022 21:52:14 +0800 Subject: [PATCH] Not check errata link for REC with Candidate/Proposed changes (#1680) * Not check errata link for REC with Candidate/Proposed changes * Update lib/rules/headers/errata.js Co-authored-by: Denis Ah-Kang * Update lib/rules/headers/errata.js Co-authored-by: Denis Ah-Kang * address comment https://github.com/w3c/specberus/pull/1680#discussion_r1039163718 * add document * add document * Update lib/rules.json Co-authored-by: Denis Ah-Kang * fix lint Co-authored-by: Denis Ah-Kang --- lib/rules.json | 2 +- lib/rules/headers/errata.js | 17 +++++++ test/data/TR/Recommendation/REC.js | 16 +++++++ test/doc-views/TR/Recommendation/REC.js | 60 +++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) diff --git a/lib/rules.json b/lib/rules.json index 693c1ea83..399a5689d 100644 --- a/lib/rules.json +++ b/lib/rules.json @@ -1223,7 +1223,7 @@ "

If this is a modified Recommendation that was modified in place or is a new edition, the document must include both the original publication date and the modification date. For example:

<p id=\"w3c-state\">W3C Recommendation 7 April 2004, edited in place 19 August2004</p>
" ], "docIDFormat": true, - "docIDOrder": "Document identifier information must be present in this order:
  • 'This version' - URI to that version
  • 'Latest version' - URI to the latest version. See also the (non-normative) Version Management in W3C Technical Reports for information about \"latest version\" URI and version management.
  • 'History' - URI to the history of the specification
  • Editor(s)
  • Feedback - GitHub repository issue links are required in the <dl>after <dt>Feedback:</dt> in the headers (<div class=\"head\">) of the document. Links are expected to be of the form https://github.com/<USER_OR_ORG>/<REPO_NAME>/[issues|labels][/…].)
  • Errata - URI to an errata document for any errors or issues reported since publication. See also suggestions on errata page structure in the Manual of Style. Note: 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 in-place modification of W3C Technical Reports.
", + "docIDOrder": "Document identifier information must be present in this order:
  • 'This version' - URI to that version
  • 'Latest version' - URI to the latest version. See also the (non-normative) Version Management in W3C Technical Reports for information about \"latest version\" URI and version management.
  • 'History' - URI to the history of the specification
  • Editor(s)
  • Feedback - GitHub repository issue links are required in the <dl>after <dt>Feedback:</dt> in the headers (<div class=\"head\">) of the document. Links are expected to be of the form https://github.com/<USER_OR_ORG>/<REPO_NAME>/[issues|labels][/…].)
  • Errata - URI to an errata document for any errors or issues reported since publication. See also suggestions on errata page structure in the Manual of Style. Note:
    • 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 in-place modification of W3C Technical Reports.
    • Recommendations with candidate/proposed changes are treated as inline errata, and these documents don't require an errata link.
", "docIDThisVersion": ["REC"], "docIDDate": true, "docIDLatestVersion": true, diff --git a/lib/rules/headers/errata.js b/lib/rules/headers/errata.js index 800ef5200..b5fdffcd5 100644 --- a/lib/rules/headers/errata.js +++ b/lib/rules/headers/errata.js @@ -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) { diff --git a/test/data/TR/Recommendation/REC.js b/test/data/TR/Recommendation/REC.js index c4f3ce2f9..13eb76e15 100644 --- a/test/data/TR/Recommendation/REC.js +++ b/test/data/TR/Recommendation/REC.js @@ -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, diff --git a/test/doc-views/TR/Recommendation/REC.js b/test/doc-views/TR/Recommendation/REC.js index 21350bf9b..033b69758 100644 --- a/test/doc-views/TR/Recommendation/REC.js +++ b/test/doc-views/TR/Recommendation/REC.js @@ -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: {