Skip to content

Commit c47a1e8

Browse files
committed
Remove docusaurus
Signed-off-by: Andrew Stein <steinlink@gmail.com>
1 parent 41250b2 commit c47a1e8

45 files changed

Lines changed: 5065 additions & 13836 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/build.config.mjs

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2+
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3+
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4+
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5+
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6+
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7+
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
8+
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9+
// ┃ This file is part of the Perspective library, distributed under the terms ┃
10+
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11+
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12+
13+
import * as esbuild from "esbuild";
14+
import * as fs from "node:fs";
15+
import * as path from "node:path";
16+
import { createRequire } from "module";
17+
import { bundleAsync as bundleCssAsync, composeVisitors } from "lightningcss";
18+
import { fileURLToPath } from "node:url";
19+
20+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
21+
const DIST = path.join(__dirname, "dist");
22+
23+
function copyRecursive(src, dest) {
24+
if (!fs.existsSync(src)) return;
25+
const stat = fs.statSync(src);
26+
if (stat.isDirectory()) {
27+
fs.mkdirSync(dest, { recursive: true });
28+
for (const child of fs.readdirSync(src)) {
29+
copyRecursive(path.join(src, child), path.join(dest, child));
30+
}
31+
} else {
32+
fs.copyFileSync(src, dest);
33+
}
34+
}
35+
36+
// Inline url() asset references as data URIs.
37+
export function inlineUrlVisitor(fromFile) {
38+
const dir = path.dirname(fromFile);
39+
return composeVisitors([
40+
{
41+
Url(url) {
42+
const ext = path.extname(url.url).toLowerCase();
43+
if (![".svg", ".png", ".gif"].includes(ext)) {
44+
return;
45+
}
46+
47+
const resolved = path.resolve(dir, url.url);
48+
if (!fs.existsSync(resolved)) {
49+
throw new Error(`File not found ${url.url}`);
50+
// return;
51+
}
52+
53+
const content = fs.readFileSync(resolved);
54+
const mime =
55+
ext === ".svg"
56+
? "image/svg+xml"
57+
: ext === ".png"
58+
? "image/png"
59+
: "image/gif";
60+
61+
const new_content = content
62+
.toString("base64")
63+
.split("\n")
64+
.map((x) => x.trim())
65+
.join("");
66+
67+
return {
68+
url: `data:${mime};base64,${new_content}`,
69+
loc: url.loc,
70+
};
71+
},
72+
},
73+
]);
74+
}
75+
76+
export const resolveNPM = (url) => ({
77+
read(filePath) {
78+
if (filePath.startsWith("http")) {
79+
return `@import url("${filePath}");`;
80+
}
81+
82+
return fs.readFileSync(filePath, "utf8");
83+
},
84+
resolve(specifier, from) {
85+
if (specifier.startsWith("http")) {
86+
return { external: specifier };
87+
}
88+
89+
const _require = createRequire(url);
90+
91+
if (specifier.startsWith(".") || specifier.startsWith("/")) {
92+
return path.resolve(path.dirname(from), specifier);
93+
}
94+
95+
return _require.resolve(specifier);
96+
},
97+
});
98+
99+
async function build() {
100+
// Clean and create dist
101+
fs.mkdirSync(DIST, { recursive: true });
102+
103+
// Bundle CSS
104+
const { code: cssCode } = await bundleCssAsync({
105+
filename: path.join(__dirname, "./src/css/style.css"),
106+
minify: true,
107+
resolver: resolveNPM(import.meta.url),
108+
visitor: inlineUrlVisitor("./src/css/style.css"),
109+
});
110+
111+
fs.mkdirSync(path.join(DIST, "css"), { recursive: true });
112+
fs.writeFileSync(path.join(DIST, "style.css"), cssCode);
113+
114+
// Bundle JS entry points
115+
await esbuild.build({
116+
entryPoints: [
117+
path.join(__dirname, "src/index.ts"),
118+
path.join(__dirname, "src/examples.ts"),
119+
path.join(__dirname, "src/block.ts"),
120+
],
121+
bundle: true,
122+
splitting: true,
123+
format: "esm",
124+
outdir: DIST,
125+
minify: true,
126+
sourcemap: true,
127+
target: ["es2022"],
128+
define: {
129+
global: "window",
130+
},
131+
loader: {
132+
".wasm": "file",
133+
".arrow": "file",
134+
},
135+
});
136+
137+
// Copy HTML files
138+
for (const html of ["index.html", "examples.html", "block.html"]) {
139+
fs.copyFileSync(
140+
path.join(__dirname, "src", html),
141+
path.join(DIST, html),
142+
);
143+
}
144+
145+
// Copy static assets
146+
copyRecursive(path.join(__dirname, "static"), DIST);
147+
148+
// Generate blocks manifest
149+
const blocksDir = path.join(DIST, "blocks");
150+
if (fs.existsSync(blocksDir)) {
151+
const manifest = {};
152+
for (const example of fs.readdirSync(blocksDir)) {
153+
const exDir = path.join(blocksDir, example);
154+
if (!fs.statSync(exDir).isDirectory()) continue;
155+
manifest[example] = fs
156+
.readdirSync(exDir)
157+
.filter(
158+
(f) =>
159+
!f.startsWith(".") &&
160+
!f.endsWith(".png") &&
161+
!f.endsWith(".arrow"),
162+
);
163+
}
164+
fs.writeFileSync(
165+
path.join(blocksDir, "manifest.json"),
166+
JSON.stringify(manifest),
167+
);
168+
}
169+
170+
console.log("Build complete: dist/");
171+
}
172+
173+
build().catch((e) => {
174+
console.error(e);
175+
process.exit(1);
176+
});

