@rspress/plugin-api-docgen 2.0.0-beta.13 → 2.0.0-beta.15
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 +10 -10
- package/package.json +5 -5
package/dist/index.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
import
|
2
|
-
import
|
1
|
+
import node_fs from "node:fs";
|
2
|
+
import node_path from "node:path";
|
3
3
|
import { logger } from "@rspress/shared/logger";
|
4
4
|
import { RSPRESS_TEMP_DIR } from "@rspress/shared";
|
5
|
-
import
|
5
|
+
import chokidar from "chokidar";
|
6
6
|
import { withCompilerOptions, withCustomConfig, withDefaultConfig } from "react-docgen-typescript";
|
7
|
-
|
7
|
+
node_path.join(__dirname, '..');
|
8
8
|
const apiDocMap = {};
|
9
9
|
const locales = {
|
10
10
|
zh: {
|
@@ -62,7 +62,7 @@ const docgen = async ({ entries, languages, apiParseTool, appDir, parseToolOptio
|
|
62
62
|
const genApiDoc = async (entry, tool)=>{
|
63
63
|
if (0 === Object.keys(entry).length) return;
|
64
64
|
await Promise.all(Object.entries(entry).map(async ([key, value])=>{
|
65
|
-
const moduleSourceFilePath =
|
65
|
+
const moduleSourceFilePath = node_path.resolve(appDir, value);
|
66
66
|
watchFileMap[moduleSourceFilePath] = {
|
67
67
|
apiParseTool,
|
68
68
|
moduleName: key
|
@@ -116,7 +116,7 @@ const docgen = async ({ entries, languages, apiParseTool, appDir, parseToolOptio
|
|
116
116
|
]);
|
117
117
|
} else await genApiDoc(entries, apiParseTool);
|
118
118
|
if (!isProd) {
|
119
|
-
const watcher =
|
119
|
+
const watcher = chokidar.watch(Object.keys(watchFileMap), {
|
120
120
|
ignoreInitial: true,
|
121
121
|
ignorePermissionErrors: true,
|
122
122
|
ignored: [
|
@@ -132,7 +132,7 @@ const docgen = async ({ entries, languages, apiParseTool, appDir, parseToolOptio
|
|
132
132
|
if (watchFileInfo) {
|
133
133
|
const { apiParseTool, moduleName } = watchFileInfo;
|
134
134
|
const updateSiteData = ()=>{
|
135
|
-
const siteDataPath =
|
135
|
+
const siteDataPath = node_path.join(process.cwd(), 'node_modules', RSPRESS_TEMP_DIR, 'runtime', 'virtual-site-data.mjs');
|
136
136
|
import(siteDataPath).then((siteData)=>{
|
137
137
|
const data = {
|
138
138
|
...siteData.default
|
@@ -140,7 +140,7 @@ const docgen = async ({ entries, languages, apiParseTool, appDir, parseToolOptio
|
|
140
140
|
data.pages.forEach((page)=>{
|
141
141
|
page.apiDocMap = apiDocMap;
|
142
142
|
});
|
143
|
-
|
143
|
+
node_fs.writeFileSync(siteDataPath, `export default ${JSON.stringify(data)}`);
|
144
144
|
isUpdate = false;
|
145
145
|
});
|
146
146
|
};
|
@@ -226,7 +226,7 @@ function pluginApiDocgen(options) {
|
|
226
226
|
const apiCompRegExp = /(<API\s+moduleName=['"](\S+)['"]\s*(.*)?\/>)|(<API\s+moduleName=['"](\S+)['"]\s*(.*)?>(.*)?<\/API>)/;
|
227
227
|
await Promise.all(pages.map(async (page)=>{
|
228
228
|
const { _filepath, lang } = page;
|
229
|
-
let content = await
|
229
|
+
let content = await node_fs.promises.readFile(_filepath, 'utf-8');
|
230
230
|
let matchResult = apiCompRegExp.exec(content);
|
231
231
|
if (!matchResult) return;
|
232
232
|
while(null !== matchResult){
|
@@ -247,7 +247,7 @@ function pluginApiDocgen(options) {
|
|
247
247
|
},
|
248
248
|
markdown: {
|
249
249
|
globalComponents: [
|
250
|
-
|
250
|
+
node_path.join(__dirname, '..', 'static', 'global-components', 'API.tsx')
|
251
251
|
]
|
252
252
|
}
|
253
253
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/plugin-api-docgen",
|
3
|
-
"version": "2.0.0-beta.
|
3
|
+
"version": "2.0.0-beta.15",
|
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": {
|
@@ -31,15 +31,15 @@
|
|
31
31
|
"remark-gfm": "^4.0.1",
|
32
32
|
"unified": "^11.0.5",
|
33
33
|
"unist-util-visit": "^5.0.0",
|
34
|
-
"@rspress/shared": "2.0.0-beta.
|
34
|
+
"@rspress/shared": "2.0.0-beta.15"
|
35
35
|
},
|
36
36
|
"devDependencies": {
|
37
37
|
"@microsoft/api-extractor": "^7.52.8",
|
38
|
-
"@rslib/core": "0.
|
38
|
+
"@rslib/core": "0.10.0",
|
39
39
|
"@types/hast": "^3.0.4",
|
40
40
|
"@types/mdast": "^4.0.4",
|
41
41
|
"@types/node": "^22.8.1",
|
42
|
-
"@types/react": "^19.1.
|
42
|
+
"@types/react": "^19.1.8",
|
43
43
|
"@types/react-dom": "^19.1.6",
|
44
44
|
"react": "^19.1.0",
|
45
45
|
"react-dom": "^19.1.0",
|
@@ -48,7 +48,7 @@
|
|
48
48
|
"typescript": "^5.8.2"
|
49
49
|
},
|
50
50
|
"peerDependencies": {
|
51
|
-
"@rspress/core": "^2.0.0-beta.
|
51
|
+
"@rspress/core": "^2.0.0-beta.15",
|
52
52
|
"typescript": "^5.8.2"
|
53
53
|
},
|
54
54
|
"peerDependenciesMeta": {
|