diff --git a/.sidebarignore b/.sidebarignore new file mode 100644 index 00000000..d6ae3554 --- /dev/null +++ b/.sidebarignore @@ -0,0 +1,4 @@ +policies/validate-json-schema-inbound +policies/api-key-auth-inbound +sample-apis +conferences/conference-prize-terms \ No newline at end of file diff --git a/scripts/find-unlinked-docs.mjs b/scripts/find-unlinked-docs.mjs index 4ed1b4d3..6a9d9857 100644 --- a/scripts/find-unlinked-docs.mjs +++ b/scripts/find-unlinked-docs.mjs @@ -1,6 +1,10 @@ import fs from "fs"; import { glob } from "glob"; +const ignoredDocs = await fs.promises + .readFile(".sidebarignore", "utf8") + .then((content) => content.split("\n")); + const sidebar = await fs.promises .readFile("./sidebar.json", "utf8") .then(JSON.parse); @@ -20,6 +24,8 @@ function listDocs(items) { allDocs.push(item); } else if ("items" in item && typeof item.items === "object") { listDocs(item.items); + } else if ("type" in item && item.type === "doc") { + allDocs.push(item.id); } if (typeof item === "object" && "link" in item) { if (typeof item.link === "string") { @@ -37,11 +43,20 @@ function listDocs(items) { listDocs(sidebar); -const uniqueDocs = [...new Set(docs), ...new Set(policies)]; +const uniqueDocs = [...new Set(docs), ...new Set(policies)].filter( + (doc) => !ignoredDocs.includes(doc), +); const unlinkedDocs = uniqueDocs.filter((doc) => !allDocs.includes(doc)); -console.log(unlinkedDocs); -console.log( - `Total Docs: ${uniqueDocs.length}, Unlinked Docs: ${unlinkedDocs.length}`, +console.group(); +console.log("The following docs are not linked to in the sidebar:"); +console.group(); +for (const doc of unlinkedDocs) { + console.log(doc); +} +console.groupEnd(); + +console.warn( + `There are ${unlinkedDocs.length} that are not linked to in the sidebar.`, );