@rspress/plugin-typedoc 2.0.0-rc.2 → 2.0.0-rc.3

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/es/index.js +4 -30
  2. package/package.json +4 -4
package/dist/es/index.js CHANGED
@@ -29,36 +29,10 @@ function _async_to_generator(fn) {
29
29
  });
30
30
  };
31
31
  }
32
- function patchLinks(outputDir) {
33
- return _async_to_generator(function*() {
34
- const normalizeLinksInFile = (filePath)=>_async_to_generator(function*() {
35
- const content = yield promises.readFile(filePath, 'utf-8');
36
- const newContent = content.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, p1, p2)=>{
37
- if ([
38
- '/',
39
- '.'
40
- ].includes(p2[0]) || p2.startsWith('http://') || p2.startsWith('https://')) return `[${p1}](${p2})`;
41
- return `[${p1}](./${p2})`;
42
- });
43
- yield promises.writeFile(filePath, newContent);
44
- })();
45
- const traverse = (dir)=>_async_to_generator(function*() {
46
- const files = yield promises.readdir(dir);
47
- const filePaths = files.map((file)=>path.join(dir, file));
48
- const stats = yield Promise.all(filePaths.map((fp)=>promises.stat(fp)));
49
- yield Promise.all(stats.map((stat, index)=>{
50
- const file = files[index];
51
- const filePath = filePaths[index];
52
- if (stat.isDirectory()) return traverse(filePath);
53
- if (stat.isFile() && /\.mdx?/.test(file)) return normalizeLinksInFile(filePath);
54
- }));
55
- })();
56
- yield traverse(outputDir);
57
- })();
58
- }
59
32
  function generateMetaJson(absoluteApiDir) {
60
33
  return _async_to_generator(function*() {
61
34
  const metaJsonPath = path.join(absoluteApiDir, '_meta.json');
35
+ if (yield promises.access(metaJsonPath).then(()=>true).catch(()=>false)) return;
62
36
  const files = yield promises.readdir(absoluteApiDir);
63
37
  const filePaths = files.map((file)=>path.join(absoluteApiDir, file));
64
38
  const stats = yield Promise.all(filePaths.map((fp)=>promises.stat(fp)));
@@ -71,12 +45,11 @@ function generateMetaJson(absoluteApiDir) {
71
45
  yield promises.writeFile(metaJsonPath, JSON.stringify([
72
46
  'index',
73
47
  ...meta
74
- ]));
48
+ ], null, 2));
75
49
  })();
76
50
  }
77
51
  function patchGeneratedApiDocs(absoluteApiDir) {
78
52
  return _async_to_generator(function*() {
79
- yield patchLinks(absoluteApiDir);
80
53
  yield generateMetaJson(absoluteApiDir);
81
54
  })();
82
55
  }
@@ -138,7 +111,8 @@ function pluginTypeDoc(options) {
138
111
  hideBreadcrumbs: true,
139
112
  pageTitleTemplates: {
140
113
  module: '{kind}: {name}'
141
- }
114
+ },
115
+ cleanOutputDir: false
142
116
  });
143
117
  app = (yield setup(app)) || app;
144
118
  const project = yield app.convert();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/plugin-typedoc",
3
- "version": "2.0.0-rc.2",
3
+ "version": "2.0.0-rc.3",
4
4
  "description": "A plugin for rspress to integrate typedoc",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -33,17 +33,17 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@microsoft/api-extractor": "^7.55.2",
36
- "@rslib/core": "0.18.3",
36
+ "@rslib/core": "0.18.5",
37
37
  "@types/node": "^22.8.1",
38
38
  "@types/react": "^19.2.7",
39
39
  "@types/react-dom": "^19.2.3",
40
- "react": "^19.2.1",
40
+ "react": "^19.2.3",
41
41
  "rsbuild-plugin-publint": "^0.3.3",
42
42
  "typescript": "^5.8.2",
43
43
  "@rspress/config": "1.0.0"
44
44
  },
45
45
  "peerDependencies": {
46
- "@rspress/core": "^2.0.0-rc.2"
46
+ "@rspress/core": "^2.0.0-rc.3"
47
47
  },
48
48
  "engines": {
49
49
  "node": ">=18.0.0"