@rspress/plugin-typedoc 2.0.0-beta.0 → 2.0.0-beta.10
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/README.md +1 -1
- package/package.json +18 -11
- package/dist/lib/index.js +0 -165
- /package/dist/es/{index.mjs → index.js} +0 -0
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/plugin-typedoc",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.10",
|
|
4
4
|
"description": "A plugin for rspress to integrate typedoc",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/web-infra-dev/rspress",
|
|
8
|
+
"url": "git+https://github.com/web-infra-dev/rspress.git",
|
|
9
9
|
"directory": "packages/plugin-typedoc"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
@@ -15,7 +15,13 @@
|
|
|
15
15
|
"*.sass",
|
|
16
16
|
"*.scss"
|
|
17
17
|
],
|
|
18
|
-
"
|
|
18
|
+
"type": "module",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
22
|
+
"import": "./dist/es/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
19
25
|
"module": "./dist/es/index.js",
|
|
20
26
|
"types": "./dist/types/index.d.ts",
|
|
21
27
|
"files": [
|
|
@@ -24,23 +30,24 @@
|
|
|
24
30
|
"dependencies": {
|
|
25
31
|
"typedoc": "0.24.8",
|
|
26
32
|
"typedoc-plugin-markdown": "3.17.1",
|
|
27
|
-
"@rspress/shared": "2.0.0-beta.
|
|
33
|
+
"@rspress/shared": "2.0.0-beta.10"
|
|
28
34
|
},
|
|
29
35
|
"devDependencies": {
|
|
30
|
-
"@microsoft/api-extractor": "^7.52.
|
|
31
|
-
"@rslib/core": "0.
|
|
32
|
-
"@types/node": "^
|
|
33
|
-
"@types/react": "^18.3.
|
|
34
|
-
"@types/react-dom": "^18.3.
|
|
36
|
+
"@microsoft/api-extractor": "^7.52.8",
|
|
37
|
+
"@rslib/core": "0.8.0",
|
|
38
|
+
"@types/node": "^22.8.1",
|
|
39
|
+
"@types/react": "^18.3.22",
|
|
40
|
+
"@types/react-dom": "^18.3.7",
|
|
35
41
|
"react": "^19.1.0",
|
|
42
|
+
"rsbuild-plugin-publint": "^0.3.2",
|
|
36
43
|
"typescript": "^5.8.2",
|
|
37
44
|
"@rspress/config": "1.0.0"
|
|
38
45
|
},
|
|
39
46
|
"peerDependencies": {
|
|
40
|
-
"rspress": "^2.0.0-beta.
|
|
47
|
+
"rspress": "^2.0.0-beta.10"
|
|
41
48
|
},
|
|
42
49
|
"engines": {
|
|
43
|
-
"node": ">=
|
|
50
|
+
"node": ">=18.0.0"
|
|
44
51
|
},
|
|
45
52
|
"publishConfig": {
|
|
46
53
|
"access": "public",
|
package/dist/lib/index.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
-
value: 'Module'
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
-
value: true
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __webpack_exports__ = {};
|
|
34
|
-
__webpack_require__.r(__webpack_exports__);
|
|
35
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
pluginTypeDoc: ()=>pluginTypeDoc
|
|
37
|
-
});
|
|
38
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
39
|
-
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
40
|
-
const external_typedoc_namespaceObject = require("typedoc");
|
|
41
|
-
const external_typedoc_plugin_markdown_namespaceObject = require("typedoc-plugin-markdown");
|
|
42
|
-
const API_DIR = 'api';
|
|
43
|
-
const promises_namespaceObject = require("node:fs/promises");
|
|
44
|
-
var promises_default = /*#__PURE__*/ __webpack_require__.n(promises_namespaceObject);
|
|
45
|
-
async function patchLinks(outputDir) {
|
|
46
|
-
const normalizeLinksInFile = async (filePath)=>{
|
|
47
|
-
const content = await promises_default().readFile(filePath, 'utf-8');
|
|
48
|
-
const newContent = content.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, p1, p2)=>{
|
|
49
|
-
if ([
|
|
50
|
-
'/',
|
|
51
|
-
'.'
|
|
52
|
-
].includes(p2[0])) return `[${p1}](${p2})`;
|
|
53
|
-
return `[${p1}](./${p2})`;
|
|
54
|
-
});
|
|
55
|
-
await promises_default().writeFile(filePath, newContent);
|
|
56
|
-
};
|
|
57
|
-
const traverse = async (dir)=>{
|
|
58
|
-
const files = await promises_default().readdir(dir);
|
|
59
|
-
const filePaths = files.map((file)=>external_node_path_default().join(dir, file));
|
|
60
|
-
const stats = await Promise.all(filePaths.map((fp)=>promises_default().stat(fp)));
|
|
61
|
-
await Promise.all(stats.map((stat, index)=>{
|
|
62
|
-
const file = files[index];
|
|
63
|
-
const filePath = filePaths[index];
|
|
64
|
-
if (stat.isDirectory()) return traverse(filePath);
|
|
65
|
-
if (stat.isFile() && /\.mdx?/.test(file)) return normalizeLinksInFile(filePath);
|
|
66
|
-
}));
|
|
67
|
-
};
|
|
68
|
-
await traverse(outputDir);
|
|
69
|
-
}
|
|
70
|
-
async function generateMetaJson(absoluteApiDir) {
|
|
71
|
-
const metaJsonPath = external_node_path_default().join(absoluteApiDir, '_meta.json');
|
|
72
|
-
const files = await promises_default().readdir(absoluteApiDir);
|
|
73
|
-
const filePaths = files.map((file)=>external_node_path_default().join(absoluteApiDir, file));
|
|
74
|
-
const stats = await Promise.all(filePaths.map((fp)=>promises_default().stat(fp)));
|
|
75
|
-
const dirs = stats.map((stat, index)=>stat.isDirectory() ? files[index] : null).filter(Boolean);
|
|
76
|
-
const meta = dirs.map((dir)=>({
|
|
77
|
-
type: 'dir',
|
|
78
|
-
label: dir.slice(0, 1).toUpperCase() + dir.slice(1),
|
|
79
|
-
name: dir
|
|
80
|
-
}));
|
|
81
|
-
await promises_default().writeFile(metaJsonPath, JSON.stringify([
|
|
82
|
-
'index',
|
|
83
|
-
...meta
|
|
84
|
-
]));
|
|
85
|
-
}
|
|
86
|
-
async function patchGeneratedApiDocs(absoluteApiDir) {
|
|
87
|
-
await patchLinks(absoluteApiDir);
|
|
88
|
-
await promises_default().rename(external_node_path_default().join(absoluteApiDir, 'README.md'), external_node_path_default().join(absoluteApiDir, 'index.md'));
|
|
89
|
-
await generateMetaJson(absoluteApiDir);
|
|
90
|
-
}
|
|
91
|
-
function pluginTypeDoc(options) {
|
|
92
|
-
let docRoot;
|
|
93
|
-
const { entryPoints = [], outDir = API_DIR } = options;
|
|
94
|
-
const apiPageRoute = `/${outDir.replace(/(^\/)|(\/$)/, '')}/`;
|
|
95
|
-
return {
|
|
96
|
-
name: '@rspress/plugin-typedoc',
|
|
97
|
-
async addPages () {
|
|
98
|
-
return [
|
|
99
|
-
{
|
|
100
|
-
routePath: apiPageRoute,
|
|
101
|
-
filepath: external_node_path_default().join(docRoot, outDir, 'README.md')
|
|
102
|
-
}
|
|
103
|
-
];
|
|
104
|
-
},
|
|
105
|
-
async config (config) {
|
|
106
|
-
const app = new external_typedoc_namespaceObject.Application();
|
|
107
|
-
docRoot = config.root;
|
|
108
|
-
app.options.addReader(new external_typedoc_namespaceObject.TSConfigReader());
|
|
109
|
-
(0, external_typedoc_plugin_markdown_namespaceObject.load)(app);
|
|
110
|
-
app.bootstrap({
|
|
111
|
-
name: config.title,
|
|
112
|
-
entryPoints,
|
|
113
|
-
theme: 'markdown',
|
|
114
|
-
disableSources: true,
|
|
115
|
-
readme: 'none',
|
|
116
|
-
githubPages: false,
|
|
117
|
-
requiredToBeDocumented: [
|
|
118
|
-
'Class',
|
|
119
|
-
'Function',
|
|
120
|
-
'Interface'
|
|
121
|
-
],
|
|
122
|
-
plugin: [
|
|
123
|
-
'typedoc-plugin-markdown'
|
|
124
|
-
],
|
|
125
|
-
hideBreadcrumbs: true,
|
|
126
|
-
hideMembersSymbol: true,
|
|
127
|
-
allReflectionsHaveOwnDocument: true
|
|
128
|
-
});
|
|
129
|
-
const project = app.convert();
|
|
130
|
-
if (project) {
|
|
131
|
-
const absoluteApiDir = external_node_path_default().join(docRoot, outDir);
|
|
132
|
-
await app.generateDocs(project, absoluteApiDir);
|
|
133
|
-
await patchGeneratedApiDocs(absoluteApiDir);
|
|
134
|
-
config.themeConfig = config.themeConfig || {};
|
|
135
|
-
config.themeConfig.nav = config.themeConfig.nav || [];
|
|
136
|
-
const { nav } = config.themeConfig;
|
|
137
|
-
function isApiAlreadyInNav(navList) {
|
|
138
|
-
return navList.some((item)=>{
|
|
139
|
-
if ('link' in item && 'string' == typeof item.link && item.link.startsWith(apiPageRoute.slice(0, apiPageRoute.length - 1))) return true;
|
|
140
|
-
return false;
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
if (Array.isArray(nav)) {
|
|
144
|
-
if (!isApiAlreadyInNav(nav)) nav.push({
|
|
145
|
-
text: 'API',
|
|
146
|
-
link: apiPageRoute
|
|
147
|
-
});
|
|
148
|
-
} else if ('default' in nav) {
|
|
149
|
-
if (!isApiAlreadyInNav(nav.default)) nav.default.push({
|
|
150
|
-
text: 'API',
|
|
151
|
-
link: apiPageRoute
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return config;
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
exports.pluginTypeDoc = __webpack_exports__.pluginTypeDoc;
|
|
160
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
161
|
-
"pluginTypeDoc"
|
|
162
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
163
|
-
Object.defineProperty(exports, '__esModule', {
|
|
164
|
-
value: true
|
|
165
|
-
});
|
|
File without changes
|