Skip to content

Commit

Permalink
fix(w3c): remove revisionTypes config, use querySelector instead (#4737)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored Jun 17, 2024
1 parent 2d6b9ff commit 662fb7d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 69 deletions.
70 changes: 23 additions & 47 deletions src/w3c/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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]"}.`;
Expand Down
54 changes: 32 additions & 22 deletions src/w3c/templates/sotd.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ const localizationStrings = {
zh: {
sotd: "关于本文档",
// eslint-disable-next-line prettier/prettier
status_at_publication: html`本章节描述了本文档的发布状态。W3C的文档列表和最新版本可通过<a href="https://www.w3.org/TR/">W3C技术报告</a>索引访问。`,
status_at_publication: html`本章节描述了本文档的发布状态。W3C的文档列表和最新版本可通过<a
href="https://www.w3.org/TR/"
>W3C技术报告</a
>索引访问。`,
},
ja: {
sotd: "この文書の位置付け",
Expand Down Expand Up @@ -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
Expand All @@ -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
<a href="${processLink}#allow-new-features">new features</a>.`
: ""}
Expand Down Expand Up @@ -224,7 +228,7 @@ function renderNotRec(conf) {
>royalty-free licensing</a
>
for implementations.`;
updatePolicy = html`${conf.updateableRec
updatePolicy = html`${updatableRec
? html`Future updates to this specification may incorporate
<a href="${processLink}#allow-new-features">new features</a>.`
: ""}`;
Expand Down Expand Up @@ -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`
Expand All @@ -290,27 +295,27 @@ function renderIsRec(conf) {
>royalty-free licensing</a
>
for implementations.
${updateableRec
${updatableRec
? html`Future updates to this Recommendation may incorporate
<a href="${processLink}#allow-new-features">new features</a>.`
: ""}
</p>
${revisionTypes.includes("addition")
${document.querySelector(".addition")
? html`<p class="addition">
Candidate additions are marked in the document.
</p>`
: ""}
${revisionTypes.includes("correction")
${document.querySelector(".correction")
? html`<p class="correction">
Candidate corrections are marked in the document.
</p>`
: ""}
${revisionTypes.includes("proposed-addition")
${document.querySelector(".proposed-addition")
? html`<p class="addition proposed">
Proposed additions are marked in the document.
</p>`
: ""}
${revisionTypes.includes("proposed-correction")
${document.querySelector(".proposed-correction")
? html`<p class="correction proposed">
Proposed corrections are marked in the document.
</p>`
Expand Down Expand Up @@ -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`<a href="${processLink}#proposed-amendments">
proposed amendments</a
>`
Expand All @@ -469,19 +479,19 @@ 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`<a href="${processLink}#proposed-addition">
proposed additions</a
>`
: html`<a href="${processLink}#candidate-addition">
candidate additions</a
>`},
introducing new features since the previous Recommendation.`;
} else if (pc || cc) {
} else if (proposedCorrections || corrections) {
changes = html`It includes
${pc
${proposedCorrections
? html`<a href="${processLink}#proposed-correction">
proposed corrections</a
>`
Expand Down

0 comments on commit 662fb7d

Please sign in to comment.