Skip to content

Commit

Permalink
docs[patch]: Add escape hatch (#6334)
Browse files Browse the repository at this point in the history
* Add escape hatch

* Remove logs
  • Loading branch information
jacoblee93 authored Aug 2, 2024
1 parent 9578e55 commit e396174
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 8 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,13 @@ 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 (
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
5 changes: 4 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,11 @@ export function extract(filepath: string) {
const sourceFile = project.createSourceFile("temp.ts", "");

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

Please sign in to comment.