mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-25 05:54:25 +00:00
Document formatter progress scripts (#6035)
## Summary Add documentation to the formatter progress scripts ## Test Plan n/a
This commit is contained in:
parent
fdb3c8852f
commit
a9f535997d
2 changed files with 18 additions and 3 deletions
|
@ -231,6 +231,13 @@ additional test cases in `resources/test/fixtures/ruff`.
|
||||||
|
|
||||||
The full Ruff test suite is slow, `cargo test -p ruff_python_formatter` is a lot faster.
|
The full Ruff test suite is slow, `cargo test -p ruff_python_formatter` is a lot faster.
|
||||||
|
|
||||||
|
You can check the black compatibility on a number of projects using `scripts/formatter_progress`.
|
||||||
|
It will print the similarity index, the percentage of lines that remains unchanged between black's
|
||||||
|
formatting and our formatting. You could compute it as the number of neutral lines in a diff divided
|
||||||
|
by the neutral plus the removed lines. It also checks for common problems such unstable formatting,
|
||||||
|
internal formatter errors and printing invalid syntax. We run this script in CI and you can view the
|
||||||
|
results in a PR page under "Checks" > "CI" > "Summary" at the bottom of the page.
|
||||||
|
|
||||||
There is a `ruff_python_formatter` binary that avoid building and linking the main `ruff` crate.
|
There is a `ruff_python_formatter` binary that avoid building and linking the main `ruff` crate.
|
||||||
|
|
||||||
You can use `scratch.py` as a playground, e.g.
|
You can use `scratch.py` as a playground, e.g.
|
||||||
|
@ -239,7 +246,7 @@ and `--print-comments` options.
|
||||||
|
|
||||||
The origin of Ruff's formatter is the [Rome formatter](https://github.com/rome/tools/tree/main/crates/rome_json_formatter),
|
The origin of Ruff's formatter is the [Rome formatter](https://github.com/rome/tools/tree/main/crates/rome_json_formatter),
|
||||||
e.g. the ruff_formatter crate is forked from the [rome_formatter crate](https://github.com/rome/tools/tree/main/crates/rome_formatter).
|
e.g. the ruff_formatter crate is forked from the [rome_formatter crate](https://github.com/rome/tools/tree/main/crates/rome_formatter).
|
||||||
The Rome repository can be a helpful reference when implementing something in the Ruff formatter
|
The Rome repository can be a helpful reference when implementing something in the Ruff formatter.
|
||||||
|
|
||||||
### Checking entire projects
|
### Checking entire projects
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# Check black compatibility and check for formatter instabilities and other
|
||||||
# The pinned revisions are the latest of this writing, update freely
|
# errors.
|
||||||
|
#
|
||||||
|
# This script will first clone a diverse set of (mostly) black formatted
|
||||||
|
# repositories with fixed revisions to target/progress_projects. Each project
|
||||||
|
# gets formatted (without modifying the files on disk) to check how
|
||||||
|
# similar our style is to black. It also catches common issues such as
|
||||||
|
# unstable formatting, internal formatter errors and printing invalid syntax.
|
||||||
|
#
|
||||||
|
# The pinned revisions are the latest of this writing, update freely.
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue