Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,701 changes: 5,144 additions & 557 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions test/doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Rslib project

## Setup

Install the dependencies:

```bash
pnpm install
```

## Get started

Build the library:

```bash
pnpm build
```

Build the library in watch mode:

```bash
pnpm dev
```

Start the doc dev server:

```bash
pnpm doc
```

Build the doc for production:

```bash
pnpm doc:build
```

Preview the production build locally:

```bash
pnpm doc:preview
```
30 changes: 30 additions & 0 deletions test/doc/docs/en/Button.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Button

## Size

Buttons can be small, medium and large in size.

```jsx
import React from 'react';
import { Button } from 'rslib-module-doc';

export default () => {
return <Button size="medium" label="Click me"></Button>;
};
```

## Background color

The background color of the button can be set by yourself.

```jsx
import React from 'react';
import { Button } from 'rslib-module-doc';

export default () => {
return <Button backgroundColor="red" label="红色"></Button>;
};
```

## API
<API moduleName="Button" en/>
1 change: 1 addition & 0 deletions test/doc/docs/en/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["index", "Button"]
4 changes: 4 additions & 0 deletions test/doc/docs/en/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
overview: true
title: Overview
---
30 changes: 30 additions & 0 deletions test/doc/docs/zh/Button.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Button

## 尺寸

按钮分为:小、中、大三种尺寸。

```jsx
import React from 'react';
import { Button } from 'rslib-module-doc';

export default () => {
return <Button size="medium" label="点我"></Button>;
};
```

## 背景色

按钮的背景色可以自行设置。

```jsx
import React from 'react';
import { Button } from 'rslib-module-doc';

export default () => {
return <Button backgroundColor="red" label="红色"></Button>;
};
```

## API
<API moduleName="Button"/>
1 change: 1 addition & 0 deletions test/doc/docs/zh/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["index", "Button"]
4 changes: 4 additions & 0 deletions test/doc/docs/zh/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
overview: true
title: 总览
---
39 changes: 39 additions & 0 deletions test/doc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "rslib-module-doc",
"version": "0.0.0",
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "rslib build",
"dev": "rslib build --watch",
"doc": "rspress dev",
"doc:build": "rspress build",
"doc:preview": "rspress preview"
},
"devDependencies": {
"rslib-module-doc": "workspace:*",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "^0.14.0",
"@rspress/core": "^2.0.0-beta.33",
"@rspress/plugin-api-docgen": "^2.0.0-beta.33",
"@rspress/plugin-preview": "^2.0.0-beta.33",
"@types/node": "^24.5.2",
"@types/react": "^19.1.13",
"react": "^19.1.1",
"rsbuild-plugin-workspace-dev": "workspace:*",
"typescript": "^5.9.2"
},
"peerDependencies": {
"react": ">=19.0.0",
"react-dom": ">=19.0.0"
}
}
19 changes: 19 additions & 0 deletions test/doc/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { pluginReact } from '@rsbuild/plugin-react';
import { defineConfig } from '@rslib/core';

export default defineConfig({
lib: [
{
bundle: false,
dts: true,
format: 'esm',
},
],
output: {
target: 'web',
},
source: {
tsconfigPath: 'tsconfig.build.json',
},
plugins: [pluginReact()],
});
37 changes: 37 additions & 0 deletions test/doc/rspress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as path from 'node:path';
import { defineConfig } from '@rspress/core';
import { pluginApiDocgen } from '@rspress/plugin-api-docgen';
import { pluginPreview } from '@rspress/plugin-preview';
import { pluginWorkspaceDev } from 'rsbuild-plugin-workspace-dev';

export default defineConfig({
root: path.join(__dirname, 'docs'),
title: 'Rslib Module Doc',
lang: 'en',
locales: [
{
lang: 'en',
label: 'English',
},
{
lang: 'zh',
label: '简体中文',
},
],
plugins: [
pluginApiDocgen({
entries: {
Button: './src/button.tsx',
},
apiParseTool: 'react-docgen-typescript',
}),
pluginPreview(),
],
builderConfig: {
plugins: [
pluginWorkspaceDev({
ignoreSelf: false,
}),
],
},
});
42 changes: 42 additions & 0 deletions test/doc/src/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import './button.css';

export interface ButtonProps {
/**
* Whether the button is primary
* @default true
*/
primary?: boolean;
/**
* Background color of the button
*/
backgroundColor?: string;
/**
* Size of Button
* @default 'large'
*/
size?: 'small' | 'medium' | 'large';
/**
* Label of the button
*/
label: string;
}

export const Button = ({
primary = true,
size = 'large',
backgroundColor,
label,
...props
}: ButtonProps) => {
const mode = primary ? 'demo-button--primary' : 'demo-button--secondary';
return (
<button
type="button"
className={['demo-button', `demo-button--${size}`, mode].join(' ')}
style={{ backgroundColor }}
{...props}
>
{label}
</button>
);
};
34 changes: 34 additions & 0 deletions test/doc/src/button.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.demo-button {
font-weight: 700;
border: 0;
border-radius: 3em;
cursor: pointer;
display: inline-block;
line-height: 1;
}

.demo-button--primary {
color: white;
background-color: #1ea7fd;
}

.demo-button--secondary {
color: #333;
background-color: transparent;
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
}

.demo-button--small {
font-size: 12px;
padding: 10px 16px;
}

.demo-button--medium {
font-size: 14px;
padding: 11px 20px;
}

.demo-button--large {
font-size: 16px;
padding: 12px 24px;
}
1 change: 1 addition & 0 deletions test/doc/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Button } from './Button';
4 changes: 4 additions & 0 deletions test/doc/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["src"]
}
28 changes: 28 additions & 0 deletions test/doc/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"lib": ["DOM", "ES2020"],
"jsx": "react-jsx",
"target": "ES2020",
"noEmit": true,
"skipLibCheck": true,
"useDefineForClassFields": true,

/* modules */
"module": "ESNext",
"moduleDetection": "force",
"moduleResolution": "bundler",
"verbatimModuleSyntax": true,
"resolveJsonModule": true,
"allowImportingTsExtensions": true,
"isolatedModules": true,

/* type checking */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": ["src", "docs", "theme", "rspress.config.ts", "rslib.config.ts"],
"mdx": {
"checkMdx": true
}
}