@rspress/plugin-api-docgen 1.43.11 → 2.0.0-alpha-canary-202504162001
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/index.js
CHANGED
@@ -15,12 +15,8 @@ function __webpack_require__(moduleId) {
|
|
15
15
|
return module.exports;
|
16
16
|
}
|
17
17
|
(()=>{
|
18
|
-
__webpack_require__.n =
|
19
|
-
var getter = module && module.__esModule ?
|
20
|
-
return module['default'];
|
21
|
-
} : function() {
|
22
|
-
return module;
|
23
|
-
};
|
18
|
+
__webpack_require__.n = (module)=>{
|
19
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
24
20
|
__webpack_require__.d(getter, {
|
25
21
|
a: getter
|
26
22
|
});
|
@@ -28,7 +24,7 @@ function __webpack_require__(moduleId) {
|
|
28
24
|
};
|
29
25
|
})();
|
30
26
|
(()=>{
|
31
|
-
__webpack_require__.d =
|
27
|
+
__webpack_require__.d = (exports1, definition)=>{
|
32
28
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
33
29
|
enumerable: true,
|
34
30
|
get: definition[key]
|
@@ -36,12 +32,10 @@ function __webpack_require__(moduleId) {
|
|
36
32
|
};
|
37
33
|
})();
|
38
34
|
(()=>{
|
39
|
-
__webpack_require__.o =
|
40
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
41
|
-
};
|
35
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
42
36
|
})();
|
43
37
|
(()=>{
|
44
|
-
__webpack_require__.r =
|
38
|
+
__webpack_require__.r = (exports1)=>{
|
45
39
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
46
40
|
value: 'Module'
|
47
41
|
});
|
@@ -60,10 +54,10 @@ var __webpack_exports__ = {};
|
|
60
54
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
61
55
|
const external_node_path_namespaceObject = require("node:path");
|
62
56
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
57
|
+
const logger_namespaceObject = require("@rspress/shared/logger");
|
63
58
|
external_node_path_default().join(__dirname, '..');
|
64
59
|
const apiDocMap = {};
|
65
60
|
const shared_namespaceObject = require("@rspress/shared");
|
66
|
-
const logger_namespaceObject = require("@rspress/shared/logger");
|
67
61
|
const external_chokidar_namespaceObject = require("chokidar");
|
68
62
|
var external_chokidar_default = /*#__PURE__*/ __webpack_require__.n(external_chokidar_namespaceObject);
|
69
63
|
const external_react_docgen_typescript_namespaceObject = require("react-docgen-typescript");
|
@@ -138,7 +132,7 @@ var __webpack_exports__ = {};
|
|
138
132
|
...parseToolOptions.documentation
|
139
133
|
});
|
140
134
|
const apiDoc = await documentation.formats.md(documentationRes, {
|
141
|
-
noReferenceLinks: (null
|
135
|
+
noReferenceLinks: (null == (_parseToolOptions_documentation = parseToolOptions.documentation) ? void 0 : _parseToolOptions_documentation.noReferenceLinks) ?? true
|
142
136
|
});
|
143
137
|
apiDocMap[key] = apiDoc;
|
144
138
|
} else {
|
@@ -272,9 +266,7 @@ var __webpack_exports__ = {};
|
|
272
266
|
},
|
273
267
|
async beforeBuild (config, isProd) {
|
274
268
|
var _config_themeConfig_locales, _config_themeConfig, _config_locales;
|
275
|
-
const languages = ((null
|
276
|
-
config.lang || 'en'
|
277
|
-
]).filter((lang)=>[
|
269
|
+
const languages = ((null == (_config_themeConfig = config.themeConfig) ? void 0 : null == (_config_themeConfig_locales = _config_themeConfig.locales) ? void 0 : _config_themeConfig_locales.map((locale)=>locale.lang)) || (null == (_config_locales = config.locales) ? void 0 : _config_locales.map((locale)=>locale.lang)) || []).filter((lang)=>[
|
278
270
|
'zh',
|
279
271
|
'en',
|
280
272
|
'ru'
|
@@ -293,14 +285,15 @@ var __webpack_exports__ = {};
|
|
293
285
|
await Promise.all(pages.map(async (page)=>{
|
294
286
|
const { _filepath, lang } = page;
|
295
287
|
let content = await external_node_fs_default().promises.readFile(_filepath, 'utf-8');
|
296
|
-
let matchResult =
|
288
|
+
let matchResult = apiCompRegExp.exec(content);
|
297
289
|
if (!matchResult) return;
|
298
290
|
while(null !== matchResult){
|
299
291
|
const matchContent = matchResult[0];
|
300
292
|
const moduleName = matchResult[2] ?? matchResult[5] ?? '';
|
301
|
-
const apiDoc = apiDocMap[moduleName] ?? apiDocMap[`${moduleName}-${lang}`] ?? '';
|
293
|
+
const apiDoc = apiDocMap[moduleName] ?? apiDocMap[`${moduleName}-${lang ? lang : 'en'}`] ?? '';
|
294
|
+
if (matchContent && !apiDoc) logger_namespaceObject.logger.warn(`No api doc found for module: ${moduleName} in lang: ${lang ?? 'en'}`);
|
302
295
|
content = content.replace(matchContent, apiDoc);
|
303
|
-
matchResult =
|
296
|
+
matchResult = apiCompRegExp.exec(content);
|
304
297
|
}
|
305
298
|
page.content = content;
|
306
299
|
}));
|
@@ -318,8 +311,10 @@ var __webpack_exports__ = {};
|
|
318
311
|
};
|
319
312
|
}
|
320
313
|
})();
|
321
|
-
|
322
|
-
for(var __webpack_i__ in __webpack_exports__)
|
323
|
-
|
314
|
+
exports.pluginApiDocgen = __webpack_exports__.pluginApiDocgen;
|
315
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
316
|
+
"pluginApiDocgen"
|
317
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
318
|
+
Object.defineProperty(exports, '__esModule', {
|
324
319
|
value: true
|
325
320
|
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/plugin-api-docgen",
|
3
|
-
"version": "
|
3
|
+
"version": "2.0.0-alpha-canary-202504162001",
|
4
4
|
"description": "A plugin for rspress to generate api doc.",
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
6
6
|
"repository": {
|
@@ -21,29 +21,29 @@
|
|
21
21
|
"chokidar": "^3.6.0",
|
22
22
|
"documentation": "14.0.3",
|
23
23
|
"react-docgen-typescript": "2.2.2",
|
24
|
-
"react-markdown": "
|
25
|
-
"remark-gfm": "
|
26
|
-
"@rspress/shared": "
|
24
|
+
"react-markdown": "^10.1.0",
|
25
|
+
"remark-gfm": "^4.0.1",
|
26
|
+
"@rspress/shared": "2.0.0-alpha-canary-202504162001"
|
27
27
|
},
|
28
28
|
"devDependencies": {
|
29
|
-
"@microsoft/api-extractor": "^7.
|
30
|
-
"@rslib/core": "0.
|
31
|
-
"@types/mdast": "^
|
29
|
+
"@microsoft/api-extractor": "^7.52.3",
|
30
|
+
"@rslib/core": "0.6.3",
|
31
|
+
"@types/mdast": "^4.0.4",
|
32
32
|
"@types/node": "^18.11.17",
|
33
|
-
"@types/react": "^18.3.
|
34
|
-
"@types/react-dom": "^18.3.
|
33
|
+
"@types/react": "^18.3.20",
|
34
|
+
"@types/react-dom": "^18.3.6",
|
35
35
|
"react": "^18.3.1",
|
36
36
|
"react-dom": "^18.3.1",
|
37
37
|
"react-router-dom": "^6.29.0",
|
38
|
-
"typescript": "^5.
|
39
|
-
"unified": "^
|
40
|
-
"unist-util-visit": "^
|
38
|
+
"typescript": "^5.8.2",
|
39
|
+
"unified": "^11.0.5",
|
40
|
+
"unist-util-visit": "^5.0.0"
|
41
41
|
},
|
42
42
|
"peerDependencies": {
|
43
|
-
"@rspress/core": "^
|
43
|
+
"@rspress/core": "^2.0.0-alpha-canary-202504162001",
|
44
44
|
"react": ">=17.0.0",
|
45
45
|
"react-router-dom": "^6.8.1",
|
46
|
-
"typescript": "^5.
|
46
|
+
"typescript": "^5.8.2"
|
47
47
|
},
|
48
48
|
"peerDependenciesMeta": {
|
49
49
|
"typescript": {
|
@@ -4,7 +4,7 @@ import { useLang, usePageData } from '@rspress/core/runtime';
|
|
4
4
|
import { getCustomMDXComponent } from '@rspress/core/theme';
|
5
5
|
import ReactMarkdown from 'react-markdown';
|
6
6
|
import remarkGfm from 'remark-gfm';
|
7
|
-
import './API.
|
7
|
+
import './API.css';
|
8
8
|
|
9
9
|
export default (props: { moduleName: string }) => {
|
10
10
|
const lang = useLang();
|
@@ -16,13 +16,16 @@ export default (props: { moduleName: string }) => {
|
|
16
16
|
const apiDoc =
|
17
17
|
apiDocMap?.[moduleName] || apiDocMap?.[`${moduleName}-${lang}`] || '';
|
18
18
|
return (
|
19
|
-
<
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
<div className="rspress-plugin-api-docgen">
|
20
|
+
<ReactMarkdown
|
21
|
+
remarkPlugins={[[remarkGfm]]}
|
22
|
+
components={
|
23
|
+
getCustomMDXComponent() as Record<string, React.ElementType>
|
24
|
+
}
|
25
|
+
skipHtml={true}
|
26
|
+
>
|
27
|
+
{apiDoc}
|
28
|
+
</ReactMarkdown>
|
29
|
+
</div>
|
27
30
|
);
|
28
31
|
};
|