diff --git a/config/allowed-code-link-text.txt b/config/allowed-code-link-text.txt index 4f4f553..c8dc39b 100644 --- a/config/allowed-code-link-text.txt +++ b/config/allowed-code-link-text.txt @@ -63,6 +63,7 @@ contain-intrinsic-size: auto none cubic-bezier(0, 0, 1, 1) cubic-bezier(p1, p2, p3, p4) delete obj.x +for each...in import ... with { type: "css" } instanceof Array minmax(auto, max-content) diff --git a/config/no-bcd.txt b/config/no-bcd.txt new file mode 100644 index 0000000..78f2ed8 --- /dev/null +++ b/config/no-bcd.txt @@ -0,0 +1,78 @@ + This file contains BCD keys that can be derived from content pages, + but are not actually tracked in BCD usually because support is not interesting + or browser support is irrelevant. + Use two-space indent for comments. + +html.global_attributes.itemid +html.global_attributes.itemprop +html.global_attributes.itemref +html.global_attributes.itemscope +html.global_attributes.itemtype + +http.headers.Accept-Charset +http.headers.Accept-Patch +http.headers.Accept-Post + + https://github.com/mdn/browser-compat-data/pull/23529 +http.status.100 +http.status.101 +http.status.102 +http.status.200 +http.status.201 +http.status.202 +http.status.203 +http.status.204 +http.status.205 +http.status.206 +http.status.207 +http.status.208 +http.status.226 +http.status.300 +http.status.301 +http.status.302 +http.status.303 +http.status.304 +http.status.307 +http.status.400 +http.status.401 +http.status.402 +http.status.403 +http.status.404 +http.status.405 +http.status.406 +http.status.407 +http.status.408 +http.status.409 +http.status.410 +http.status.411 +http.status.412 +http.status.413 +http.status.414 +http.status.415 +http.status.416 +http.status.417 +http.status.418 +http.status.421 +http.status.422 +http.status.423 +http.status.424 +http.status.426 +http.status.428 +http.status.429 +http.status.431 +http.status.451 +http.status.500 +http.status.501 +http.status.502 +http.status.503 +http.status.504 +http.status.505 +http.status.506 +http.status.507 +http.status.508 +http.status.510 +http.status.511 + + https://github.com/mdn/browser-compat-data/pull/23774 +html.manifest.categories +html.manifest.screenshots diff --git a/src/server/check-bcd-matching.ts b/src/server/check-bcd-matching.ts index 58f77e8..c26f74d 100644 --- a/src/server/check-bcd-matching.ts +++ b/src/server/check-bcd-matching.ts @@ -1,12 +1,14 @@ import nodes from "../../data/nodes.json" with { type: "json" }; import bcdData from "@mdn/browser-compat-data" with { type: "json" }; import { readConfig, configHas } from "./config.js"; -import { getBCD } from "./utils.js"; +import { getBCD, readConfig } from "./utils.js"; const dictionaries = new Map( (await readConfig("dictionaries.txt")).map((x) => [x, false]), ); +const noBCD = new Map((await readConfig("no-bcd.txt")).map((x) => [x, false])); + function htmlAttrToBCD(attrName: string, elemName: string) { if (attrName === "data-*") { attrName = "data_attributes"; @@ -166,7 +168,14 @@ function expectedBCD(node: any): "Unexpected page type" | "ignore" | string[] { return [`html.elements.${elemName}`]; } // Mozilla/Add-ons/WebExtensions/ - case "webextension-api-function": + case "webextension-api-function": { + const match = node.id.match( + /^\/en-US\/docs\/Mozilla\/Add-ons\/WebExtensions\/Content_scripts\/([^/]+)$/, + ); + if (match) { + return [`webextensions.content_scripts.${match[1]}`]; + } + } case "webextension-api-event": case "webextension-api-property": case "webextension-api-type": { @@ -221,11 +230,33 @@ function expectedBCD(node: any): "Unexpected page type" | "ignore" | string[] { case "webgl-extension-method": { const match = node.id.match(/^\/en-US\/docs\/Web\/API\/(.+)$/); if (!match) return "Unexpected page type"; - const path = dictionaryToBCD( - match[1] - .replaceAll("/", ".") - .replace(/^CSS\.factory_functions_static$/, "CSS"), - ); + switch (match[1]) { + case "CSS/factory_functions_static": + return [`api.CSS`]; + // These pages coalesce multiple methods into one, and only display one BCD + case "WebGL2RenderingContext/clearBuffer": + return [`api.WebGL2RenderingContext.clearBufferiv`]; + case "WebGL2RenderingContext/samplerParameter": + return [`api.WebGL2RenderingContext.samplerParameteri`]; + case "WebGL2RenderingContext/uniform": + return [`api.WebGL2RenderingContext.uniform1ui`]; + case "WebGL2RenderingContext/uniformMatrix": + return [`api.WebGL2RenderingContext.uniformMatrix2fv`]; + case "WebGL2RenderingContext/vertexAttribI": + return [`api.WebGL2RenderingContext.vertexAttribI4i`]; + case "WebGLRenderingContext/texParameter": + return [ + `api.WebGLRenderingContext.texParameterf`, + `api.WebGLRenderingContext.texParameteri`, + ]; + case "WebGLRenderingContext/uniform": + return [`api.WebGLRenderingContext.uniform1f`]; + case "WebGLRenderingContext/uniformMatrix": + return [`api.WebGLRenderingContext.uniformMatrix2fv`]; + case "WebGLRenderingContext/vertexAttrib": + return [`api.WebGLRenderingContext.vertexAttrib1f`]; + } + const path = dictionaryToBCD(match[1].replaceAll("/", ".")); if (configHas(dictionaries, path.split(".")[0])) return []; return [`api.${path}`]; } @@ -521,6 +552,7 @@ export function checkBCDMatching( } const expectedExisting = expected.filter((x) => getBCD(bcdData, x)); if (!expectedExisting.length && expected.length) { + if (configHas(noBCD, node.id)) continue; report(node, "Not in BCD", expected.join("\n")); continue; } @@ -542,4 +574,7 @@ export function postCheckBCDMatching() { for (const [name, used] of dictionaries) { if (!used) console.warn(name, "is no longer documented"); } + for (const [name, used] of noBCD) { + if (!used) console.warn(name, "is no longer documented"); + } } diff --git a/src/server/create-graph.ts b/src/server/create-graph.ts index fa881ea..0b9c0c1 100644 --- a/src/server/create-graph.ts +++ b/src/server/create-graph.ts @@ -386,7 +386,7 @@ for (const node of nodes) { pageToSidebarId.set(node.id, processedSidebars.get(normalizedHTML)!.id); continue; } - const $ = load(sidebarHTML); + const $ = load(normalizedHTML); const links = $("a") .map((i, a) => ({ href: $(a).attr("href")?.replace(/\/$/, ""),