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

Send ReSpec specs to spec-generator before looking for status #1000

Merged
merged 1 commit into from
Jul 12, 2023
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
21 changes: 3 additions & 18 deletions specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,8 @@
]
}
},
{
"url": "https://screen-share.github.io/captured-mouse-events/",
"nightly": {
"status": "Draft Community Group Report"
}
},
{
"url": "https://screen-share.github.io/element-capture/",
"nightly": {
"status": "Draft Community Group Report"
}
},
"https://screen-share.github.io/captured-mouse-events/",
"https://screen-share.github.io/element-capture/",
{
"url": "https://sourcemaps.info/spec.html",
"shortname": "sourcemap",
Expand Down Expand Up @@ -402,12 +392,7 @@
"https://wicg.github.io/datacue/",
"https://wicg.github.io/deprecation-reporting/",
"https://wicg.github.io/digital-goods/",
{
"url": "https://wicg.github.io/direct-sockets/",
"nightly": {
"status": "Unofficial Proposal Draft"
}
},
"https://wicg.github.io/direct-sockets/",
"https://wicg.github.io/document-picture-in-picture/",
"https://wicg.github.io/document-policy/",
"https://wicg.github.io/element-timing/",
Expand Down
15 changes: 13 additions & 2 deletions src/fetch-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ async function fetchInfoFromSpecs(specs, options) {
}
}

if (dom.window.document.head.querySelector("script[src*='respec']")) {
// Non-generated ReSpec spec, let's get the generated version from
// spec-generator
dom = await JSDOMFromURL(`https://labs.w3.org/spec-generator/?type=respec&url=${encodeURIComponent(url)}`);
}

// Extract first heading when set
let title = dom.window.document.querySelector("h1");
if (!title) {
Expand Down Expand Up @@ -289,10 +295,15 @@ async function fetchInfoFromSpecs(specs, options) {
".head #subtitle", // WHATWG specs
".head #living-standard" // HTML spec
].join(","));
const match = subtitle?.textContent.match(/^\s*(.*?)(,| — Last Updated)? \d{1,2} \w+ \d{4}\s*$/);
const status = (match ? match[1] : "Editor's Draft")
const match = subtitle?.textContent.match(/^\s*(.+?)(,| — Last Updated)?\s+\d{1,2} \w+ \d{4}\s*$/);
let status = (match ? match[1] : "Editor's Draft")
.replace(/’/g, "'") // Bikeshed generates curly quotes
.replace(/^W3C /, ""); // Once every full moon, a "W3C " prefix gets added
// And once every other full moon, spec has a weird status
// (e.g., https://privacycg.github.io/gpc-spec/)
if (status === "Proposal" || status === "Unofficial Draft") {
status = "Unofficial Proposal Draft";
}
return {
nightly: { url, status },
title
Expand Down
6 changes: 3 additions & 3 deletions test/fetch-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ describe("fetch-info module (without W3C API key)", function () {

it("extracts spec info from a Respec spec when needed", async () => {
const spec = {
url: "https://w3c.github.io/respec/examples/tpac_2019.html",
url: "https://screen-share.github.io/element-capture/",
shortname: "respec"
};
const info = await fetchInfo([spec]);
assert.ok(info[spec.shortname]);
assert.equal(info[spec.shortname].source, "spec");
assert.equal(info[spec.shortname].nightly.url, spec.url);
assert.equal(info[spec.shortname].nightly.status, "Editor's Draft");
assert.equal(info[spec.shortname].title, "TPAC 2019 - New Features");
assert.equal(info[spec.shortname].nightly.status, "Draft Community Group Report");
assert.equal(info[spec.shortname].title, "Element Capture");
});

it("extracts right title from an ECMAScript proposal spec", async () => {
Expand Down