@rspress/plugin-typedoc 1.38.0 → 1.39.1
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.mjs +1 -13
- package/dist/lib/index.js +3 -24
- package/package.json +8 -8
package/dist/es/index.mjs
CHANGED
|
@@ -4,16 +4,9 @@ import * as __WEBPACK_EXTERNAL_MODULE_typedoc_plugin_markdown__ from "typedoc-pl
|
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_fs_extra__ from "@rspress/shared/fs-extra";
|
|
5
5
|
const API_DIR = 'api';
|
|
6
6
|
async function patchLinks(outputDir) {
|
|
7
|
-
// Patch links in markdown files
|
|
8
|
-
// Scan all the markdown files in the output directory
|
|
9
|
-
// replace
|
|
10
|
-
// 1. [foo](bar) -> [foo](./bar)
|
|
11
|
-
// 2. [foo](./bar) -> [foo](./bar) no change
|
|
12
7
|
const normlizeLinksInFile = async (filePath)=>{
|
|
13
8
|
const content = await __WEBPACK_EXTERNAL_MODULE__rspress_shared_fs_extra__["default"].readFile(filePath, 'utf-8');
|
|
14
|
-
// 1. [foo](bar) -> [foo](./bar)
|
|
15
9
|
const newContent = content.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, p1, p2)=>{
|
|
16
|
-
// 2. [foo](./bar) -> [foo](./bar) no change
|
|
17
10
|
if ([
|
|
18
11
|
'/',
|
|
19
12
|
'.'
|
|
@@ -59,7 +52,7 @@ async function patchGeneratedApiDocs(absoluteApiDir) {
|
|
|
59
52
|
function pluginTypeDoc(options) {
|
|
60
53
|
let docRoot;
|
|
61
54
|
const { entryPoints = [], outDir = API_DIR } = options;
|
|
62
|
-
const apiPageRoute = `/${outDir.replace(/(^\/)|(\/$)/, '')}/`;
|
|
55
|
+
const apiPageRoute = `/${outDir.replace(/(^\/)|(\/$)/, '')}/`;
|
|
63
56
|
return {
|
|
64
57
|
name: '@rspress/plugin-typedoc',
|
|
65
58
|
async addPages () {
|
|
@@ -90,29 +83,24 @@ function pluginTypeDoc(options) {
|
|
|
90
83
|
plugin: [
|
|
91
84
|
'typedoc-plugin-markdown'
|
|
92
85
|
],
|
|
93
|
-
// @ts-expect-error MarkdownTheme has no export
|
|
94
86
|
hideBreadcrumbs: true,
|
|
95
87
|
hideMembersSymbol: true,
|
|
96
88
|
allReflectionsHaveOwnDocument: true
|
|
97
89
|
});
|
|
98
90
|
const project = app.convert();
|
|
99
91
|
if (project) {
|
|
100
|
-
// 1. Generate doc/api, doc/api/_meta.json by typedoc
|
|
101
92
|
const absoluteApiDir = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].join(docRoot, outDir);
|
|
102
93
|
await app.generateDocs(project, absoluteApiDir);
|
|
103
94
|
await patchGeneratedApiDocs(absoluteApiDir);
|
|
104
|
-
// 2. Generate "api" nav bar
|
|
105
95
|
config.themeConfig = config.themeConfig || {};
|
|
106
96
|
config.themeConfig.nav = config.themeConfig.nav || [];
|
|
107
97
|
const { nav } = config.themeConfig;
|
|
108
|
-
// avoid that user config "api" in doc/_meta.json
|
|
109
98
|
function isApiAlreadyInNav(navList) {
|
|
110
99
|
return navList.some((item)=>{
|
|
111
100
|
if ('link' in item && 'string' == typeof item.link && item.link.startsWith(apiPageRoute.slice(0, apiPageRoute.length - 1))) return true;
|
|
112
101
|
return false;
|
|
113
102
|
});
|
|
114
103
|
}
|
|
115
|
-
// Note: TypeDoc does not support i18n
|
|
116
104
|
if (Array.isArray(nav)) {
|
|
117
105
|
if (!isApiAlreadyInNav(nav)) nav.push({
|
|
118
106
|
text: 'API',
|
package/dist/lib/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// The require scope
|
|
3
2
|
var __webpack_require__ = {};
|
|
4
|
-
/************************************************************************/ // webpack/runtime/compat_get_default_export
|
|
5
3
|
(()=>{
|
|
6
|
-
// getDefaultExport function for compatibility with non-ESM modules
|
|
7
4
|
__webpack_require__.n = function(module) {
|
|
8
5
|
var getter = module && module.__esModule ? function() {
|
|
9
6
|
return module['default'];
|
|
@@ -16,7 +13,6 @@ var __webpack_require__ = {};
|
|
|
16
13
|
return getter;
|
|
17
14
|
};
|
|
18
15
|
})();
|
|
19
|
-
// webpack/runtime/define_property_getters
|
|
20
16
|
(()=>{
|
|
21
17
|
__webpack_require__.d = function(exports1, definition) {
|
|
22
18
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -25,15 +21,12 @@ var __webpack_require__ = {};
|
|
|
25
21
|
});
|
|
26
22
|
};
|
|
27
23
|
})();
|
|
28
|
-
// webpack/runtime/has_own_property
|
|
29
24
|
(()=>{
|
|
30
25
|
__webpack_require__.o = function(obj, prop) {
|
|
31
26
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
32
27
|
};
|
|
33
28
|
})();
|
|
34
|
-
// webpack/runtime/make_namespace_object
|
|
35
29
|
(()=>{
|
|
36
|
-
// define __esModule on exports
|
|
37
30
|
__webpack_require__.r = function(exports1) {
|
|
38
31
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
39
32
|
value: 'Module'
|
|
@@ -43,12 +36,10 @@ var __webpack_require__ = {};
|
|
|
43
36
|
});
|
|
44
37
|
};
|
|
45
38
|
})();
|
|
46
|
-
|
|
47
|
-
// ESM COMPAT FLAG
|
|
39
|
+
var __webpack_exports__ = {};
|
|
48
40
|
__webpack_require__.r(__webpack_exports__);
|
|
49
|
-
// EXPORTS
|
|
50
41
|
__webpack_require__.d(__webpack_exports__, {
|
|
51
|
-
pluginTypeDoc: ()
|
|
42
|
+
pluginTypeDoc: ()=>pluginTypeDoc
|
|
52
43
|
});
|
|
53
44
|
const external_node_path_namespaceObject = require("node:path");
|
|
54
45
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
@@ -58,16 +49,9 @@ const API_DIR = 'api';
|
|
|
58
49
|
const fs_extra_namespaceObject = require("@rspress/shared/fs-extra");
|
|
59
50
|
var fs_extra_default = /*#__PURE__*/ __webpack_require__.n(fs_extra_namespaceObject);
|
|
60
51
|
async function patchLinks(outputDir) {
|
|
61
|
-
// Patch links in markdown files
|
|
62
|
-
// Scan all the markdown files in the output directory
|
|
63
|
-
// replace
|
|
64
|
-
// 1. [foo](bar) -> [foo](./bar)
|
|
65
|
-
// 2. [foo](./bar) -> [foo](./bar) no change
|
|
66
52
|
const normlizeLinksInFile = async (filePath)=>{
|
|
67
53
|
const content = await fs_extra_default().readFile(filePath, 'utf-8');
|
|
68
|
-
// 1. [foo](bar) -> [foo](./bar)
|
|
69
54
|
const newContent = content.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, p1, p2)=>{
|
|
70
|
-
// 2. [foo](./bar) -> [foo](./bar) no change
|
|
71
55
|
if ([
|
|
72
56
|
'/',
|
|
73
57
|
'.'
|
|
@@ -113,7 +97,7 @@ async function patchGeneratedApiDocs(absoluteApiDir) {
|
|
|
113
97
|
function pluginTypeDoc(options) {
|
|
114
98
|
let docRoot;
|
|
115
99
|
const { entryPoints = [], outDir = API_DIR } = options;
|
|
116
|
-
const apiPageRoute = `/${outDir.replace(/(^\/)|(\/$)/, '')}/`;
|
|
100
|
+
const apiPageRoute = `/${outDir.replace(/(^\/)|(\/$)/, '')}/`;
|
|
117
101
|
return {
|
|
118
102
|
name: '@rspress/plugin-typedoc',
|
|
119
103
|
async addPages () {
|
|
@@ -144,29 +128,24 @@ function pluginTypeDoc(options) {
|
|
|
144
128
|
plugin: [
|
|
145
129
|
'typedoc-plugin-markdown'
|
|
146
130
|
],
|
|
147
|
-
// @ts-expect-error MarkdownTheme has no export
|
|
148
131
|
hideBreadcrumbs: true,
|
|
149
132
|
hideMembersSymbol: true,
|
|
150
133
|
allReflectionsHaveOwnDocument: true
|
|
151
134
|
});
|
|
152
135
|
const project = app.convert();
|
|
153
136
|
if (project) {
|
|
154
|
-
// 1. Generate doc/api, doc/api/_meta.json by typedoc
|
|
155
137
|
const absoluteApiDir = external_node_path_default().join(docRoot, outDir);
|
|
156
138
|
await app.generateDocs(project, absoluteApiDir);
|
|
157
139
|
await patchGeneratedApiDocs(absoluteApiDir);
|
|
158
|
-
// 2. Generate "api" nav bar
|
|
159
140
|
config.themeConfig = config.themeConfig || {};
|
|
160
141
|
config.themeConfig.nav = config.themeConfig.nav || [];
|
|
161
142
|
const { nav } = config.themeConfig;
|
|
162
|
-
// avoid that user config "api" in doc/_meta.json
|
|
163
143
|
function isApiAlreadyInNav(navList) {
|
|
164
144
|
return navList.some((item)=>{
|
|
165
145
|
if ('link' in item && 'string' == typeof item.link && item.link.startsWith(apiPageRoute.slice(0, apiPageRoute.length - 1))) return true;
|
|
166
146
|
return false;
|
|
167
147
|
});
|
|
168
148
|
}
|
|
169
|
-
// Note: TypeDoc does not support i18n
|
|
170
149
|
if (Array.isArray(nav)) {
|
|
171
150
|
if (!isApiAlreadyInNav(nav)) nav.push({
|
|
172
151
|
text: 'API',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/plugin-typedoc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.1",
|
|
4
4
|
"description": "A plugin for rspress to integrate typedoc",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"node": ">=14.17.6"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@microsoft/api-extractor": "^7.48.
|
|
21
|
-
"@modern-js/tsconfig": "2.63.
|
|
22
|
-
"@rslib/core": "0.1.
|
|
20
|
+
"@microsoft/api-extractor": "^7.48.1",
|
|
21
|
+
"@modern-js/tsconfig": "2.63.3",
|
|
22
|
+
"@rslib/core": "0.1.5",
|
|
23
23
|
"@types/node": "^18.11.17",
|
|
24
|
-
"@types/react": "^18.3.
|
|
25
|
-
"@types/react-dom": "^18.3.
|
|
24
|
+
"@types/react": "^18.3.18",
|
|
25
|
+
"@types/react-dom": "^18.3.5",
|
|
26
26
|
"react": "^18.3.1",
|
|
27
27
|
"typescript": "^5.5.3",
|
|
28
28
|
"vitest": "2.1.8"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"rspress": "^1.
|
|
31
|
+
"rspress": "^1.39.1"
|
|
32
32
|
},
|
|
33
33
|
"sideEffects": [
|
|
34
34
|
"*.css",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"typedoc": "0.24.8",
|
|
50
50
|
"typedoc-plugin-markdown": "3.17.1",
|
|
51
|
-
"@rspress/shared": "1.
|
|
51
|
+
"@rspress/shared": "1.39.1"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"dev": "rslib build -w",
|