Skip to content

Commit abb5f2b

Browse files
authored
chore: add doc example (#6)
* chore: add doc example * chore: update lock
1 parent 4e90bc8 commit abb5f2b

File tree

16 files changed

+5459
-557
lines changed

16 files changed

+5459
-557
lines changed

pnpm-lock.yaml

Lines changed: 5144 additions & 557 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/doc/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Rslib project
2+
3+
## Setup
4+
5+
Install the dependencies:
6+
7+
```bash
8+
pnpm install
9+
```
10+
11+
## Get started
12+
13+
Build the library:
14+
15+
```bash
16+
pnpm build
17+
```
18+
19+
Build the library in watch mode:
20+
21+
```bash
22+
pnpm dev
23+
```
24+
25+
Start the doc dev server:
26+
27+
```bash
28+
pnpm doc
29+
```
30+
31+
Build the doc for production:
32+
33+
```bash
34+
pnpm doc:build
35+
```
36+
37+
Preview the production build locally:
38+
39+
```bash
40+
pnpm doc:preview
41+
```

test/doc/docs/en/Button.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Button
2+
3+
## Size
4+
5+
Buttons can be small, medium and large in size.
6+
7+
```jsx
8+
import React from 'react';
9+
import { Button } from 'rslib-module-doc';
10+
11+
export default () => {
12+
return <Button size="medium" label="Click me"></Button>;
13+
};
14+
```
15+
16+
## Background color
17+
18+
The background color of the button can be set by yourself.
19+
20+
```jsx
21+
import React from 'react';
22+
import { Button } from 'rslib-module-doc';
23+
24+
export default () => {
25+
return <Button backgroundColor="red" label="红色"></Button>;
26+
};
27+
```
28+
29+
## API
30+
<API moduleName="Button" en/>

test/doc/docs/en/_meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["index", "Button"]

test/doc/docs/en/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
overview: true
3+
title: Overview
4+
---

test/doc/docs/zh/Button.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Button
2+
3+
## 尺寸
4+
5+
按钮分为:小、中、大三种尺寸。
6+
7+
```jsx
8+
import React from 'react';
9+
import { Button } from 'rslib-module-doc';
10+
11+
export default () => {
12+
return <Button size="medium" label="点我"></Button>;
13+
};
14+
```
15+
16+
## 背景色
17+
18+
按钮的背景色可以自行设置。
19+
20+
```jsx
21+
import React from 'react';
22+
import { Button } from 'rslib-module-doc';
23+
24+
export default () => {
25+
return <Button backgroundColor="red" label="红色"></Button>;
26+
};
27+
```
28+
29+
## API
30+
<API moduleName="Button"/>

test/doc/docs/zh/_meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["index", "Button"]

test/doc/docs/zh/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
overview: true
3+
title: 总览
4+
---

test/doc/package.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "rslib-module-doc",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"exports": {
6+
".": {
7+
"types": "./dist/index.d.ts",
8+
"import": "./dist/index.js"
9+
}
10+
},
11+
"types": "./dist/index.d.ts",
12+
"files": [
13+
"dist"
14+
],
15+
"scripts": {
16+
"build": "rslib build",
17+
"dev": "rslib build --watch",
18+
"doc": "rspress dev",
19+
"doc:build": "rspress build",
20+
"doc:preview": "rspress preview"
21+
},
22+
"devDependencies": {
23+
"rslib-module-doc": "workspace:*",
24+
"@rsbuild/plugin-react": "^1.4.1",
25+
"@rslib/core": "^0.14.0",
26+
"@rspress/core": "^2.0.0-beta.33",
27+
"@rspress/plugin-api-docgen": "^2.0.0-beta.33",
28+
"@rspress/plugin-preview": "^2.0.0-beta.33",
29+
"@types/node": "^24.5.2",
30+
"@types/react": "^19.1.13",
31+
"react": "^19.1.1",
32+
"rsbuild-plugin-workspace-dev": "workspace:*",
33+
"typescript": "^5.9.2"
34+
},
35+
"peerDependencies": {
36+
"react": ">=19.0.0",
37+
"react-dom": ">=19.0.0"
38+
}
39+
}

test/doc/rslib.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { pluginReact } from '@rsbuild/plugin-react';
2+
import { defineConfig } from '@rslib/core';
3+
4+
export default defineConfig({
5+
lib: [
6+
{
7+
bundle: false,
8+
dts: true,
9+
format: 'esm',
10+
},
11+
],
12+
output: {
13+
target: 'web',
14+
},
15+
source: {
16+
tsconfigPath: 'tsconfig.build.json',
17+
},
18+
plugins: [pluginReact()],
19+
});

0 commit comments

Comments
 (0)