Skip to content

Commit caca20a

Browse files
authored
docs: complete doc command guide (#57)
1 parent 162206e commit caca20a

2 files changed

Lines changed: 138 additions & 4 deletions

File tree

‎website/docs/en/guide/cli/doc.mdx‎

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,74 @@
11
# doc
22

3-
TODO.
3+
import { PackageManagerTabs } from '@rspress/core/theme';
4+
5+
The `rs doc` command uses [Rspress](https://rspress.rs/guide/start/introduction) to develop, build, and preview a documentation site.
6+
7+
Install [`@rspress/core`](https://www.npmjs.com/package/@rspress/core) before using the command:
8+
9+
<PackageManagerTabs command="install -D @rspress/core" />
10+
11+
## Usage
12+
13+
```bash
14+
rs doc [command] [root] [options]
15+
```
16+
17+
The command loads the documentation configuration registered with [`define.doc()`](../configuration#define-doc). When no subcommand is provided, it starts the [Rspress development server](https://rspress.rs/api/commands#rspress-dev). The optional `root` argument overrides the configured documentation root directory.
18+
19+
## Options
20+
21+
`rs doc` supports the same options as the corresponding Rspress commands. See the [Rspress CLI documentation](https://rspress.rs/api/commands) for details.
22+
23+
Examples:
24+
25+
```bash
26+
# Start the development server
27+
rs doc
28+
29+
# Use a custom documentation root directory
30+
rs doc ./documentation
31+
32+
# Start the development server on port 8080
33+
rs doc --port 8080
34+
```
35+
36+
## Subcommands
37+
38+
### build
39+
40+
[`rs doc build`](https://rspress.rs/api/commands#rspress-build) builds the documentation site for production.
41+
42+
```bash
43+
rs doc build
44+
```
45+
46+
### preview
47+
48+
[`rs doc preview`](https://rspress.rs/api/commands#rspress-preview) previews the output generated by `rs doc build` locally.
49+
50+
```bash
51+
rs doc build
52+
rs doc preview
53+
```
54+
55+
### eject
56+
57+
[`rs doc eject`](https://rspress.rs/api/commands#rspress-eject) copies a built-in Rspress theme component into the project for customization. Run it without a component name to list all ejectable components.
58+
59+
```bash
60+
rs doc eject
61+
```
462

563
## Configuration
664

7-
See [`define.doc()`](../configuration#define-doc).
65+
Configure the documentation site through [`define.doc()`](../configuration#define-doc) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rspress configuration](https://rspress.rs/api/config/config-basic):
66+
67+
```ts title="rstack.config.ts"
68+
import { define } from 'rstack';
69+
70+
define.doc({
71+
root: 'docs',
72+
title: 'My Site',
73+
});
74+
```

‎website/docs/zh/guide/cli/doc.mdx‎

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,74 @@
11
# doc
22

3-
TODO.
3+
import { PackageManagerTabs } from '@rspress/core/theme';
4+
5+
`rs doc` 命令使用 [Rspress](https://rspress.rs/zh/guide/start/introduction) 开发、构建和预览文档站点。
6+
7+
使用该命令前,请安装 [`@rspress/core`](https://www.npmjs.com/package/@rspress/core):
8+
9+
<PackageManagerTabs command="install -D @rspress/core" />
10+
11+
## 用法 \{#usage}
12+
13+
```bash
14+
rs doc [command] [root] [options]
15+
```
16+
17+
该命令会加载通过 [`define.doc()`](../configuration#define-doc) 注册的文档配置。未指定子命令时,默认启动 [Rspress 开发服务器](https://rspress.rs/zh/api/commands#rspress-dev)。可选的 `root` 参数用于覆盖配置中的文档根目录。
18+
19+
## 选项 \{#options}
20+
21+
`rs doc` 支持与对应 Rspress 命令相同的选项,具体说明请参见 [Rspress CLI 文档](https://rspress.rs/zh/api/commands)。
22+
23+
示例:
24+
25+
```bash
26+
# 启动开发服务器
27+
rs doc
28+
29+
# 使用自定义文档根目录
30+
rs doc ./documentation
31+
32+
# 使用 8080 端口启动开发服务器
33+
rs doc --port 8080
34+
```
35+
36+
## 子命令 \{#subcommands}
37+
38+
### build
39+
40+
[`rs doc build`](https://rspress.rs/zh/api/commands#rspress-build) 用于构建生产环境的文档站点。
41+
42+
```bash
43+
rs doc build
44+
```
45+
46+
### preview
47+
48+
[`rs doc preview`](https://rspress.rs/zh/api/commands#rspress-preview) 用于在本地预览 `rs doc build` 生成的产物。
49+
50+
```bash
51+
rs doc build
52+
rs doc preview
53+
```
54+
55+
### eject
56+
57+
[`rs doc eject`](https://rspress.rs/zh/api/commands#rspress-eject) 用于将 Rspress 内置主题组件复制到项目中进行自定义。不指定组件名称时,会列出所有可导出的组件。
58+
59+
```bash
60+
rs doc eject
61+
```
462

563
## 配置 \{#configuration}
664

7-
参见 [`define.doc()`](../configuration#define-doc)。
65+
在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.doc()`](../configuration#define-doc) 配置文档站点。该 API 支持标准的 [Rspress 配置](https://rspress.rs/zh/api/config/config-basic):
66+
67+
```ts title="rstack.config.ts"
68+
import { define } from 'rstack';
69+
70+
define.doc({
71+
root: 'docs',
72+
title: 'My Site',
73+
});
74+
```

0 commit comments

Comments
 (0)