diff --git a/src/w3c/headers.js b/src/w3c/headers.js index 68e9d8e153..072290884e 100644 --- a/src/w3c/headers.js +++ b/src/w3c/headers.js @@ -465,11 +465,6 @@ export async function run(conf) { showError(msg, name); } if (conf.copyrightStart == conf.publishYear) conf.copyrightStart = ""; - if (conf.isRec && !conf.errata && !conf.revisionTypes?.length) { - const msg = "Recommendations must have an errata link."; - const hint = docLink`Add an ${"[errata]"} URL to your ${"[respecConfig]"}.`; - showError(msg, name, { hint }); - } conf.dashDate = ISODate.format(conf.publishDate); conf.publishISODate = conf.publishDate.toISOString(); conf.shortISODate = ISODate.format(conf.publishDate); @@ -571,53 +566,34 @@ export async function run(conf) { } conf.prEnd = validateDateAndRecover(conf, "prEnd"); - if (conf.hasOwnProperty("updateableRec")) { - const msg = "Configuration option `updateableRec` is deprecated."; - const hint = docLink`Add an ${"[`updateable-rec`|#updateable-rec-class]"} CSS class to the Status of This Document section instead.`; - showWarning(msg, name, { hint }); - if (conf.updateableRec) { - sotd.classList.add("updateable-rec"); - } + const isUpdatableRec = sotd.classList.contains("updateable-rec"); + const hasCorrections = document.querySelector(".correction") !== null; + const hasProposedCorrections = + document.querySelector(".proposed-correction") !== null; + const hasAdditions = document.querySelector(".addition") !== null; + const hasProposedAdditions = + document.querySelector(".proposed-addition") !== null; + const hasRevisions = + hasCorrections || + hasAdditions || + hasProposedAdditions || + hasProposedCorrections; + + if (conf.isRec && !conf.errata && !hasRevisions) { + const msg = "Recommendations must have an errata link."; + const hint = docLink`Add an ${"[errata]"} URL to your ${"[respecConfig]"}.`; + showError(msg, name, { hint }); } - conf.updateableRec = sotd.classList.contains("updateable-rec"); - const revisionTypes = [ - "addition", - "correction", - "proposed-addition", - "proposed-correction", - ]; - if (conf.isRec && conf.revisionTypes?.length > 0) { - if (conf.revisionTypes.some(x => !revisionTypes.includes(x))) { - const unknownRevisionTypes = conf.revisionTypes.filter( - x => !revisionTypes.includes(x) - ); - const msg = docLink`${"[specStatus]"} is "REC" with unknown ${"[revisionTypes]"}: '${codedJoinOr( - unknownRevisionTypes - )}'.`; - const hint = docLink`The valid values for ${"[revisionTypes]"} are: ${codedJoinOr( - revisionTypes - )}.`; - showError(msg, name, { hint }); - } - if ( - (conf.revisionTypes.includes("proposed-addition") || - conf.revisionTypes.includes("addition")) && - !conf.updateableRec - ) { - const msg = docLink`${"[specStatus]"} is "REC" with proposed additions but the Recommendation is not marked as allowing new features.`; - showError(msg, name); - } + if (!isUpdatableRec && (hasAdditions || hasCorrections)) { + const msg = docLink`${"[specStatus]"} is "REC" with proposed additions but the Recommendation is not marked as allowing new features.`; + showError(msg, name); } if ( - conf.specStatus === "REC" && - conf.updateableRec && - conf.revisionTypes && - conf.revisionTypes.length > 0 && - ["proposed-addition", "proposed-correction"].some(type => - conf.revisionTypes.includes(type) - ) && + conf.isRec && + isUpdatableRec && + (hasProposedAdditions || hasProposedCorrections) && !conf.revisedRecEnd ) { const msg = docLink`${"[specStatus]"} is "REC" with proposed corrections or additions but no ${"[revisedRecEnd]"} is specified in the ${"[respecConfig]"}.`; diff --git a/src/w3c/templates/sotd.js b/src/w3c/templates/sotd.js index e194936b18..17b0889200 100644 --- a/src/w3c/templates/sotd.js +++ b/src/w3c/templates/sotd.js @@ -22,7 +22,10 @@ const localizationStrings = { zh: { sotd: "关于本文档", // eslint-disable-next-line prettier/prettier - status_at_publication: html`本章节描述了本文档的发布状态。W3C的文档列表和最新版本可通过W3C技术报告索引访问。`, + status_at_publication: html`本章节描述了本文档的发布状态。W3C的文档列表和最新版本可通过W3C技术报告索引访问。`, }, ja: { sotd: "この文書の位置付け", @@ -145,6 +148,7 @@ function renderIsNoTrack(conf, opts) { } function renderNotRec(conf) { + const updatableRec = document.querySelector("#sotd.updateable-rec"); let statusExplanation = null; let reviewPolicy = null; let endorsement = html`Publication as ${prefix(conf.textStatus)} does not @@ -153,7 +157,7 @@ function renderNotRec(conf) { This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress. - ${conf.updateableRec + ${updatableRec ? html`Future updates to this specification may incorporate new features.` : ""} @@ -224,7 +228,7 @@ function renderNotRec(conf) { >royalty-free licensing for implementations.`; - updatePolicy = html`${conf.updateableRec + updatePolicy = html`${updatableRec ? html`Future updates to this specification may incorporate new features.` : ""}`; @@ -268,11 +272,12 @@ function renderNotRec(conf) { } function renderIsRec(conf) { - const { updateableRec, revisionTypes = [], revisedRecEnd } = conf; + const { revisedRecEnd } = conf; + const updatableRec = document.querySelector("#sotd.updateable-rec"); let reviewTarget = ""; - if (revisionTypes.includes("proposed-addition")) { + if (document.querySelector(".proposed-addition")) { reviewTarget = "additions"; - } else if (revisionTypes.includes("proposed-correction")) { + } else if (document.querySelector(".proposed-correction")) { reviewTarget = "corrections"; } return html` @@ -290,27 +295,27 @@ function renderIsRec(conf) { >royalty-free licensing for implementations. - ${updateableRec + ${updatableRec ? html`Future updates to this Recommendation may incorporate new features.` : ""}

- ${revisionTypes.includes("addition") + ${document.querySelector(".addition") ? html`

Candidate additions are marked in the document.

` : ""} - ${revisionTypes.includes("correction") + ${document.querySelector(".correction") ? html`

Candidate corrections are marked in the document.

` : ""} - ${revisionTypes.includes("proposed-addition") + ${document.querySelector(".proposed-addition") ? html`

Proposed additions are marked in the document.

` : ""} - ${revisionTypes.includes("proposed-correction") + ${document.querySelector(".proposed-correction") ? html`

Proposed corrections are marked in the document.

` @@ -453,14 +458,19 @@ function linkToWorkingGroup(conf) { return; } let changes = null; - if (conf.isRec && conf.revisionTypes && conf.revisionTypes.length) { - const pa = conf.revisionTypes.includes("proposed-addition"); - const pc = conf.revisionTypes.includes("proposed-correction"); - const ca = conf.revisionTypes.includes("addition"); - const cc = conf.revisionTypes.includes("correction"); - if ((pa && pc) || (ca && cc)) { + const proposedAdditions = document.querySelector(".proposed-addition"); + const proposedCorrections = document.querySelector(".proposed-correction"); + const additions = document.querySelector(".addition"); + const corrections = document.querySelector(".correction"); + const hasRevisions = + proposedAdditions || proposedCorrections || additions || corrections; + if (conf.isRec && hasRevisions) { + if ( + (proposedAdditions && proposedCorrections) || + (additions && corrections) + ) { changes = html`It includes - ${pa + ${proposedAdditions ? html` proposed amendments` @@ -469,9 +479,9 @@ function linkToWorkingGroup(conf) { >`}, introducing substantive changes and new features since the previous Recommendation.`; - } else if (pa || ca) { + } else if (proposedAdditions || additions) { changes = html`It includes - ${pa + ${proposedAdditions ? html` proposed additions` @@ -479,9 +489,9 @@ function linkToWorkingGroup(conf) { candidate additions`}, introducing new features since the previous Recommendation.`; - } else if (pc || cc) { + } else if (proposedCorrections || corrections) { changes = html`It includes - ${pc + ${proposedCorrections ? html` proposed corrections`