Skip to content

Commit 008da95

Browse files
authored
Add preview documentation section (#7281)
Adds a basic documentation section for preview mode based on the FAQ entry and versioning RFC.
1 parent 5d4dd3e commit 008da95

File tree

3 files changed

+50
-36
lines changed

3 files changed

+50
-36
lines changed

docs/faq.md

+1-36
Original file line numberDiff line numberDiff line change
@@ -384,42 +384,7 @@ alone.
384384

385385
## What is preview?
386386

387-
Preview enables a collection of newer rules and fixes that are considered experimental or unstable.
388-
389-
If a rule is marked as preview, it can only be enabled if the `--preview` flag is toggled. For example, consider a
390-
hypothetical rule, `HYP001`. If `HYP001` were in preview, it would _not_ be enabled by adding following to your
391-
`pyproject.toml`:
392-
393-
```toml
394-
[tool.ruff]
395-
extend-select = ["HYP001"]
396-
```
397-
398-
It also would _not_ be enabled by selecting the `HYP` category, like so:
399-
400-
```toml
401-
[tool.ruff]
402-
extend-select = ["HYP"]
403-
```
404-
405-
Similarly, it would _not_ be enabled via the `ALL` selector:
406-
407-
```toml
408-
[tool.ruff]
409-
select = ["ALL"]
410-
```
411-
412-
However, it would be enabled in any of the above cases if you you enabled `preview`:
413-
414-
```toml
415-
[tool.ruff]
416-
extend-select = ["HYP"]
417-
preview = true
418-
```
419-
420-
Preview can also be enabled via the CLI with the `--preview` flag.
421-
422-
To see which rules are currently in preview, visit the [rules reference](https://beta.ruff.rs/docs/rules/).
387+
Preview enables a collection of newer rules and fixes that are considered experimental or unstable. See the [preview documentation](https://beta.ruff.rs/docs/preview/) for more details; or, to see which rules are currently in preview, visit the [rules reference](https://beta.ruff.rs/docs/rules/).
423388

424389
## How can I tell what settings Ruff is using to check my code?
425390

docs/preview.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Preview
2+
3+
Ruff includes an opt-in preview mode to provide an opportunity for community feedback and increase confidence that
4+
changes are a net-benefit before enabling them for everyone.
5+
6+
Preview mode enables a collection of newer rules and fixes that are considered experimental or unstable.
7+
8+
## Enabling preview mode
9+
10+
Preview mode can be enabled with the `--preview` flag on the CLI or by setting `preview = true` in your Ruff
11+
configuration file (e.g. `pyproject.toml`).
12+
13+
## Using rules that are in preview
14+
15+
If a rule is marked as preview, it can only be selected if preview mode is enabled. For example, consider a
16+
hypothetical rule, `HYP001`. If `HYP001` were in preview, it would _not_ be enabled by adding following to your
17+
`pyproject.toml`:
18+
19+
```toml
20+
[tool.ruff]
21+
extend-select = ["HYP001"]
22+
```
23+
24+
It also would _not_ be enabled by selecting the `HYP` category, like so:
25+
26+
```toml
27+
[tool.ruff]
28+
extend-select = ["HYP"]
29+
```
30+
31+
Similarly, it would _not_ be enabled via the `ALL` selector:
32+
33+
```toml
34+
[tool.ruff]
35+
select = ["ALL"]
36+
```
37+
38+
However, it would be enabled in any of the above cases if you you enabled preview in your configuration file:
39+
40+
```toml
41+
[tool.ruff]
42+
extend-select = ["HYP"]
43+
preview = true
44+
```
45+
46+
Or, if you provided the `--preview` CLI flag.
47+
48+
To see which rules are currently in preview, visit the [rules reference](https://beta.ruff.rs/docs/rules/).

scripts/generate_mkdocs.py

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Section(NamedTuple):
2525
Section("Installation", "installation.md", generated=False),
2626
Section("Usage", "usage.md", generated=False),
2727
Section("Configuration", "configuration.md", generated=False),
28+
Section("Preview", "preview.md", generated=False),
2829
Section("Rules", "rules.md", generated=True),
2930
Section("Settings", "settings.md", generated=True),
3031
Section("Editor Integrations", "editor-integrations.md", generated=False),

0 commit comments

Comments
 (0)