docs: Move fmt: off docs (#4090)

This commit is contained in:
cobalt 2023-12-09 19:44:15 -06:00 committed by GitHub
parent 432d9050c3
commit e7e122e9ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 14 deletions

View File

@ -8,18 +8,9 @@ deliberately limited and rarely added. Previous formatting is taken into account
little as possible, with rare exceptions like the magic trailing comma. The coding style little as possible, with rare exceptions like the magic trailing comma. The coding style
used by _Black_ can be viewed as a strict subset of PEP 8. used by _Black_ can be viewed as a strict subset of PEP 8.
_Black_ reformats entire files in place. It doesn't reformat lines that contain This document describes the current formatting style. If you're interested in trying out
`# fmt: skip` or blocks that start with `# fmt: off` and end with `# fmt: on`. where the style is heading, see [future style](./future_style.md) and try running
`# fmt: skip` can be mixed with other pragmas/comments either with multiple comments `black --preview`.
(e.g. `# fmt: skip # pylint # noqa`) or as a semicolon separated list (e.g.
`# fmt: skip; pylint; noqa`). `# fmt: on/off` must be on the same level of indentation
and in the same block, meaning no unindents beyond the initial indentation level between
them. It also recognizes [YAPF](https://github.com/google/yapf)'s block comments to the
same effect, as a courtesy for straddling code.
The rest of this document describes the current formatting style. If you're interested
in trying out where the style is heading, see [future style](./future_style.md) and try
running `black --preview`.
### How _Black_ wraps lines ### How _Black_ wraps lines

View File

@ -12,7 +12,8 @@ _Black_ is a well-behaved Unix-style command-line tool:
## Usage ## Usage
To get started right away with sensible defaults: _Black_ will reformat entire files in place. To get started right away with sensible
defaults:
```sh ```sh
black {source_file_or_directory} black {source_file_or_directory}
@ -24,6 +25,17 @@ You can run _Black_ as a package if running it as a script doesn't work:
python -m black {source_file_or_directory} python -m black {source_file_or_directory}
``` ```
### Ignoring sections
Black will not reformat lines that contain `# fmt: skip` or blocks that start with
`# fmt: off` and end with `# fmt: on`. `# fmt: skip` can be mixed with other
pragmas/comments either with multiple comments (e.g. `# fmt: skip # pylint # noqa`) or
as a semicolon separated list (e.g. `# fmt: skip; pylint; noqa`). `# fmt: on/off` must
be on the same level of indentation and in the same block, meaning no unindents beyond
the initial indentation level between them. Black also recognizes
[YAPF](https://github.com/google/yapf)'s block comments to the same effect, as a
courtesy for straddling code.
### Command line options ### Command line options
The CLI options of _Black_ can be displayed by running `black --help`. All options are The CLI options of _Black_ can be displayed by running `black --help`. All options are
@ -191,7 +203,7 @@ All done! ✨ 🍰 ✨
Show (or do not show) colored diff. Only applies when `--diff` is given. Show (or do not show) colored diff. Only applies when `--diff` is given.
### `--line-ranges` #### `--line-ranges`
When specified, _Black_ will try its best to only format these lines. When specified, _Black_ will try its best to only format these lines.