docs/build.js renamed to docs/build.mjs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@
1010
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
1111
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1212

13-
const puppeteer = require("puppeteer");
14-
const fs = require("fs");
15-
const cp = require("child_process");
16-
const path = require("node:path");
17-
const mkdirp = require("mkdirp");
18-
const EXAMPLES = require("./src/components/ExampleGallery/features.js").default;
13+
import puppeteer from "puppeteer";
14+
import * as fs from "node:fs";
15+
import * as cp from "node:child_process";
16+
import * as path from "node:path";
17+
import { fileURLToPath } from "node:url";
18+
19+
import EXAMPLES from "./src/data/features.js";
20+
21+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
22+
23+
// features.js uses CJS exports.default, import it dynamically
24+
// const EXAMPLES = (await import("./src/data/features.ts")).default;
1925

2026
const perspective = import(
2127
"@perspective-dev/client/dist/esm/perspective.node.js"
@@ -30,13 +36,9 @@ function shuffle(array) {
3036
let currentIndex = array.length,
3137
randomIndex;
3238

33-
// While there remain elements to shuffle.
3439
while (currentIndex != 0) {
35-
// Pick a remaining element.
3640
randomIndex = Math.floor(Math.random() * currentIndex);
3741
currentIndex--;
38-
39-
// And swap it with the current element.
4042
[array[currentIndex], array[randomIndex]] = [
4143
array[randomIndex],
4244
array[currentIndex],
@@ -64,7 +66,7 @@ async function run_with_theme(page, is_dark = false) {
6466
const files = [];
6567
for (const idx in EXAMPLES) {
6668
const { config, viewport } = EXAMPLES[idx];
67-
await await page.setViewport(viewport || DEFAULT_VIEWPORT);
69+
await page.setViewport(viewport || DEFAULT_VIEWPORT);
6870
const new_config = Object.assign(
6971
{
7072
plugin: "Datagrid",
@@ -103,8 +105,6 @@ async function run_with_theme(page, is_dark = false) {
103105
" ",
104106
)} static/features/montage${is_dark ? "_dark" : "_light"}.png`,
105107
);
106-
107-
// fs.writeFileSync("features/index.html", `<html><style>img{width:200px;height:150px;</style><body>${html.join("")}</body></html>`);
108108
}
109109

110110
async function run() {
@@ -133,7 +133,6 @@ async function run() {
133133
await server.close();
134134
}
135135

136-
// TODO There is a typescript module annoyingly called `blocks`.
137136
if (!fs.existsSync("static/blocks")) {
138137
fs.mkdirSync("static/blocks");
139138
}

docs/docusaurus.config.js

Lines changed: 0 additions & 140 deletions
This file was deleted.

0 commit comments

Comments
 (0)