Skip to content

Commit

Permalink
Add escape hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Aug 1, 2024
1 parent b3f4c35 commit 55fa150
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 16 additions & 2 deletions docs/core_docs/scripts/quarto-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
}
}
Expand Down
6 changes: 5 additions & 1 deletion docs/core_docs/scripts/validate_notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ export function extract(filepath: string) {
const sourceFile = project.createSourceFile("temp.ts", "");

cells.forEach((cell: Record<string, any>) => {
// 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);
}
});

Expand Down

0 comments on commit 55fa150

Please sign in to comment.