From 55fa150063ad76aa48e2bea1739759d11730059a Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Thu, 1 Aug 2024 16:51:18 -0700 Subject: [PATCH] Add escape hatch --- docs/core_docs/scripts/quarto-build.js | 18 ++++++++++++++++-- docs/core_docs/scripts/validate_notebook.ts | 6 +++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/core_docs/scripts/quarto-build.js b/docs/core_docs/scripts/quarto-build.js index e502be91dd7d..6a92e5819456 100644 --- a/docs/core_docs/scripts/quarto-build.js +++ b/docs/core_docs/scripts/quarto-build.js @@ -3,6 +3,7 @@ const { glob } = require("glob"); const { execSync } = require("node:child_process"); const IGNORED_CELL_REGEX = /```\w*?\n\/\/ ?@lc-docs-hide-cell\n[\s\S]*?```/g; +const LC_TS_IGNORE_REGEX = /\/\/ ?@lc-ts-ignore\n/g; async function main() { const allIpynb = await glob("./docs/**/*.ipynb"); @@ -20,8 +21,21 @@ async function main() { for (const renamedFilepath of allRenames) { if (fs.existsSync(renamedFilepath)) { let content = fs.readFileSync(renamedFilepath).toString(); - if (content.match(IGNORED_CELL_REGEX)) { - content = content.replace(IGNORED_CELL_REGEX, ""); + if (renamedFilepath.includes("blah")) { + console.log( + content, + content.match(IGNORED_CELL_REGEX), + content.match(LC_TS_IGNORE_REGEX), + content.match(IGNORED_CELL_REGEX) || content.match(LC_TS_IGNORE_REGEX) + ); + } + if ( + content.match(IGNORED_CELL_REGEX) || + content.match(LC_TS_IGNORE_REGEX) + ) { + content = content + .replace(IGNORED_CELL_REGEX, "") + .replace(LC_TS_IGNORE_REGEX, ""); fs.writeFileSync(renamedFilepath, content); } } diff --git a/docs/core_docs/scripts/validate_notebook.ts b/docs/core_docs/scripts/validate_notebook.ts index 7afdd366cc4a..b1f75dea3aff 100644 --- a/docs/core_docs/scripts/validate_notebook.ts +++ b/docs/core_docs/scripts/validate_notebook.ts @@ -8,8 +8,12 @@ export function extract(filepath: string) { const sourceFile = project.createSourceFile("temp.ts", ""); cells.forEach((cell: Record) => { + // console.log(cell.source.includes("// @lc-skip-validation")) + const source = cell.source + .join("") + .replace(/\/\/ ?@lc-ts-ignore/g, "// @ts-ignore"); if (cell.cell_type === "code") { - sourceFile.addStatements(cell.source.join("")); + sourceFile.addStatements(source); } });