Skip to content

Commit 39db75d

Browse files
authored
docs: streamline guides and CLI reference (#639)
1 parent d502ec4 commit 39db75d

24 files changed

Lines changed: 44 additions & 68 deletions

‎website/docs/en/guide/api-reference.mdx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: 'Public Rstack APIs, including configuration helpers, tool API re-e
44

55
# API reference
66

7-
Rstack CLI provides a unified configuration API and re-exports the public APIs of Rsbuild, Rslib, Rstest, and Rslint through dedicated subpaths. Prefer these subpaths to direct imports from each tool's core package so that dependency entry points stay unified and APIs match the tool versions integrated by Rstack CLI.
7+
Rstack CLI provides a unified configuration API and re-exports the public APIs of Rsbuild, Rslib, Rstest, and Rslint through the subpaths below. Import from these entry points to use APIs that match the tool versions in Rstack CLI.
88

99
## Import paths
1010

@@ -58,8 +58,6 @@ export const teamConfig: RstackConfig = {
5858

5959
## Re-exports
6060

61-
The tool-specific subpaths below re-export the public APIs from their corresponding core packages. Using these entry points keeps imports unified and APIs aligned with the tool versions integrated by Rstack CLI.
62-
6361
### `rstack/app`
6462

6563
`rstack/app` re-exports all public APIs from `@rsbuild/core`, including APIs for creating and controlling Rsbuild instances.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ rs check --type-check
4646

4747
### `-h, --help`
4848

49-
Display usage and option information without running checks:
49+
Display usage and options:
5050

5151
```bash
5252
rs check --help

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The command uses the following exit codes:
5555

5656
### `-h, --help`
5757

58-
Display usage and option information without formatting files:
58+
Display usage and options:
5959

6060
```bash
6161
rs fmt --help
@@ -79,7 +79,7 @@ If `config/format.ignore` contains this rule:
7979
generated/**
8080
```
8181

82-
Here, `config/format.ignore` is located relative to the project root. The `generated/**` rule is relative to `config/`. It therefore ignores `config/generated/**` instead of `generated/**` in the project root.
82+
The `generated/**` rule is relative to `config/`, where the ignore file is located. It excludes `config/generated/**`, not `generated/**` in the project root.
8383

8484
Loaded rules apply to scanned paths, explicitly passed files, `--stdin-filepath`, and documents formatted through `--lsp`.
8585

@@ -133,9 +133,11 @@ Run a language server that formats editor buffers over the [Language Server Prot
133133
rs fmt --lsp
134134
```
135135

136-
The server only advertises document formatting and formats the buffer held by the editor, not the file on disk. Formatting options sent by the editor, such as tab size, are ignored: the Rstack config is the single source of truth. Ignored, unsupported, and unparsable documents produce no edits rather than an error.
136+
The server supports document formatting only and works on the editor's buffer. Formatting rules come from the Rstack config; editor options such as tab size are ignored. Ignored, unsupported, and unparsable documents produce no formatting edits.
137137

138-
The server loads a single config for the workspace root reported by the editor and does not discover nested configs per file; launch one server per config root when a project contains several. The config is loaded on the first formatting request and reused for the lifetime of the server; restart the server after changing it. Besides the global [`--config`](../configuration#configuration-file) option, only [`--ignore-path`](#--ignore-path-path) affects the server. Relative values for both are resolved from the directory the server was launched in.
138+
The server uses the config at the workspace root reported by the editor and does not discover nested configs for individual files. If a project has multiple configs, launch a server for each config root. The server reuses the loaded config, so restart it after changing the config.
139+
140+
Besides the global [`--config`](../configuration#configuration-file) option, only [`--ignore-path`](#--ignore-path-path) affects the server's formatting behavior. Relative paths for both are resolved from the directory where the server was launched.
139141

140142
Register `rs fmt --lsp` as a custom language server in any editor with LSP support to format on demand or on save.
141143

@@ -161,7 +163,7 @@ Store the persistent cache in a custom directory:
161163
rs fmt --cache-location .cache/rs-fmt
162164
```
163165

164-
Relative paths are resolved from the current working directory, while absolute paths are used as-is. The directory is created as needed and excluded from file discovery. Unlike the default cache location, a custom directory does not receive an automatic `.gitignore`; exclude it from version control or manage it through your CI cache configuration.
166+
Relative paths are resolved from the current working directory. The custom cache directory is excluded from formatting and does not receive an automatic `.gitignore`. Add the directory to `.gitignore` if you do not want to commit the cache to Git.
165167

166168
If you also pass `--no-cache`, `--cache-location` is ignored and the directory follows the normal file discovery rules.
167169

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ When using a custom directory, add the full command to the `prepare` script of t
9595
}
9696
```
9797

98-
> The path must not contain `..`. This prevents hook files from being created or overwritten outside the repository through a parent directory path.
98+
> The path must not contain `..` to prevent creating or overwriting hook files outside the repository.
9999
100100
### `--help`
101101

@@ -136,7 +136,7 @@ The default directory structure is:
136136
└── ...
137137
```
138138

139-
Files alongside `_` are repository hook scripts. The `_` directory contains generated files and is ignored by Git. `rs hooks` points `core.hooksPath` to `.rstack/hooks/_`.
139+
`rs hooks` points `core.hooksPath` to `.rstack/hooks/_`.
140140

141141
## Supported hooks
142142

@@ -189,7 +189,7 @@ Use it to initialize a Node.js version manager, update `PATH`, or set `RSTACK_HO
189189

190190
## Ownership safety
191191

192-
Each generated hooks directory records its owning project. Only that project should include `rs hooks` in its `prepare` script. Rstack skips installation from any other project, even with `--force`, and refuses to remove hooks owned by another project.
192+
Each hooks directory is managed by one project. Include `rs hooks` only in that project's `prepare` script. Installation from other projects is skipped, even with `--force`; uninstallation from other projects is rejected.
193193

194194
To transfer ownership:
195195

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ description: 'Run lint-staged tasks against Git-staged files with the rs staged
44

55
# staged
66

7-
The `rs staged` command uses [lint-staged](https://github.com/lint-staged/lint-staged) to run tasks against files staged in Git.
8-
9-
`rs staged` can run linters, formatters, or other checks on staged files before committing code.
7+
`rs staged` uses [lint-staged](https://github.com/lint-staged/lint-staged) to run linters, formatters, or other checks on files staged in Git.
108

119
A common pattern is to pair `rs staged` with [`rs hooks`](./hooks) and run staged-file tasks from a `pre-commit` hook.
1210

@@ -30,9 +28,7 @@ rs staged --allow-empty
3028

3129
### `--concurrent`
3230

33-
`--concurrent` controls how many tasks may run at the same time. It accepts `true`, `false`, or a positive integer.
34-
35-
When the option is omitted, it defaults to `true`, so `rs staged` runs tasks concurrently without a fixed limit. Set it to `false` to run one task at a time, or use a positive integer to limit the number of concurrent tasks.
31+
`--concurrent` controls how many tasks run at once: `true` (the default) allows unlimited concurrency, `false` runs one task at a time, and a positive integer sets the maximum.
3632

3733
```bash
3834
# Use the default: run tasks concurrently without a fixed limit

‎website/docs/en/guide/configuration.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ define.fmt({
3333
});
3434
```
3535

36-
The configuration file does not require a default export. Each `define.*()` API can be called at most once; defining the same configuration type more than once throws an error.
36+
The configuration file does not require a default export. Call each `define.*()` API at most once; repeated calls throw an error.
3737

3838
By default, Rstack CLI looks for a file with one of the following names:
3939

@@ -50,7 +50,7 @@ rs build --config ./configs/rstack.config.ts
5050

5151
## Importing dependencies \{#loading-dependencies-on-demand}
5252

53-
Rstack keeps a project's build, test, lint, formatting, and other settings in one `rstack.config.*` file. When a command loads the config file, it also loads every top-level import, even if it does not use the related configuration. Importing every tool and plugin at the top level can therefore add startup overhead to commands such as `rs lint` and `rs fmt`.
53+
Tools and plugins imported at the top level of `rstack.config.*` are loaded with the config, even if the current command does not use them. This can add startup overhead to commands such as `rs lint` and `rs fmt`.
5454

5555
Choose the import style based on the config contents:
5656

‎website/docs/en/guide/formatting.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ The command deletes only the cache file, then exits without formatting files. Se
243243

244244
To add formatting capabilities that are not built into Rstack CLI, install the corresponding [Prettier plugin](https://prettier.io/docs/plugins) and add it to `plugins`. Plugins can be referenced by package name, file path, or URL. Package names and relative paths are resolved from the directory containing the Rstack configuration file.
245245

246-
Because `rs fmt` loads plugins in workers, plugin objects cannot be passed directly. Reference each plugin by package name, path, or URL instead.
246+
Because `rs fmt` loads plugins in workers, plugin objects cannot be passed directly.
247247

248248
For example, install and enable [`prettier-plugin-tailwindcss`](https://github.com/tailwindlabs/prettier-plugin-tailwindcss):
249249

‎website/docs/en/guide/git-hooks.mdx‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ git config --get core.hooksPath
4949

5050
## Pre-commit checks
5151

52-
A `pre-commit` hook can lint and format the files staged for the current commit.
53-
5452
### Configure tasks
5553

5654
Add staged-file tasks to the Rstack config file. Adjust the glob patterns for the languages used by your project:
@@ -76,6 +74,6 @@ rs staged
7674

7775
When you run `git commit`, Git invokes the hook installed by `rs hooks`. The hook executes `.rstack/hooks/pre-commit`, and `rs staged` then runs the configured tasks on the staged files.
7876

79-
`rs staged` passes matching staged files to each command. Commands in an array run in order: [`rs lint --fix`](./cli/lint) first applies available fixes, then [`rs fmt`](./cli/fmt) formats the result. Remove `--fix` if lint errors should block the commit without changing files.
77+
`rs staged` passes matching staged files to each command. Commands in an array run in order: [`rs lint --fix`](./cli/lint) first applies available lint fixes, then [`rs fmt`](./cli/fmt) formats the files. Remove `--fix` if you do not want lint issues fixed automatically.
8078

81-
After every task passes, the commit continues and includes the fixed and formatted results. If any task fails, the commit stops; fix the issue and then try again.
79+
If all tasks pass, the commit includes the fixed and formatted results. If any task fails, the commit stops.

‎website/docs/en/guide/migration.mdx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ Once you have reviewed and validated the changes, move on to Rstest:
3636
Use the migrate-to-rstack-cli Skill to migrate Rstest to Rstack CLI, leaving all other tools unchanged.
3737
```
3838

39-
Repeat this process for each remaining tool.
40-
4139
## Supported tools
4240

4341
The Skill can directly migrate the following standalone tools:

‎website/docs/en/guide/monorepo.mdx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ description: 'Use Rstack CLI to configure shared checks, formatting, staged task
66

77
This guide explains how to use Rstack CLI in a monorepo, including how it works with task orchestrators such as [Turborepo](https://turborepo.com/docs) and [Nx](https://nx.dev/docs/getting-started/intro).
88

9-
It covers managing the Rstack CLI dependency, configuring lint, formatting, and staged-file tasks at the root, and defining separate configurations for web applications and libraries.
10-
119
## Project structure
1210

1311
The recommended setup has two levels:
@@ -29,7 +27,7 @@ The recommended setup has two levels:
2927
└── rstack.config.ts
3028
```
3129

32-
This structure keeps the Rstack CLI version in one place while keeping build and test configuration close to the project that uses it.
30+
This structure centralizes tool versions and check rules while letting each project maintain its own build and test configuration.
3331

3432
## Rstack CLI dependency management \{#rstack-dependency-management}
3533

0 commit comments

Comments
 (0)