summaryrefslogtreecommitdiff
path: root/gen-docs
diff options
context:
space:
mode:
authortheprimeagain <the.primeagen@gmail.com>2026-02-23 08:45:22 -0700
committertheprimeagain <the.primeagen@gmail.com>2026-02-23 08:45:22 -0700
commit6a64e0b2f4c7f1e3911db1f8318e5d7c68cb8dff (patch)
tree9555d5fde508598f809897ae1598206f9c9fe64a /gen-docs
parent7fe5bfc9f3dce7ed40c9a8e7d8516562c409d87c (diff)
downloada4-6a64e0b2f4c7f1e3911db1f8318e5d7c68cb8dff.tar.xz
a4-6a64e0b2f4c7f1e3911db1f8318e5d7c68cb8dff.zip
docs readme generation
Diffstat (limited to 'gen-docs')
-rwxr-xr-xgen-docs44
1 files changed, 44 insertions, 0 deletions
diff --git a/gen-docs b/gen-docs
new file mode 100755
index 0000000..405cba9
--- /dev/null
+++ b/gen-docs
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
+
+README_HEADER_PATH="$SCRIPT_DIR/README_HEADER.md"
+TARGET_README_PATH="$SCRIPT_DIR/README.md"
+
+SCRIPT_DIR="$SCRIPT_DIR" \
+README_HEADER_PATH="$README_HEADER_PATH" \
+TARGET_README_PATH="$TARGET_README_PATH" \
+node --input-type=module <<'EOF'
+import { execFileSync } from "node:child_process";
+import { readFileSync, writeFileSync } from "node:fs";
+import path from "node:path";
+
+const placeholder = "___DOCS___";
+const scriptDir = process.env.SCRIPT_DIR;
+const headerPath = process.env.README_HEADER_PATH;
+const targetPath = process.env.TARGET_README_PATH;
+
+if (!scriptDir || !headerPath || !targetPath) {
+ throw new Error("missing required README path environment variables");
+}
+
+const generatorPath = path.join(scriptDir, "docs", "src", "generate.ts");
+const docs = execFileSync(
+ "node",
+ ["--experimental-strip-types", generatorPath, "--stdout"],
+ { encoding: "utf8" },
+).trimEnd();
+
+const header = readFileSync(headerPath, "utf8");
+
+if (!header.includes(placeholder)) {
+ throw new Error(`placeholder '${placeholder}' not found in ${headerPath}`);
+}
+
+const combined = header.split(placeholder).join(docs);
+const output = combined.endsWith("\n") ? combined : `${combined}\n`;
+
+writeFileSync(targetPath, output, "utf8");
+console.log(`[docs] wrote ${targetPath}`);
+EOF