|
1 | | -import { resolve } from 'node:path' |
2 | | -import { fileURLToPath } from 'node:url' |
3 | | -import { mkdir, rm } from 'node:fs/promises' |
4 | | -import * as TypeDoc from 'typedoc' |
5 | | - |
6 | | -const __dirname = fileURLToPath(new URL('.', import.meta.url)) |
7 | | - |
8 | | -/** |
9 | | - * @type {Partial<import("typedoc").TypeDocOptions & import("typedoc-plugin-markdown").PluginOptions>} |
10 | | - */ |
11 | | -const settings = { |
12 | | - plugin: [ |
13 | | - 'typedoc-plugin-markdown', |
14 | | - 'typedoc-plugin-frontmatter', |
15 | | - resolve(__dirname, './typedoc-custom-settings.js'), |
16 | | - ], |
17 | | - hideGenerator: true, |
18 | | - readme: 'none', |
19 | | - entryFileName: 'index', |
20 | | - hideBreadcrumbs: true, |
21 | | - hidePageHeader: true, |
22 | | - useCodeBlocks: true, |
23 | | - excludePrivate: true, |
24 | | -} |
25 | | - |
26 | | -/** |
27 | | - * @param {import('./index.js').Options} options |
28 | | - * @returns {Promise<void>} |
29 | | - */ |
30 | | -export const generateReferenceDocs = async (options) => { |
31 | | - for (const pkg of options.packages) { |
32 | | - // Clean and recreate the output directories |
33 | | - try { |
34 | | - await rm(pkg.outputDir, { recursive: true }) |
35 | | - } catch (error) { |
36 | | - // @ts-expect-error |
37 | | - if (error.code !== 'ENOENT') { |
38 | | - throw error |
39 | | - } |
40 | | - } |
41 | | - await mkdir(pkg.outputDir, { recursive: true }) |
42 | | - |
43 | | - const app = await TypeDoc.Application.bootstrapWithPlugins({ |
44 | | - ...settings, |
45 | | - gitRevision: options.gitBranch ?? 'main', |
46 | | - entryPoints: pkg.entryPoints, |
47 | | - tsconfig: pkg.tsconfig, |
48 | | - exclude: pkg.exclude, |
49 | | - out: pkg.outputDir, |
50 | | - }) |
51 | | - |
52 | | - const project = await app.convert() |
53 | | - |
54 | | - if (project) { |
55 | | - await app.generateOutputs(project) |
56 | | - } |
57 | | - } |
58 | | -} |
| 1 | +export { generateReferenceDocs } from '@tanstack/typedoc-config' |
0 commit comments