Skip to content

Commit f3b64c5

Browse files
committed
hmm
1 parent a87b516 commit f3b64c5

File tree

5 files changed

+213
-56
lines changed

5 files changed

+213
-56
lines changed

astro.config.mjs renamed to astro.config.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import path from 'path';
1313
import { fileURLToPath } from 'url';
1414
import lunaria from '@lunariajs/starlight';
1515
import { readFileSync } from 'fs';
16+
import { getTauriTypeDocPlugins } from './config/typedoc-plugins';
17+
18+
const { plugins: typeDocPlugins } = getTauriTypeDocPlugins();
1619

1720
const authors = {
1821
nothingismagick: {
@@ -76,6 +79,7 @@ export default defineConfig({
7679
integrations: [
7780
starlight({
7881
plugins: [
82+
...typeDocPlugins,
7983
starlightBlog({ authors }),
8084
starlightSidebarTopics(
8185
[
@@ -293,7 +297,16 @@ export default defineConfig({
293297
{
294298
label: 'JavaScript',
295299
collapsed: true,
296-
autogenerate: { directory: 'reference/javascript' },
300+
items: [
301+
{
302+
label: 'Tauri',
303+
autogenerate: { directory: 'reference/javascript/core' },
304+
},
305+
{
306+
label: 'Plugins',
307+
autogenerate: { directory: 'reference/javascript/plugins' },
308+
},
309+
],
297310
},
298311
{
299312
label: 'Rust (docs.rs)',
@@ -393,6 +406,7 @@ export default defineConfig({
393406
}),
394407
serviceWorker({
395408
workbox: {
409+
swDest: 'dist/sw.js',
396410
cleanupOutdatedCaches: true,
397411
clientsClaim: true,
398412
inlineWorkboxRuntime: true,
@@ -415,9 +429,6 @@ export default defineConfig({
415429
}),
416430
],
417431
markdown: {
418-
shikiConfig: {
419-
langs: ['powershell', 'ts', 'rust', 'bash', 'json', 'toml', 'html', 'js'],
420-
},
421432
rehypePlugins: [
422433
rehypeHeadingIds,
423434
[
@@ -522,8 +533,10 @@ function i18nRedirect(from, to) {
522533
const routes = {};
523534
Object.keys(locales).map((locale) =>
524535
locale === 'root'
525-
? (routes[from] = to)
526-
: (routes[`/${locale}/${from.replaceAll(/^\/*/g, '')}`] = `/${locale}/${to.replaceAll(
536+
? // @ts-ignore
537+
(routes[from] = to)
538+
: // @ts-ignore
539+
(routes[`/${locale}/${from.replaceAll(/^\/*/g, '')}`] = `/${locale}/${to.replaceAll(
527540
/^\/*/g,
528541
''
529542
)}`)
@@ -536,7 +549,8 @@ function readHeaders() {
536549
const header_file = readFileSync('public/_headers', { encoding: 'utf8' })
537550
.split('\n')
538551
.filter(Boolean);
539-
const headers = {};
552+
/** @type {import('http').OutgoingHttpHeaders} */
553+
const headers = Object.create(null);
540554
for (const line of header_file) {
541555
const [key, val] = line.trim().split(/\s*:\s*(.+)/);
542556
if (key != undefined && val != undefined) {

config/typedoc-plugins.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import starlightTypeDoc from 'starlight-typedoc';
2+
import { existsSync } from 'fs';
3+
4+
const tauriPlugins = [
5+
{ name: 'fs', path: 'fs' },
6+
{ name: 'autostart', path: 'autostart' },
7+
{ name: 'barcode-scanner', path: 'barcode-scanner' },
8+
{ name: 'biometric', path: 'biometric' },
9+
{ name: 'cli', path: 'cli' },
10+
{ name: 'clipboard-manager', path: 'clipboard-manager' },
11+
{ name: 'deep-link', path: 'deep-link' },
12+
{ name: 'dialog', path: 'dialog' },
13+
{ name: 'global-shortcut', path: 'global-shortcut' },
14+
{ name: 'http', path: 'http' },
15+
{ name: 'log', path: 'log' },
16+
{ name: 'nfc', path: 'nfc' },
17+
{ name: 'notification', path: 'notification' },
18+
{ name: 'opener', path: 'opener' },
19+
{ name: 'os', path: 'os' },
20+
{ name: 'positioner', path: 'positioner' },
21+
{ name: 'process', path: 'process' },
22+
{ name: 'shell', path: 'shell' },
23+
{ name: 'sql', path: 'sql' },
24+
{ name: 'store', path: 'store' },
25+
{ name: 'stronghold', path: 'stronghold' },
26+
{ name: 'updater', path: 'updater' },
27+
{ name: 'upload', path: 'upload' },
28+
{ name: 'websocket', path: 'websocket' },
29+
{ name: 'window-state', path: 'window-state' },
30+
];
31+
32+
const coreOutput = 'reference/javascript/core';
33+
const pluginOutput = 'reference/javascript/plugins';
34+
35+
export function getTauriTypeDocPlugins(): {
36+
plugins: Array<any>;
37+
} {
38+
const plugins: any[] = [];
39+
40+
tauriPlugins.forEach((plugin) => {
41+
const dir = `src/content/docs/${pluginOutput}/${plugin.path}/README.md`;
42+
if (!existsSync(dir)) {
43+
plugins.push(
44+
starlightTypeDoc({
45+
tsconfig: `./packages/plugins-workspace/plugins/${plugin.path}/tsconfig.json`,
46+
entryPoints: [`./packages/plugins-workspace/plugins/${plugin.path}/guest-js/index.ts`],
47+
output: `${pluginOutput}/${plugin.path}`,
48+
})
49+
);
50+
}
51+
});
52+
53+
const dir = `src/content/docs/${coreOutput}/README.md`;
54+
if (!existsSync(dir)) {
55+
plugins.push(
56+
starlightTypeDoc({
57+
tsconfig: './packages/tauri/packages/api/tsconfig.json',
58+
entryPoints: ['./packages/tauri/packages/api/src/index.ts'],
59+
output: coreOutput,
60+
})
61+
);
62+
}
63+
64+
return {
65+
plugins,
66+
};
67+
}

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
"format": "prettier -w --cache --plugin prettier-plugin-astro .",
1414
"format:check": "prettier -c --cache --plugin prettier-plugin-astro .",
1515
"build:compatibility-table": "pnpm --filter compatibility-table run build",
16-
"build:references": "pnpm --filter js-api-generator run build",
1716
"build:releases": "pnpm --filter releases-generator run build",
1817
"build:config": "pnpm --filter config-generator run build",
1918
"build:cli": "pnpm --filter cli-generator run build",
2019
"build:astro": "astro build",
21-
"build": "pnpm dev:setup && pnpm build:references && pnpm build:config && pnpm build:cli && pnpm build:releases && pnpm build:astro",
20+
"build": "pnpm dev:setup && pnpm build:config && pnpm build:cli && pnpm build:releases && pnpm build:astro",
2221
"preview": "astro preview"
2322
},
2423
"dependencies": {
@@ -40,8 +39,11 @@
4039
"sharp": "^0.33.5",
4140
"shiki": "^3.0.0",
4241
"starlight-blog": "^0.24.0",
42+
"starlight-links-validator": "^0.17.0",
4343
"starlight-sidebar-topics": "^0.6.0",
44-
"starlight-links-validator": "^0.17.0"
44+
"starlight-typedoc": "^0.21.3",
45+
"typedoc": "0.28.7",
46+
"typedoc-plugin-markdown": "4.7.1"
4547
},
4648
"packageManager": "[email protected]",
4749
"engines": {

packages/js-api-generator/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This package is archived in favour of starlight-typedoc plugin
2+
3+
To renable, add `"build:references": "pnpm --filter js-api-generator run build",` to docs package.json and append `pnpm build:references` to the build command

0 commit comments

Comments
 (0)