Skip to content

Commit d441338

Browse files
authored
Improve documentation of the preview mode (#10168)
## Summary This PR was prompted by the discussion in #10153. It adds CLI tab examples next to the `pyproject.toml` and `ruff.toml` examples. It should be helpful for users wanting to try out the preview mode without modifying or creating a `.toml` file. It also adds a paragraph to try to make the effect of the preview mode less confusing.
1 parent 72599da commit d441338

File tree

1 file changed

+43
-6
lines changed

1 file changed

+43
-6
lines changed

docs/preview.md

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
Ruff includes an opt-in preview mode to provide an opportunity for community feedback and increase confidence that
44
changes are a net-benefit before enabling them for everyone.
55

6-
Preview mode enables a collection of newer lint rules, fixes, and formatter style changes that are
7-
considered experimental or unstable,.
6+
Preview mode enables a collection of unstable features such as new lint rules and fixes, formatter style changes, interface updates, and more. Warnings about deprecated features may turn into errors when using preview mode.
7+
8+
Enabling preview mode does not on its own enable all preview rules. See the [rules section](#using-rules-that-are-in-preview) for details on selecting preview rules.
89

910
## Enabling preview mode
1011

@@ -27,6 +28,13 @@ Preview mode can be configured separately for linting and formatting (requires R
2728
preview = true
2829
```
2930

31+
=== "CLI"
32+
33+
```console
34+
ruff check --preview
35+
```
36+
37+
3038
To enable preview style formatting without enabling any preview lint rules:
3139

3240
=== "pyproject.toml"
@@ -43,11 +51,16 @@ To enable preview style formatting without enabling any preview lint rules:
4351
preview = true
4452
```
4553

54+
=== "CLI"
55+
56+
```console
57+
ruff format --preview
58+
```
59+
4660
## Using rules that are in preview
4761

4862
If a rule is marked as preview, it can only be selected if preview mode is enabled. For example, consider a
49-
hypothetical rule, `HYP001`. If `HYP001` were in preview, it would _not_ be enabled by adding following to your
50-
config file:
63+
hypothetical rule, `HYP001`. If `HYP001` were in preview, it would _not_ be enabled by adding it to the selected rule set.
5164

5265
=== "pyproject.toml"
5366

@@ -63,6 +76,13 @@ config file:
6376
extend-select = ["HYP001"]
6477
```
6578

79+
=== "CLI"
80+
81+
```console
82+
ruff check --extend-select HYP001
83+
```
84+
85+
6686
It also would _not_ be enabled by selecting the `HYP` category, like so:
6787

6888
=== "pyproject.toml"
@@ -79,6 +99,13 @@ It also would _not_ be enabled by selecting the `HYP` category, like so:
7999
extend-select = ["HYP"]
80100
```
81101

102+
=== "CLI"
103+
104+
```console
105+
ruff check --extend-select HYP
106+
```
107+
108+
82109
Similarly, it would _not_ be enabled via the `ALL` selector:
83110

84111
=== "pyproject.toml"
@@ -95,7 +122,13 @@ Similarly, it would _not_ be enabled via the `ALL` selector:
95122
select = ["ALL"]
96123
```
97124

98-
However, it would be enabled in any of the above cases if you enabled preview in your configuration file:
125+
=== "CLI"
126+
127+
```console
128+
ruff check --select ALL
129+
```
130+
131+
However, it _would_ be enabled in any of the above cases if you enabled preview mode:
99132

100133
=== "pyproject.toml"
101134

@@ -113,7 +146,11 @@ However, it would be enabled in any of the above cases if you enabled preview in
113146
preview = true
114147
```
115148

116-
Or, if you provided the `--preview` CLI flag.
149+
=== "CLI"
150+
151+
```console
152+
ruff check --extend-select HYP --preview
153+
```
117154

118155
To see which rules are currently in preview, visit the [rules reference](rules.md).
119156

0 commit comments

Comments
 (0)