Created
September 10, 2021 08:09
-
-
Save dontcallmedom/4ce7183bd1ac9d6bf79ae11da12f1898 to your computer and use it in GitHub Desktop.
node.js script to generate the list of MDN interface data from webref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs").promises; | |
// @@@ download latest tagged version of @webref/idl repo | |
const webrefPath = "../../webref/ed/"; | |
(async function () { | |
const interfaceData = {}; | |
const index = JSON.parse(await fs.readFile(webrefPath + "idlnames.json", "utf-8")); | |
(await Promise.all( | |
Object.entries(index) | |
.sort(([k1, v1], [k2, v2]) => k1.localeCompare(k2)) | |
.map(async ([,{parsed: jsonIdlPath}]) => await fs.readFile(webrefPath + jsonIdlPath, "utf-8")) | |
)).forEach(jsonData => { | |
const jsonIdl = JSON.parse(jsonData); | |
if (jsonIdl.type === "interface" || jsonIdl.type === "interface mixin") { | |
interfaceData[jsonIdl.name] = { | |
inh: jsonIdl.inheritance?.name || "", | |
impl: jsonIdl.includes.map(i => i.name) | |
}; | |
} | |
}); | |
console.log(JSON.stringify(interfaceData, null, 2)); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment