Skip to content

Commit 5514f51

Browse files
authored
Merge pull request #3029 from finos/refactor-docs
Refactor docs
2 parents 855a37a + 9b3429e commit 5514f51

File tree

105 files changed

+2165
-4482
lines changed

Some content is hidden

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

105 files changed

+2165
-4482
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ vcpkg
6060
venv/
6161
rust/perspective-python/perspective_python-*.data
6262
.pytest-cache/
63+
docs/static/python
64+
docs/static/node
65+
docs/static/browser
66+
docs/static/viewer

Cargo.lock

Lines changed: 18 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ default-members = [
2323
members = [
2424
"rust/lint",
2525
"rust/generate-metadata",
26-
"rust/bootstrap",
27-
"rust/bootstrap-runtime",
2826
"rust/bundle",
2927
"rust/perspective",
3028
"rust/perspective-client",

cpp/perspective/build.js renamed to cpp/perspective/build.mjs

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

13-
const { execSync } = require("child_process");
14-
const os = require("os");
15-
const path = require("path");
13+
import { execSync } from "node:child_process";
14+
import os from "node:os";
15+
import path from "node:path";
16+
import * as url from "node:url";
17+
18+
const __dirname = url.fileURLToPath(new URL(".", import.meta.url)).slice(0, -1);
1619

1720
const stdio = "inherit";
18-
const rust_env = process.env.PSP_DEBUG ? "" : "--release";
1921
const env = process.env.PSP_DEBUG ? "debug" : "release";
2022
const cwd = path.join(process.cwd(), "dist", env);
2123

22-
delete process.env.NODE;
24+
const { compress } = await import("pro_self_extracting_wasm");
2325

24-
function bootstrap(file) {
25-
execSync(`cargo run -p perspective-bootstrap -- ${rust_env} ${file}`, {
26-
cwd: path.join(process.cwd(), "..", "..", "rust", "perspective-js"),
27-
stdio,
28-
});
29-
}
26+
delete process.env.NODE;
3027

3128
let cmake_flags = "";
3229
let make_flags = "";
@@ -50,8 +47,7 @@ try {
5047
);
5148

5249
execSync(
53-
`emmake make -j${
54-
process.env.PSP_NUM_CPUS || os.cpus().length
50+
`emmake make -j${process.env.PSP_NUM_CPUS || os.cpus().length
5551
} ${make_flags}`,
5652
{
5753
cwd,
@@ -62,7 +58,10 @@ try {
6258
execSync(`cpy web/**/* ../web`, { cwd, stdio });
6359
execSync(`cpy node/**/* ../node`, { cwd, stdio });
6460
if (!process.env.PSP_HEAP_INSTRUMENTS) {
65-
bootstrap(`../../cpp/perspective/dist/web/perspective-server.wasm`);
61+
compress(
62+
`../../cpp/perspective/dist/web/perspective-server.wasm`,
63+
`../../cpp/perspective/dist/web/perspective-server.wasm`
64+
);
6665
}
6766
} catch (e) {
6867
console.error(e);

cpp/perspective/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"dist/cjs/**/*"
1111
],
1212
"scripts": {
13-
"build": "node ../../tools/perspective-scripts/run_emsdk.mjs node ./build.js",
13+
"build": "node ../../tools/perspective-scripts/run_emsdk.mjs node ./build.mjs",
1414
"clean": "rimraf dist"
15+
},
16+
"devDependencies": {
17+
"pro_self_extracting_wasm": "0.0.9"
1518
}
16-
}
19+
}

docs/docusaurus.config.js

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ const examples = fs.readdirSync("static/blocks").map((ex) => {
3939
};
4040
});
4141

42+
function link(title, path) {
43+
return `<a class="dropdown__link" href="${path}"> ${title}</a>`;
44+
}
45+
4246
/** @type {import('@docusaurus/types').Config} */
4347
const config = {
4448
title: "Perspective",
@@ -119,20 +123,73 @@ const config = {
119123
label: "Docs",
120124
items: [
121125
{
122-
href: "/guide/",
123-
label: "User Guide",
126+
type: "html",
127+
value: `<a class="dropdown__link" style="font-size:16px;padding:0.25rem 0rem" href="/guide/">User Guide</a>`,
128+
},
129+
{
130+
type: "html",
131+
value: '<span style="user-select:none">Python API</span>',
132+
},
133+
{
134+
type: "html",
135+
value: `<a class="dropdown__link" href="/python/"><code>perspective</code></a>`,
136+
},
137+
{
138+
type: "html",
139+
value: `<a class="dropdown__link" href="/python/perspective/widget.html"><code>perspective.widget</code></a>`,
140+
},
141+
{
142+
type: "html",
143+
value: `<a class="dropdown__link" href="/python/perspective/handlers/aiohttp.html"><code>perspective.handlers.aiohttp</code></a>`,
144+
},
145+
{
146+
type: "html",
147+
value: `<a class="dropdown__link" href="/python/perspective/handlers/starlette.html"><code>perspective.handlers.starlette</code></a>`,
148+
},
149+
{
150+
type: "html",
151+
value: `<a class="dropdown__link" href="/python/perspective/handlers/tornado.html"><code>perspective.handlers.tornado</code></a>`,
152+
},
153+
{
154+
type: "html",
155+
value: '<span style="user-select:none">JavaScript API</span>',
156+
},
157+
{
158+
type: "html",
159+
value: link(
160+
"<code>@finos/perspective-viewer</code>",
161+
"/viewer/modules/perspective-viewer.html"
162+
),
163+
},
164+
{
165+
type: "html",
166+
value: link(
167+
"<code>@finos/perspective</code> Browser",
168+
"/browser/modules/src_ts_perspective.browser.ts.html"
169+
),
170+
},
171+
{
172+
type: "html",
173+
value: link(
174+
"<code>@finos/perspective</code> Node.js",
175+
"/node/modules/src_ts_perspective.node.ts.html"
176+
),
177+
},
178+
{
179+
type: "html",
180+
value: '<span style="user-select:none">Rust API</span>',
124181
},
125182
{
126183
type: "html",
127-
value: `<a class="dropdown__link" href="https://docs.rs/perspective-js/latest/perspective_js/"><code>@finos/perspective</code> JavaScript API</a>`,
184+
value: `<a class="dropdown__link" href="https://docs.rs/perspective-js/latest/perspective_js/"><code>perspective-js</code></a>`,
128185
},
129186
{
130187
type: "html",
131-
value: `<a class="dropdown__link" href="https://docs.rs/perspective-python/latest/perspective_python/"><code>perspective-python</code> Python API</a>`,
188+
value: `<a class="dropdown__link" href="https://docs.rs/perspective-python/latest/perspective_python/"><code>perspective-python</code></a>`,
132189
},
133190
{
134191
type: "html",
135-
value: `<a class="dropdown__link" href="https://docs.rs/perspective/latest/perspective/"><code>perspective</code> Rust API</a>`,
192+
value: `<a class="dropdown__link" href="https://docs.rs/perspective/latest/perspective/"><code>perspective</code></a>`,
136193
},
137194
],
138195
},

docs/md/how_to/javascript/importing.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ ESBuild config JSON to encode this asset as a `file`:
7676
### Webpack
7777

7878
```javascript
79-
import * as SERVER_WASM from "@finos/perspective/dist/wasm/perspective-server.wasm";
80-
import * as CLIENT_WASM from "@finos/perspective-viewer/dist/wasm/perspective-viewer.wasm";
79+
import SERVER_WASM from "@finos/perspective/dist/wasm/perspective-server.wasm";
80+
import CLIENT_WASM from "@finos/perspective-viewer/dist/wasm/perspective-viewer.wasm";
8181

8282
await Promise.all([
8383
perspective.init_server(SERVER_WASM),
@@ -90,8 +90,19 @@ Webpack config:
9090
```javascript
9191
{
9292
// ...
93+
module: {
94+
// ...
95+
rules: [
96+
// ...
97+
{
98+
test: /\.wasm$/,
99+
type: "asset/resource"
100+
},
101+
]
102+
},
93103
experiments: {
94-
asyncWebAssembly: true,
104+
// ...
105+
asyncWebAssembly: false,
95106
syncWebAssembly: false,
96107
},
97108
}

docs/plugins/perspective-loader/index.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ module.exports = function (context, options) {
2121
}
2222

2323
config.experiments = config.experiments || {
24-
asyncWebAssembly: true,
24+
asyncWebAssembly: false,
25+
syncWebAssembly: false
2526
};
2627

2728
config.experiments.topLevelAwait = true;
@@ -36,17 +37,22 @@ module.exports = function (context, options) {
3637
type: "asset/resource",
3738
});
3839

40+
config.module.rules.push({
41+
test: /\.wasm$/,
42+
type: "asset/resource"
43+
});
44+
3945
return {
4046
node: {
4147
__filename: false,
4248
},
4349
plugins: isServer
4450
? [
45-
new webpack.NormalModuleReplacementPlugin(
46-
/@finos\/perspective/,
47-
"@finos/perspective/dist/esm/perspective.js"
48-
),
49-
]
51+
new webpack.NormalModuleReplacementPlugin(
52+
/@finos\/perspective/,
53+
"@finos/perspective/dist/esm/perspective.js"
54+
),
55+
]
5056
: [],
5157
};
5258
},

docs/src/data/worker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const WORKER = (async () => {
1919
);
2020

2121
await Promise.all([
22-
perspective.init_server(wasm),
23-
perspective_viewer.init_client(client_wasm),
22+
perspective.init_server(wasm.then(x => x.default)),
23+
perspective_viewer.init_client(client_wasm.then(x => x.default)),
2424
]);
2525

2626
return await perspective.worker();

examples/blocks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
"superstore-arrow": "3.0.0"
2121
},
2222
"devDependencies": {
23-
"esbuild": "^0.14.54"
23+
"esbuild": "^0.25.5"
2424
}
2525
}

0 commit comments

Comments
 (0)