Skip to content

Commit 1664461

Browse files
committed
feat(plugin-typedoc): Upgrade to TypeDoc v0.28 with new API
1 parent ad4d5ba commit 1664461

File tree

6 files changed

+121
-108
lines changed

6 files changed

+121
-108
lines changed

e2e/fixtures/plugin-typedoc/index.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ test.describe('plugin-typedoc single entry', async () => {
3131
[
3232
'@rspress-fixture/rspress-plugin-typedoc-single',
3333
'Functions',
34-
'Function: createMiddleware',
35-
'Function: mergeMiddlewares',
34+
'Function: createMiddleware()',
35+
'Function: mergeMiddlewares()',
3636
'Types',
37-
'Type alias: Middleware',
37+
'Type Alias: Middleware()',
3838
].join(','),
3939
);
4040
});
@@ -68,21 +68,21 @@ test.describe('plugin-typedoc multi entries', async () => {
6868
[
6969
'@rspress-fixture/rspress-plugin-typedoc-multi',
7070
'Functions',
71-
'Function: createMiddleware',
72-
'Function: mergeMiddlewares',
73-
'Function: getRspressUrl',
71+
'Function: createMiddleware()',
72+
'Function: mergeMiddlewares()',
73+
'Function: getRspressUrl()',
7474
'Modules',
7575
'Module: middleware',
7676
'Module: raw-link',
7777
'Types',
78-
'Type alias: Middleware',
78+
'Type Alias: Middleware()',
7979
].join(','),
8080
);
8181
});
8282

8383
test('Should render raw link correctly', async ({ page }) => {
8484
await page.goto(
85-
`http://localhost:${appPort}/api/functions/raw_link.getRspressUrl.html`,
85+
`http://localhost:${appPort}/api/functions/raw-link.getRspressUrl.html`,
8686
{
8787
waitUntil: 'networkidle',
8888
},

packages/plugin-typedoc/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"reset": "rimraf ./**/node_modules"
3434
},
3535
"dependencies": {
36-
"typedoc": "0.24.8",
37-
"typedoc-plugin-markdown": "3.17.1"
36+
"typedoc": "0.28.14",
37+
"typedoc-plugin-markdown": "4.9.0"
3838
},
3939
"devDependencies": {
4040
"@microsoft/api-extractor": "^7.55.1",

packages/plugin-typedoc/src/index.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path';
22
import type { RspressPlugin } from '@rspress/core';
3-
import { Application, TSConfigReader } from 'typedoc';
4-
import { load } from 'typedoc-plugin-markdown';
3+
import { Application } from 'typedoc';
4+
import { load as loadPluginMarkdown } from 'typedoc-plugin-markdown';
55
import { API_DIR } from './constants';
66
import { patchGeneratedApiDocs } from './patch';
77

@@ -19,35 +19,36 @@ export interface PluginTypeDocOptions {
1919
}
2020

2121
export function pluginTypeDoc(options: PluginTypeDocOptions): RspressPlugin {
22-
let docRoot: string | undefined;
2322
const { entryPoints = [], outDir = API_DIR } = options;
2423
return {
2524
name: '@rspress/plugin-typedoc',
2625
async config(config) {
27-
const app = new Application();
28-
docRoot = config.root;
29-
app.options.addReader(new TSConfigReader());
30-
load(app);
31-
app.bootstrap({
26+
const app = await Application.bootstrapWithPlugins({
3227
name: config.title,
3328
entryPoints,
34-
theme: 'markdown',
3529
disableSources: true,
30+
router: 'kind',
3631
readme: 'none',
3732
githubPages: false,
3833
requiredToBeDocumented: ['Class', 'Function', 'Interface'],
39-
plugin: ['typedoc-plugin-markdown'],
40-
// @ts-expect-error - FIXME: current version of MarkdownTheme has no export, bump related package versions
34+
// @ts-expect-error - Typedoc does not export a type for this options
35+
plugin: [loadPluginMarkdown],
36+
entryFileName: 'index',
37+
hidePageHeader: true,
4138
hideBreadcrumbs: true,
42-
hideMembersSymbol: true,
43-
allReflectionsHaveOwnDocument: true,
39+
pageTitleTemplates: {
40+
module: '{kind}: {name}', // e.g. "Module: MyModule"
41+
},
4442
});
45-
const project = app.convert();
4643

44+
const project = await app.convert();
4745
if (project) {
4846
// 1. Generate doc/api, doc/api/_meta.json by typedoc
49-
const absoluteApiDir = path.join(docRoot!, outDir);
50-
await app.generateDocs(project, absoluteApiDir);
47+
const absoluteApiDir = path.join(config.root!, outDir);
48+
await app.outputs.writeOutput(
49+
{ name: 'markdown', path: absoluteApiDir },
50+
project,
51+
);
5152
await patchGeneratedApiDocs(absoluteApiDir);
5253
}
5354
return config;

packages/plugin-typedoc/src/patch.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,5 @@ async function generateMetaJson(absoluteApiDir: string) {
7070

7171
export async function patchGeneratedApiDocs(absoluteApiDir: string) {
7272
await patchLinks(absoluteApiDir);
73-
await fs.rename(
74-
path.join(absoluteApiDir, 'README.md'),
75-
path.join(absoluteApiDir, 'index.md'),
76-
);
7773
await generateMetaJson(absoluteApiDir);
7874
}

packages/plugin-typedoc/src/utils.ts

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

0 commit comments

Comments
 (0)