@rspress/plugin-typedoc 2.0.0-rc.1 → 2.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.js +24 -16
- package/dist/types/index.d.ts +6 -0
- package/package.json +8 -8
package/dist/es/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import {
|
|
2
|
+
import { cwd } from "process";
|
|
3
|
+
import { Application } from "typedoc";
|
|
3
4
|
import { load } from "typedoc-plugin-markdown";
|
|
4
5
|
import promises from "fs/promises";
|
|
5
6
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -76,7 +77,6 @@ function generateMetaJson(absoluteApiDir) {
|
|
|
76
77
|
function patchGeneratedApiDocs(absoluteApiDir) {
|
|
77
78
|
return _async_to_generator(function*() {
|
|
78
79
|
yield patchLinks(absoluteApiDir);
|
|
79
|
-
yield promises.rename(path.join(absoluteApiDir, 'README.md'), path.join(absoluteApiDir, 'index.md'));
|
|
80
80
|
yield generateMetaJson(absoluteApiDir);
|
|
81
81
|
})();
|
|
82
82
|
}
|
|
@@ -107,21 +107,22 @@ function src_async_to_generator(fn) {
|
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
function pluginTypeDoc(options) {
|
|
110
|
-
|
|
111
|
-
const
|
|
110
|
+
const { entryPoints: userEntryPoints = [], outDir = "api", setup = ()=>{} } = options;
|
|
111
|
+
const entryPoints = userEntryPoints.map((entryPath)=>{
|
|
112
|
+
if (!path.isAbsolute(entryPath)) return entryPath;
|
|
113
|
+
const cwdPosix = cwd().replace(/\\/g, '/');
|
|
114
|
+
const entryPosix = entryPath.replace(/\\/g, '/');
|
|
115
|
+
return path.posix.relative(cwdPosix, entryPosix);
|
|
116
|
+
});
|
|
112
117
|
return {
|
|
113
118
|
name: '@rspress/plugin-typedoc',
|
|
114
119
|
config (config) {
|
|
115
120
|
return src_async_to_generator(function*() {
|
|
116
|
-
|
|
117
|
-
docRoot = config.root;
|
|
118
|
-
app.options.addReader(new TSConfigReader());
|
|
119
|
-
load(app);
|
|
120
|
-
app.bootstrap({
|
|
121
|
+
let app = yield Application.bootstrapWithPlugins({
|
|
121
122
|
name: config.title,
|
|
122
123
|
entryPoints,
|
|
123
|
-
theme: 'markdown',
|
|
124
124
|
disableSources: true,
|
|
125
|
+
router: 'kind',
|
|
125
126
|
readme: 'none',
|
|
126
127
|
githubPages: false,
|
|
127
128
|
requiredToBeDocumented: [
|
|
@@ -130,16 +131,23 @@ function pluginTypeDoc(options) {
|
|
|
130
131
|
'Interface'
|
|
131
132
|
],
|
|
132
133
|
plugin: [
|
|
133
|
-
|
|
134
|
+
load
|
|
134
135
|
],
|
|
136
|
+
entryFileName: 'index',
|
|
137
|
+
hidePageHeader: true,
|
|
135
138
|
hideBreadcrumbs: true,
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
pageTitleTemplates: {
|
|
140
|
+
module: '{kind}: {name}'
|
|
141
|
+
}
|
|
138
142
|
});
|
|
139
|
-
|
|
143
|
+
app = (yield setup(app)) || app;
|
|
144
|
+
const project = yield app.convert();
|
|
140
145
|
if (project) {
|
|
141
|
-
const absoluteApiDir = path.join(
|
|
142
|
-
yield app.
|
|
146
|
+
const absoluteApiDir = path.join(config.root, outDir);
|
|
147
|
+
yield app.outputs.writeOutput({
|
|
148
|
+
name: 'markdown',
|
|
149
|
+
path: absoluteApiDir
|
|
150
|
+
}, project);
|
|
143
151
|
yield patchGeneratedApiDocs(absoluteApiDir);
|
|
144
152
|
}
|
|
145
153
|
return config;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Application } from 'typedoc';
|
|
1
2
|
import type { RspressPlugin } from '@rspress/core';
|
|
2
3
|
|
|
3
4
|
export declare function pluginTypeDoc(options: PluginTypeDocOptions): RspressPlugin;
|
|
@@ -13,6 +14,11 @@ export declare interface PluginTypeDocOptions {
|
|
|
13
14
|
* @default 'api'
|
|
14
15
|
*/
|
|
15
16
|
outDir?: string;
|
|
17
|
+
/**
|
|
18
|
+
* A function to setup the TypeDoc Application.
|
|
19
|
+
* @param app
|
|
20
|
+
*/
|
|
21
|
+
setup?: (app: Application) => Promise<Application> | Promise<void> | void;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
export { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/plugin-typedoc",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.2",
|
|
4
4
|
"description": "A plugin for rspress to integrate typedoc",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -28,22 +28,22 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"typedoc": "0.
|
|
32
|
-
"typedoc-plugin-markdown": "
|
|
31
|
+
"typedoc": "0.28.15",
|
|
32
|
+
"typedoc-plugin-markdown": "4.9.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@microsoft/api-extractor": "^7.55.
|
|
36
|
-
"@rslib/core": "0.
|
|
35
|
+
"@microsoft/api-extractor": "^7.55.2",
|
|
36
|
+
"@rslib/core": "0.18.3",
|
|
37
37
|
"@types/node": "^22.8.1",
|
|
38
|
-
"@types/react": "^19.2.
|
|
38
|
+
"@types/react": "^19.2.7",
|
|
39
39
|
"@types/react-dom": "^19.2.3",
|
|
40
|
-
"react": "^19.2.
|
|
40
|
+
"react": "^19.2.1",
|
|
41
41
|
"rsbuild-plugin-publint": "^0.3.3",
|
|
42
42
|
"typescript": "^5.8.2",
|
|
43
43
|
"@rspress/config": "1.0.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@rspress/core": "^2.0.0-rc.
|
|
46
|
+
"@rspress/core": "^2.0.0-rc.2"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=18.0.0"
|