@rspress/plugin-typedoc 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.
Files changed (2) hide show
  1. package/dist/es/index.js +14 -22
  2. package/package.json +5 -5
package/dist/es/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import external_path_default from "path";
1
+ import path from "path";
2
2
  import { Application, TSConfigReader } from "typedoc";
3
3
  import { load } from "typedoc-plugin-markdown";
4
- import promises_default from "fs/promises";
4
+ import promises from "fs/promises";
5
5
  const API_DIR = 'api';
6
6
  async function patchLinks(outputDir) {
7
7
  const normalizeLinksInFile = async (filePath)=>{
8
- const content = await promises_default.readFile(filePath, 'utf-8');
8
+ const content = await promises.readFile(filePath, 'utf-8');
9
9
  const newContent = content.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, p1, p2)=>{
10
10
  if ([
11
11
  '/',
@@ -13,12 +13,12 @@ async function patchLinks(outputDir) {
13
13
  ].includes(p2[0])) return `[${p1}](${p2})`;
14
14
  return `[${p1}](./${p2})`;
15
15
  });
16
- await promises_default.writeFile(filePath, newContent);
16
+ await promises.writeFile(filePath, newContent);
17
17
  };
18
18
  const traverse = async (dir)=>{
19
- const files = await promises_default.readdir(dir);
20
- const filePaths = files.map((file)=>external_path_default.join(dir, file));
21
- const stats = await Promise.all(filePaths.map((fp)=>promises_default.stat(fp)));
19
+ const files = await promises.readdir(dir);
20
+ const filePaths = files.map((file)=>path.join(dir, file));
21
+ const stats = await Promise.all(filePaths.map((fp)=>promises.stat(fp)));
22
22
  await Promise.all(stats.map((stat, index)=>{
23
23
  const file = files[index];
24
24
  const filePath = filePaths[index];
@@ -29,24 +29,24 @@ async function patchLinks(outputDir) {
29
29
  await traverse(outputDir);
30
30
  }
31
31
  async function generateMetaJson(absoluteApiDir) {
32
- const metaJsonPath = external_path_default.join(absoluteApiDir, '_meta.json');
33
- const files = await promises_default.readdir(absoluteApiDir);
34
- const filePaths = files.map((file)=>external_path_default.join(absoluteApiDir, file));
35
- const stats = await Promise.all(filePaths.map((fp)=>promises_default.stat(fp)));
32
+ const metaJsonPath = path.join(absoluteApiDir, '_meta.json');
33
+ const files = await promises.readdir(absoluteApiDir);
34
+ const filePaths = files.map((file)=>path.join(absoluteApiDir, file));
35
+ const stats = await Promise.all(filePaths.map((fp)=>promises.stat(fp)));
36
36
  const dirs = stats.map((stat, index)=>stat.isDirectory() ? files[index] : null).filter(Boolean);
37
37
  const meta = dirs.map((dir)=>({
38
38
  type: 'dir',
39
39
  label: dir.slice(0, 1).toUpperCase() + dir.slice(1),
40
40
  name: dir
41
41
  }));
42
- await promises_default.writeFile(metaJsonPath, JSON.stringify([
42
+ await promises.writeFile(metaJsonPath, JSON.stringify([
43
43
  'index',
44
44
  ...meta
45
45
  ]));
46
46
  }
47
47
  async function patchGeneratedApiDocs(absoluteApiDir) {
48
48
  await patchLinks(absoluteApiDir);
49
- await promises_default.rename(external_path_default.join(absoluteApiDir, 'README.md'), external_path_default.join(absoluteApiDir, 'index.md'));
49
+ await promises.rename(path.join(absoluteApiDir, 'README.md'), path.join(absoluteApiDir, 'index.md'));
50
50
  await generateMetaJson(absoluteApiDir);
51
51
  }
52
52
  function pluginTypeDoc(options) {
@@ -55,14 +55,6 @@ function pluginTypeDoc(options) {
55
55
  const apiPageRoute = `/${outDir.replace(/(^\/)|(\/$)/, '')}/`;
56
56
  return {
57
57
  name: '@rspress/plugin-typedoc',
58
- async addPages () {
59
- return [
60
- {
61
- routePath: apiPageRoute,
62
- filepath: external_path_default.join(docRoot, outDir, 'README.md')
63
- }
64
- ];
65
- },
66
58
  async config (config) {
67
59
  const app = new Application();
68
60
  docRoot = config.root;
@@ -89,7 +81,7 @@ function pluginTypeDoc(options) {
89
81
  });
90
82
  const project = app.convert();
91
83
  if (project) {
92
- const absoluteApiDir = external_path_default.join(docRoot, outDir);
84
+ const absoluteApiDir = path.join(docRoot, outDir);
93
85
  await app.generateDocs(project, absoluteApiDir);
94
86
  await patchGeneratedApiDocs(absoluteApiDir);
95
87
  config.themeConfig = config.themeConfig || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/plugin-typedoc",
3
- "version": "2.0.0-beta.13",
3
+ "version": "2.0.0-beta.15",
4
4
  "description": "A plugin for rspress to integrate typedoc",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -30,13 +30,13 @@
30
30
  "dependencies": {
31
31
  "typedoc": "0.24.8",
32
32
  "typedoc-plugin-markdown": "3.17.1",
33
- "@rspress/shared": "2.0.0-beta.13"
33
+ "@rspress/shared": "2.0.0-beta.15"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@microsoft/api-extractor": "^7.52.8",
37
- "@rslib/core": "0.9.2",
37
+ "@rslib/core": "0.10.0",
38
38
  "@types/node": "^22.8.1",
39
- "@types/react": "^19.1.6",
39
+ "@types/react": "^19.1.8",
40
40
  "@types/react-dom": "^19.1.6",
41
41
  "react": "^19.1.0",
42
42
  "rsbuild-plugin-publint": "^0.3.2",
@@ -44,7 +44,7 @@
44
44
  "@rspress/config": "1.0.0"
45
45
  },
46
46
  "peerDependencies": {
47
- "rspress": "^2.0.0-beta.13"
47
+ "rspress": "^2.0.0-beta.15"
48
48
  },
49
49
  "engines": {
50
50
  "node": ">=18.0.0"