Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make multipage flag specifically target release and/or nightly #1345

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ automatically is not the expected one.
- `forceCurrent`: a boolean flag to tell the code that the spec should be seen
as the current spec in the series. The property must only be set when value is
`true`.
- `multipage`: a boolean flag to identify the spec as a multipage spec. This
- `multipage`: a flag to identify the spec as a multipage spec. This
instructs the code to extract the list of pages from the index page and fill
out the `release.pages` and `nightly.pages` properties in the list.
out the `release.pages` and `nightly.pages` properties in the list. Possible
values for the flag: `"nightly"` to signal that the nightly version is
multipage, `"release"` to signal that the release version if multipage, or
`"all"` to signal that both the nightly and release versions are multipage.
- `categories`: an array that is treated as incremental update to adjust the
list of [`categories`](README.md#categories) that the spec belongs to. Values
may be one of `"reset"` to start from an empty list, `"+browser"` to add
Expand Down
7 changes: 6 additions & 1 deletion schema/specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
"obsoletedBy": { "$ref": "definitions.json#/$defs/obsoletedBy" },
"formerNames": { "$ref": "definitions.json#/$defs/formerNames" },
"forceCurrent": { "type": "boolean" },
"multipage": { "type": "boolean" }
"multipage": {
"type": "string",
"enum": [
"all", "release", "nightly"
]
}
},
"required": ["url"],
"additionalProperties": false
Expand Down
10 changes: 5 additions & 5 deletions specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"https://fullscreen.spec.whatwg.org/",
{
"url": "https://html.spec.whatwg.org/multipage/",
"multipage": true,
"multipage": "nightly",
"nightly": {
"sourcePath": "source"
}
Expand Down Expand Up @@ -303,7 +303,7 @@
"https://svgwg.org/specs/animations/",
{
"url": "https://tc39.es/ecma262/multipage/",
"multipage": true,
"multipage": "nightly",
"shortname": "ecmascript",
"shortTitle": "ECMAScript",
"tests": {
Expand Down Expand Up @@ -1065,14 +1065,14 @@
"url": "https://www.w3.org/TR/CSS21/",
"shortname": "CSS2",
"seriesVersion": "2.1",
"multipage": true,
"multipage": "all",
"nightly": {
"url": "https://www.w3.org/TR/CSS21/"
}
},
{
"url": "https://www.w3.org/TR/CSS22/",
"multipage": true,
"multipage": "release",
"nightly": {
"sourcePath": "css2/Overview.bs"
}
Expand Down Expand Up @@ -1495,7 +1495,7 @@
"https://www.w3.org/TR/svg-strokes/",
{
"url": "https://www.w3.org/TR/SVG11/",
"multipage": true,
"multipage": "all",
"nightly": {
"url": "https://www.w3.org/TR/SVG11/"
}
Expand Down
29 changes: 15 additions & 14 deletions src/build-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async function runSkeleton(specs, { log }) {
res.forceCurrent = true;
}
else if (parts[1] === "multipage") {
res.multipage = true;
res.multipage = "all";
}
return res;
}
Expand Down Expand Up @@ -320,22 +320,23 @@ async function runShortTitle(index) {

async function runPages(index) {
const browser = await puppeteer.launch();
return Promise.all(
index.map(async spec => {
if (spec.multipage) {
if (spec.release) {
spec.release.pages = await extractPages(spec.release.url, browser);
}
if (spec.nightly) {
spec.nightly.pages = await extractPages(spec.nightly.url, browser);
}
try {
for (const spec of index) {
if (spec.release && (spec.multipage === "all" || spec.multipage === "release")) {
spec.release.pages = await extractPages(spec.release.url, browser);
}
if (spec.nightly && (spec.multipage === "all" || spec.multipage === "nightly")) {
spec.nightly.pages = await extractPages(spec.nightly.url, browser);
}
if (spec.hasOwnProperty("multipage")) {
delete spec.multipage;
}
return spec;
})
).finally(async _ => {
}
}
finally {
await browser.close();
});
}
return index;
}


Expand Down
4 changes: 2 additions & 2 deletions src/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function shortenDefinition(spec) {
return `${spec.url} current`;
}
else if (Object.keys(short).length === 2 &&
spec.multipage) {
spec.multipage === "all") {
return `${spec.url} multipage`;
}
else {
Expand All @@ -56,7 +56,7 @@ function lintStr(specsStr) {
url: new URL(spec.split(" ")[0]).toString(),
seriesComposition: (spec.split(' ')[1] === "delta") ? "delta" : "full",
forceCurrent: (spec.split(' ')[1] === "current"),
multipage: (spec.split(' ')[1] === "multipage"),
multipage: (spec.split(' ')[1] === "multipage") ? "all" : undefined
} :
Object.assign({}, spec, { url: new URL(spec.url).toString() }))
.filter((spec, idx, list) =>
Expand Down
6 changes: 3 additions & 3 deletions test/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe("Linter", () => {

it("lints an object with only a URL and a multipage flag to a string", () => {
const specs = [
{ "url": "https://www.w3.org/TR/spec-1/", "multipage": true }
{ "url": "https://www.w3.org/TR/spec-1/", "multipage": "all" }
];
assert.equal(lintStr(toStr(specs)), toStr([
"https://www.w3.org/TR/spec-1/ multipage"
Expand All @@ -123,9 +123,9 @@ describe("Linter", () => {
]));
});

it("lints an object with a multipage flag set to false", () => {
it("lints an object with a multipage flag set to null", () => {
const specs = [
{ "url": "https://www.w3.org/TR/spec/", "multipage": false }
{ "url": "https://www.w3.org/TR/spec/", "multipage": null }
];
assert.equal(lintStr(toStr(specs)), toStr([
"https://www.w3.org/TR/spec/"
Expand Down