Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions astro.config.mjs → astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import path from 'path';
import { fileURLToPath } from 'url';
import lunaria from '@lunariajs/starlight';
import { readFileSync } from 'fs';
import { getTauriTypeDocPlugins } from './config/typedoc-plugins';

const { plugins: typeDocPlugins } = getTauriTypeDocPlugins();

const authors = {
nothingismagick: {
Expand Down Expand Up @@ -76,6 +79,7 @@ export default defineConfig({
integrations: [
starlight({
plugins: [
...typeDocPlugins,
starlightBlog({ authors }),
starlightSidebarTopics(
[
Expand Down Expand Up @@ -293,7 +297,18 @@ export default defineConfig({
{
label: 'JavaScript',
collapsed: true,
autogenerate: { directory: 'reference/javascript' },
items: [
{
label: 'Tauri',
collapsed: true,
autogenerate: { directory: 'reference/javascript/core' },
},
{
label: 'Plugins',
collapsed: true,
autogenerate: { directory: 'reference/javascript/plugins', collapsed: true },
},
],
},
{
label: 'Rust (docs.rs)',
Expand All @@ -318,11 +333,11 @@ export default defineConfig({
},
}
),
starlightLinksValidator({
errorOnFallbackPages: false,
errorOnRelativeLinks: false,
exclude: ['/plugin/*/#default-permission', '/plugin/*/#permission-table'],
}),
// starlightLinksValidator({
// errorOnFallbackPages: false,
// errorOnRelativeLinks: false,
// exclude: ['/plugin/*/#default-permission', '/plugin/*/#permission-table'],
// }),
lunaria({ configPath: './lunaria.config.json', route: '/contribute/translate-status' }),
],
title: 'Tauri',
Expand Down Expand Up @@ -393,6 +408,7 @@ export default defineConfig({
}),
serviceWorker({
workbox: {
swDest: 'dist/sw.js',
cleanupOutdatedCaches: true,
clientsClaim: true,
inlineWorkboxRuntime: true,
Expand Down Expand Up @@ -522,8 +538,10 @@ function i18nRedirect(from, to) {
const routes = {};
Object.keys(locales).map((locale) =>
locale === 'root'
? (routes[from] = to)
: (routes[`/${locale}/${from.replaceAll(/^\/*/g, '')}`] = `/${locale}/${to.replaceAll(
? // @ts-ignore
(routes[from] = to)
: // @ts-ignore
(routes[`/${locale}/${from.replaceAll(/^\/*/g, '')}`] = `/${locale}/${to.replaceAll(
/^\/*/g,
''
)}`)
Expand All @@ -536,7 +554,8 @@ function readHeaders() {
const header_file = readFileSync('public/_headers', { encoding: 'utf8' })
.split('\n')
.filter(Boolean);
const headers = {};
/** @type {import('http').OutgoingHttpHeaders} */
const headers = Object.create(null);
for (const line of header_file) {
const [key, val] = line.trim().split(/\s*:\s*(.+)/);
if (key != undefined && val != undefined) {
Expand Down
67 changes: 67 additions & 0 deletions config/typedoc-plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import starlightTypeDoc from 'starlight-typedoc';
import { existsSync } from 'fs';

const tauriPlugins = [
{ name: 'fs', path: 'fs' },
{ name: 'autostart', path: 'autostart' },
{ name: 'barcode-scanner', path: 'barcode-scanner' },
{ name: 'biometric', path: 'biometric' },
{ name: 'cli', path: 'cli' },
{ name: 'clipboard-manager', path: 'clipboard-manager' },
{ name: 'deep-link', path: 'deep-link' },
{ name: 'dialog', path: 'dialog' },
{ name: 'global-shortcut', path: 'global-shortcut' },
{ name: 'http', path: 'http' },
{ name: 'log', path: 'log' },
{ name: 'nfc', path: 'nfc' },
{ name: 'notification', path: 'notification' },
{ name: 'opener', path: 'opener' },
{ name: 'os', path: 'os' },
{ name: 'positioner', path: 'positioner' },
{ name: 'process', path: 'process' },
{ name: 'shell', path: 'shell' },
{ name: 'sql', path: 'sql' },
{ name: 'store', path: 'store' },
{ name: 'stronghold', path: 'stronghold' },
{ name: 'updater', path: 'updater' },
{ name: 'upload', path: 'upload' },
{ name: 'websocket', path: 'websocket' },
{ name: 'window-state', path: 'window-state' },
];

const coreOutput = 'reference/javascript/core';
const pluginOutput = 'reference/javascript/plugins';

export function getTauriTypeDocPlugins(): {
plugins: Array<any>;
} {
const plugins: any[] = [];

tauriPlugins.forEach((plugin) => {
const dir = `src/content/docs/${pluginOutput}/${plugin.path}/README.md`;
if (!existsSync(dir)) {
plugins.push(
starlightTypeDoc({
tsconfig: `./packages/plugins-workspace/plugins/${plugin.path}/tsconfig.json`,
entryPoints: [`./packages/plugins-workspace/plugins/${plugin.path}/guest-js/index.ts`],
output: `${pluginOutput}/${plugin.path}`,
})
);
}
});

const dir = `src/content/docs/${coreOutput}/README.md`;
if (!existsSync(dir)) {
plugins.push(
starlightTypeDoc({
tsconfig: './packages/tauri/packages/api/tsconfig.json',
entryPoints: ['./packages/tauri/packages/api/src/index.ts'],
output: coreOutput,
})
);
}

return {
plugins,
};
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
"format": "prettier -w --cache --plugin prettier-plugin-astro .",
"format:check": "prettier -c --cache --plugin prettier-plugin-astro .",
"build:compatibility-table": "pnpm --filter compatibility-table run build",
"build:references": "pnpm --filter js-api-generator run build",
"build:releases": "pnpm --filter releases-generator run build",
"build:config": "pnpm --filter config-generator run build",
"build:cli": "pnpm --filter cli-generator run build",
"build:astro": "astro build",
"build": "pnpm dev:setup && pnpm build:references && pnpm build:config && pnpm build:cli && pnpm build:releases && pnpm build:astro",
"build": "pnpm dev:setup && pnpm build:config && pnpm build:cli && pnpm build:releases && pnpm build:astro",
"preview": "astro preview"
},
"dependencies": {
Expand All @@ -40,8 +39,10 @@
"sharp": "^0.33.5",
"shiki": "^3.0.0",
"starlight-blog": "^0.24.0",
"starlight-links-validator": "^0.17.0",
"starlight-sidebar-topics": "^0.6.0",
"starlight-links-validator": "^0.17.0"
"starlight-typedoc": "^0.21.3",
"typedoc": "0.28.8"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
3 changes: 3 additions & 0 deletions packages/js-api-generator/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This package is archived in favour of starlight-typedoc plugin

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
Loading