Skip to content

Commit 743c7a3

Browse files
committed
KDL support for removals
1 parent f915ac0 commit 743c7a3

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
enum AuthenticatorTransport {
2+
smart-card // WebKit only as of 2023-05
3+
}

inputfiles/removedTypes.jsonc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
},
1414
"enums": {
1515
"enum": {
16-
"AuthenticatorTransport": {
17-
"value": ["smart-card"] // WebKit only as of 2023-05
18-
},
1916
"ConnectionType": {
2017
"value": ["wimax"]
2118
},

src/build.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ async function emitDom() {
8989

9090
const overriddenItems = await readInputJSON("overridingTypes.jsonc");
9191
const addedItems = await readInputJSON("addedTypes.jsonc");
92-
const patches = await readPatches();
92+
const patches = await readPatches("patches");
93+
const removals = await readPatches("removals");
9394
const comments = await readInputJSON("comments.json");
9495
const documentationFromMDN = await generateDescriptions();
9596
const removedItems = await readInputJSON("removedTypes.jsonc");
@@ -204,6 +205,7 @@ async function emitDom() {
204205
webidl = merge(webidl, getRemovalData(webidl));
205206
webidl = merge(webidl, getDocsData(webidl));
206207
webidl = prune(webidl, removedItems);
208+
webidl = prune(webidl, removals);
207209
webidl = merge(webidl, addedItems);
208210
webidl = merge(webidl, overriddenItems);
209211
webidl = merge(webidl, patches);

src/build/patches.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,37 @@ export async function readPatch(fileUrl: URL): Promise<any> {
375375
return parseKDL(text);
376376
}
377377

378+
function removeNamesDeep(obj: unknown): unknown {
379+
if (Array.isArray(obj)) {
380+
return obj.map(removeNamesDeep);
381+
} else if (obj && typeof obj === "object") {
382+
const newObj: { [key: string]: unknown } = {};
383+
for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {
384+
if (key !== "name") {
385+
newObj[key] = removeNamesDeep(value);
386+
}
387+
}
388+
return newObj;
389+
}
390+
return obj;
391+
}
392+
378393
/**
379394
* Read, parse, and merge all KDL files under the input folder.
380395
*/
381-
export default async function readPatches(): Promise<any> {
382-
const patchDirectory = new URL("../../inputfiles/patches/", import.meta.url);
396+
export default async function readPatches(
397+
folder: "patches" | "removals",
398+
): Promise<any> {
399+
const patchDirectory = new URL(
400+
`../../inputfiles/${folder}/`,
401+
import.meta.url,
402+
);
383403
const fileUrls = await getAllFileURLs(patchDirectory);
384404

385405
const parsedContents = await Promise.all(fileUrls.map(readPatch));
386-
387-
return parsedContents.reduce((acc, current) => merge(acc, current), {});
406+
const res = parsedContents.reduce((acc, current) => merge(acc, current), {});
407+
if (folder == "removals") {
408+
return removeNamesDeep(res);
409+
}
410+
return res;
388411
}

0 commit comments

Comments
 (0)