@rspress/plugin-api-docgen 2.0.0-alpha.6 → 2.0.0-alpha.8

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.
Files changed (2) hide show
  1. package/dist/index.js +11 -10
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -54,10 +54,10 @@ var __webpack_exports__ = {};
54
54
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
55
55
  const external_node_path_namespaceObject = require("node:path");
56
56
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
57
+ const logger_namespaceObject = require("@rspress/shared/logger");
57
58
  external_node_path_default().join(__dirname, '..');
58
59
  const apiDocMap = {};
59
60
  const shared_namespaceObject = require("@rspress/shared");
60
- const logger_namespaceObject = require("@rspress/shared/logger");
61
61
  const external_chokidar_namespaceObject = require("chokidar");
62
62
  var external_chokidar_default = /*#__PURE__*/ __webpack_require__.n(external_chokidar_namespaceObject);
63
63
  const external_react_docgen_typescript_namespaceObject = require("react-docgen-typescript");
@@ -266,9 +266,7 @@ var __webpack_exports__ = {};
266
266
  },
267
267
  async beforeBuild (config, isProd) {
268
268
  var _config_themeConfig_locales, _config_themeConfig, _config_locales;
269
- 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)) || [
270
- config.lang || 'en'
271
- ]).filter((lang)=>[
269
+ 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)) || []).filter((lang)=>[
272
270
  'zh',
273
271
  'en',
274
272
  'ru'
@@ -287,14 +285,15 @@ var __webpack_exports__ = {};
287
285
  await Promise.all(pages.map(async (page)=>{
288
286
  const { _filepath, lang } = page;
289
287
  let content = await external_node_fs_default().promises.readFile(_filepath, 'utf-8');
290
- let matchResult = new RegExp(apiCompRegExp).exec(content);
288
+ let matchResult = apiCompRegExp.exec(content);
291
289
  if (!matchResult) return;
292
290
  while(null !== matchResult){
293
291
  const matchContent = matchResult[0];
294
292
  const moduleName = matchResult[2] ?? matchResult[5] ?? '';
295
- 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'}`);
296
295
  content = content.replace(matchContent, apiDoc);
297
- matchResult = new RegExp(apiCompRegExp).exec(content);
296
+ matchResult = apiCompRegExp.exec(content);
298
297
  }
299
298
  page.content = content;
300
299
  }));
@@ -312,8 +311,10 @@ var __webpack_exports__ = {};
312
311
  };
313
312
  }
314
313
  })();
315
- var __webpack_export_target__ = exports;
316
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
317
- 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', {
318
319
  value: true
319
320
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/plugin-api-docgen",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.8",
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": {
@@ -23,14 +23,14 @@
23
23
  "react-docgen-typescript": "2.2.2",
24
24
  "react-markdown": "8.0.7",
25
25
  "remark-gfm": "3.0.1",
26
- "@rspress/shared": "2.0.0-alpha.6"
26
+ "@rspress/shared": "2.0.0-alpha.8"
27
27
  },
28
28
  "devDependencies": {
29
- "@microsoft/api-extractor": "^7.52.1",
30
- "@rslib/core": "0.5.5",
29
+ "@microsoft/api-extractor": "^7.52.2",
30
+ "@rslib/core": "0.6.0",
31
31
  "@types/mdast": "^3.0.15",
32
32
  "@types/node": "^18.11.17",
33
- "@types/react": "^18.3.19",
33
+ "@types/react": "^18.3.20",
34
34
  "@types/react-dom": "^18.3.5",
35
35
  "react": "^18.3.1",
36
36
  "react-dom": "^18.3.1",
@@ -40,7 +40,7 @@
40
40
  "unist-util-visit": "^4.1.2"
41
41
  },
42
42
  "peerDependencies": {
43
- "@rspress/core": "^2.0.0-alpha.6",
43
+ "@rspress/core": "^2.0.0-alpha.8",
44
44
  "react": ">=17.0.0",
45
45
  "react-router-dom": "^6.8.1",
46
46
  "typescript": "^5.8.2"