2023-07-12 23:10:52 +02:00
|
|
|
const fs = require("fs");
|
|
|
|
|
|
|
|
const files = [];
|
2023-08-01 06:59:33 +02:00
|
|
|
const docRoot = "./src/Documentation/doc";
|
2023-07-12 23:10:52 +02:00
|
|
|
const processDir = (dir) => {
|
|
|
|
console.log(dir);
|
|
|
|
for (const file of fs.readdirSync(dir)) {
|
|
|
|
const path = `${dir}/${file}`;
|
|
|
|
if (fs.lstatSync(`${dir}/${file}`).isDirectory()) {
|
|
|
|
processDir(path);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (path.startsWith(docRoot + "/")) {
|
|
|
|
files.push(path.slice(docRoot.length + 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
processDir(docRoot);
|
|
|
|
|
|
|
|
const autogenfile = `// THIS FILE IS AUTOGENERATED
|
2024-07-07 09:08:33 +02:00
|
|
|
${files.map((f, i) => `import file${i} from "./doc/${f}?raw";`).join("\n")}
|
|
|
|
|
|
|
|
import type { Document } from "./root.ts";
|
2023-07-12 23:10:52 +02:00
|
|
|
|
|
|
|
export const AllPages: Record<string, Document> = {};
|
|
|
|
${files.map((f, i) => `AllPages["${f}"] = file${i};`).join("\n")}
|
|
|
|
`;
|
|
|
|
|
|
|
|
fs.writeFile(docRoot + "/../pages.ts", autogenfile, (err) => {
|
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
|
|
|
// file written successfully
|
|
|
|
});
|