mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
Documentation added ingame (#667)
This commit is contained in:
35
tools/bundle-doc/index.js
Normal file
35
tools/bundle-doc/index.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const fs = require("fs");
|
||||
|
||||
const files = [];
|
||||
const docRoot = "./src/Documentation/ui/doc";
|
||||
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
|
||||
${files.map((f, i) => `import file${i} from "!!raw-loader!./doc/${f}";`).join("\n")}
|
||||
|
||||
interface Document {
|
||||
default: string;
|
||||
}
|
||||
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
|
||||
});
|
||||
Reference in New Issue
Block a user