Skip to content

Commit

Permalink
Add IETF specs used in MDN
Browse files Browse the repository at this point in the history
close #280
  • Loading branch information
dontcallmedom committed Jul 2, 2021
1 parent d3101bc commit 451ed9a
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 3 deletions.
97 changes: 97 additions & 0 deletions specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,103 @@
}
},
"https://console.spec.whatwg.org/",
{
"url": "https://datatracker.ietf.org/doc/html/rfc6265",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc6265.xml"
}
},
{
"url": "https://datatracker.ietf.org/doc/html/rfc6454",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc6454.xml"
},
"groups": [
{
"name": "Web Security Working Group",
"url": "https://datatracker.ietf.org/group/websec/"
}
]
},
{
"url": "https://datatracker.ietf.org/doc/html/rfc7230",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc7230.xml"
}
},
{
"url": "https://datatracker.ietf.org/doc/html/rfc7231",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc7231.xml"
}
},
{
"url": "https://datatracker.ietf.org/doc/html/rfc7232",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc7232.xml"
}
},
{
"url": "https://datatracker.ietf.org/doc/html/rfc7233",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc7233.xml"
}
},
{
"url": "https://datatracker.ietf.org/doc/html/rfc7234",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc7234.xml"
}
},
{
"url": "https://datatracker.ietf.org/doc/html/rfc7235",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc7235.xml"
}
},
{
"url": "https://datatracker.ietf.org/doc/html/rfc7239",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc7239.xml"
}
},
{
"url": "https://datatracker.ietf.org/doc/html/rfc7469",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc7469.xml"
}
},
{
"url": "https://datatracker.ietf.org/doc/html/rfc7538",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc7538.xml"
}
},
{
"url": "https://datatracker.ietf.org/doc/html/rfc7540",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc7540.xml"
}
},
{
"url": "https://datatracker.ietf.org/doc/html/rfc8470",
"nightly": {
"repository": "https://github.com/httpwg/httpwg.github.io",
"sourcePath": "specs/rfc8470.xml"
}
},
"https://dom.spec.whatwg.org/",
"https://drafts.css-houdini.org/css-typed-om-2/ delta",
"https://drafts.css-houdini.org/font-metrics-api-1/",
Expand Down
5 changes: 3 additions & 2 deletions src/build-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* Script that compiles and returns the final list of specs from the
* "specs.json" input file.
*
* The script will extract the W3C API key it needs from a "config.json" file
* in the root folder, which must exist and contain a "w3cApiKey" key.
* The script will extract the W3C API key and the github token it needs
* from a "config.json" file in the root folder
* which must exist and contain "w3cApiKey" and "githubToken" keys.
*/

const fs = require("fs").promises;
Expand Down
6 changes: 6 additions & 0 deletions src/compute-shortname.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ function computeShortname(url) {
return "svg-" + svg[1];
}

// Handle IETF RFCs
const rfcs = url.match(/\/datatracker\.ietf\.org\/doc\/html\/(rfc[0-9]+)/);
if (rfcs) {
return rfcs[1];
}

// Return name when one was given
if (!url.match(/\//)) {
return url;
Expand Down
25 changes: 24 additions & 1 deletion src/fetch-groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@ module.exports = async function (specs, options) {
for (const spec of specs) {
const info = parseSpecUrl(spec.url);
if (!info) {
// No general rule to identify repos and groups for IETF specs
// instead, fetching info on groups from https://www.rfc-editor.org/in-notes/rfcXXX.json
if (spec.url.match(/ietf\.org/)) {
spec.organization = spec.organization ?? "IETF";
if (spec.groups) continue;
const rfcNumber = spec.url.slice(spec.url.lastIndexOf('/') + 1);
const rfcJSON = await fetchJSON(`https://www.rfc-editor.org/in-notes/${rfcNumber}.json`);
const wgName = rfcJSON.source;
// draft-ietf-websec-origin-06 → websec
// per https://www.ietf.org/standards/ids/guidelines/#7
// not clear there is anything forbidding hyphens in WG acronyms though
// https://datatracker.ietf.org/doc/html/rfc2418#section-2.2
const wgId = rfcJSON.draft.split('-')[2];
if (wgName && wgId) {
spec.groups = [{
name: `${wgName} Working Group`,
url: `https://datatracker.ietf.org/wg/${wgId}/`
}];
continue;
} else {
throw new Error(`Could not identify IETF group producing ${spec.url}`);
}
}
throw new Error(`Cannot extract any useful info from ${spec.url}`);
}

Expand Down Expand Up @@ -153,4 +176,4 @@ module.exports = async function (specs, options) {
}

return specs;
};
};

0 comments on commit 451ed9a

Please sign in to comment.