From d7b071978860472aa0ffa9f787a89811870f56b2 Mon Sep 17 00:00:00 2001
From: zadam
Date: Thu, 12 Jan 2023 16:37:30 +0100
Subject: [PATCH] script to build the docs website
---
src/build_docs_website.js | 123 ++++++++++++++++++++++++
src/services/export/zip.js | 5 +-
src/transform_api_docs.js | 188 ++++++++++++++++++++++---------------
3 files changed, 237 insertions(+), 79 deletions(-)
create mode 100644 src/build_docs_website.js
diff --git a/src/build_docs_website.js b/src/build_docs_website.js
new file mode 100644
index 000000000..9e3e6a6c5
--- /dev/null
+++ b/src/build_docs_website.js
@@ -0,0 +1,123 @@
+const fs = require("fs-extra");
+const utils = require("./services/utils.js");
+const html = require("html");
+
+const USER_GUIDE_DIR = './docs/user_guide';
+const META_PATH = USER_GUIDE_DIR + '/!!!meta.json';
+const WEB_TMP_DIR = './tmp/user_guide_web';
+fs.copySync(USER_GUIDE_DIR, WEB_TMP_DIR);
+
+const meta = JSON.parse(fs.readFileSync(META_PATH).toString());
+const rootNoteMeta = meta.files[0];
+const noteIdToMeta = {};
+createNoteIdToMetaMapping(rootNoteMeta);
+
+addNavigationAndStyle(rootNoteMeta, WEB_TMP_DIR);
+
+fs.writeFileSync(WEB_TMP_DIR + '/style.css', getCss());
+
+function getCss() {
+ return '* { color: red }';
+}
+
+function addNavigationAndStyle(noteMeta, parentDirPath) {
+ const nav = createNavigation(rootNoteMeta, noteMeta);
+
+ if (noteMeta.dataFileName) {
+ const filePath = parentDirPath + "/" + noteMeta.dataFileName;
+
+ console.log(`Adding nav to ${filePath}`);
+
+ const content = fs.readFileSync(filePath).toString();
+ const depth = noteMeta.notePath.length - 1;
+ const updatedContent = content
+ .replaceAll("", ``)
+ .replaceAll("
+
${utils.escapeHtml(title)}
-${content}
+
+ ${content}