@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 = function(module) {
19
- var getter = module && module.__esModule ? function() {
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 = function(exports1, definition) {
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 = function(obj, prop) {
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 = function(exports1) {
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 === (_parseToolOptions_documentation = parseToolOptions.documentation) || void 0 === _parseToolOptions_documentation ? void 0 : _parseToolOptions_documentation.noReferenceLinks) ?? true
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 === (_config_themeConfig = config.themeConfig) || void 0 === _config_themeConfig ? void 0 : null === (_config_themeConfig_locales = _config_themeConfig.locales) || void 0 === _config_themeConfig_locales ? void 0 : _config_themeConfig_locales.map((locale)=>locale.lang)) || (null === (_config_locales = config.locales) || void 0 === _config_locales ? void 0 : _config_locales.map((locale)=>locale.lang)) || [
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 = new RegExp(apiCompRegExp).exec(content);
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 = new RegExp(apiCompRegExp).exec(content);
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
- var __webpack_export_target__ = exports;
322
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
323
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
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": "1.43.11",
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": "8.0.7",
25
- "remark-gfm": "3.0.1",
26
- "@rspress/shared": "1.43.11"
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.49.2",
30
- "@rslib/core": "0.5.2",
31
- "@types/mdast": "^3.0.15",
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.18",
34
- "@types/react-dom": "^18.3.5",
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.5.3",
39
- "unified": "^10.1.2",
40
- "unist-util-visit": "^4.1.2"
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": "^1.43.11",
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.5.3"
46
+ "typescript": "^5.8.2"
47
47
  },
48
48
  "peerDependenciesMeta": {
49
49
  "typescript": {
@@ -0,0 +1,9 @@
1
+ .rspress-plugin-api-docgen table {
2
+ table-layout: fixed;
3
+ width: 100%;
4
+ }
5
+
6
+ .rspress-plugin-api-docgen table td {
7
+ /* allow use 
 to break line */
8
+ white-space: pre-wrap;
9
+ }
@@ -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.scss';
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
- <ReactMarkdown
20
- remarkPlugins={[[remarkGfm]]}
21
- components={getCustomMDXComponent() as Record<string, React.ElementType>}
22
- skipHtml={true}
23
- className="rspress-plugin-api-docgen"
24
- >
25
- {apiDoc}
26
- </ReactMarkdown>
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
  };
@@ -1,11 +0,0 @@
1
- .rspress-plugin-api-docgen {
2
- table {
3
- table-layout: fixed;
4
- width: 100%;
5
-
6
- td {
7
- // allow use &#10; to break line
8
- white-space: pre-wrap;
9
- }
10
- }
11
- }