@rspress/plugin-api-docgen 2.0.0-beta.31 → 2.0.0-beta.32
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 +6 -5
- package/package.json +3 -4
- package/static/global-components/API.tsx +11 -8
- package/index.d.ts +0 -8
package/dist/index.js
CHANGED
|
@@ -220,6 +220,12 @@ function pluginApiDocgen(options) {
|
|
|
220
220
|
parseToolOptions,
|
|
221
221
|
isProd
|
|
222
222
|
});
|
|
223
|
+
config.builderConfig = config.builderConfig || {};
|
|
224
|
+
config.builderConfig.source = config.builderConfig.source || {};
|
|
225
|
+
config.builderConfig.source.define = {
|
|
226
|
+
...config.builderConfig.source.define,
|
|
227
|
+
RSPRESS_PLUGIN_API_DOCGEN_MAP: JSON.stringify(apiDocMap)
|
|
228
|
+
};
|
|
223
229
|
},
|
|
224
230
|
async modifySearchIndexData (pages) {
|
|
225
231
|
const apiCompRegExp = /(<API\s+moduleName=['"](\S+)['"]\s*(.*)?\/>)|(<API\s+moduleName=['"](\S+)['"]\s*(.*)?>(.*)?<\/API>)/;
|
|
@@ -239,11 +245,6 @@ function pluginApiDocgen(options) {
|
|
|
239
245
|
page.content = content;
|
|
240
246
|
}));
|
|
241
247
|
},
|
|
242
|
-
extendPageData (pageData) {
|
|
243
|
-
pageData.apiDocMap = {
|
|
244
|
-
...apiDocMap
|
|
245
|
-
};
|
|
246
|
-
},
|
|
247
248
|
markdown: {
|
|
248
249
|
globalComponents: [
|
|
249
250
|
node_path.join(__dirname, '..', 'static', 'global-components', 'API.tsx')
|
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.32",
|
|
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": {
|
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"files": [
|
|
21
21
|
"dist",
|
|
22
|
-
"static"
|
|
23
|
-
"index.d.ts"
|
|
22
|
+
"static"
|
|
24
23
|
],
|
|
25
24
|
"dependencies": {
|
|
26
25
|
"chokidar": "^3.6.0",
|
|
@@ -47,7 +46,7 @@
|
|
|
47
46
|
"typescript": "^5.8.2"
|
|
48
47
|
},
|
|
49
48
|
"peerDependencies": {
|
|
50
|
-
"@rspress/core": "^2.0.0-beta.
|
|
49
|
+
"@rspress/core": "^2.0.0-beta.32",
|
|
51
50
|
"typescript": "^5.8.2"
|
|
52
51
|
},
|
|
53
52
|
"peerDependenciesMeta": {
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { useLang, usePageData } from '@rspress/core/runtime';
|
|
1
|
+
import { useLang } from '@rspress/core/runtime';
|
|
4
2
|
// @ts-expect-error @theme is overridden by alias in @rspress/core
|
|
5
3
|
import { getCustomMDXComponent } from '@theme';
|
|
4
|
+
import GithubSlugger from 'github-slugger';
|
|
5
|
+
import type { Content, Element, Root } from 'hast';
|
|
6
6
|
import ReactMarkdown from 'react-markdown';
|
|
7
7
|
import remarkGfm from 'remark-gfm';
|
|
8
8
|
import './API.css';
|
|
9
|
-
import GithubSlugger from 'github-slugger';
|
|
10
|
-
import type { Content, Element, Root } from 'hast';
|
|
11
9
|
// biome-ignore lint/style/useImportType: <exact>
|
|
12
10
|
import React from 'react';
|
|
13
11
|
import type { Plugin } from 'unified';
|
|
14
12
|
import { visit } from 'unist-util-visit';
|
|
15
13
|
|
|
14
|
+
declare global {
|
|
15
|
+
var RSPRESS_PLUGIN_API_DOCGEN_MAP: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
|
|
16
18
|
function headingRank(node: Root | Content): number | null {
|
|
17
19
|
const name =
|
|
18
20
|
(node && node.type === 'element' && node.tagName.toLowerCase()) || '';
|
|
@@ -98,12 +100,11 @@ const collectHeaderText = (node: Element): string => {
|
|
|
98
100
|
return text;
|
|
99
101
|
};
|
|
100
102
|
|
|
101
|
-
|
|
103
|
+
const API = (props: { moduleName: string }) => {
|
|
102
104
|
const lang = useLang();
|
|
103
|
-
const { page } = usePageData();
|
|
104
105
|
const { moduleName } = props;
|
|
105
106
|
// some api doc have two languages.
|
|
106
|
-
const apiDocMap =
|
|
107
|
+
const apiDocMap = RSPRESS_PLUGIN_API_DOCGEN_MAP;
|
|
107
108
|
// avoid error when no page data
|
|
108
109
|
const apiDoc =
|
|
109
110
|
apiDocMap?.[moduleName] || apiDocMap?.[`${moduleName}-${lang}`] || '';
|
|
@@ -122,3 +123,5 @@ export default (props: { moduleName: string }) => {
|
|
|
122
123
|
</div>
|
|
123
124
|
);
|
|
124
125
|
};
|
|
126
|
+
|
|
127
|
+
export default API;
|