ruff/crates/ruff_python_formatter/src
Andrew Gallant b972455ac7
ruff_python_formatter: implement "dynamic" line width mode for docstring code formatting (#9098)
## Summary

This PR changes the internal `docstring-code-line-width` setting to
additionally accept a string value `dynamic`. When `dynamic` is set, the
line width is dynamically adjusted when reformatting code snippets in
docstrings based on the indent level of the docstring. The result is
that the reformatted lines from the code snippet should not exceed the
"global" line width configuration for the surrounding source.

This PR does not change the default behavior, although I suspect the
default should probably be `dynamic`.

## Test Plan

I added a new configuration to the existing docstring code tests and
also added a new set of tests dedicated to the new `dynamic` mode.
2023-12-12 09:58:07 -05:00
..
comments remove several uses of `unsafe` (#8600) 2023-11-28 09:50:03 -05:00
expression ruff_python_formatter: implement "dynamic" line width mode for docstring code formatting (#9098) 2023-12-12 09:58:07 -05:00
module Attach dangling comments to the comprehension instead of the `if` or `iter` nodes (#7693) 2023-09-29 10:45:01 +01:00
other Avoid trailing comma for single-argument with positional separator (#9076) 2023-12-09 18:03:31 -05:00
pattern New `Singleton` enum for `PatternMatchSingleton` node (#8063) 2023-10-30 05:48:53 +00:00
snapshots Remove exception-handler lexing from `unused-bound-exception` fix (#5851) 2023-07-18 18:27:46 +00:00
statement ruff_python_formatter: implement "dynamic" line width mode for docstring code formatting (#9098) 2023-12-12 09:58:07 -05:00
type_param Don't move type param opening parenthesis comment (#8163) 2023-10-24 12:02:27 +00:00
builders.rs Implement multiline dictionary and list hugging for preview style (#8293) 2023-11-30 21:11:14 -05:00
cli.rs Add `--skip-magic-trailing-comma` to formatter dev comment (#8689) 2023-11-15 09:23:46 +00:00
context.rs ruff_python_formatter: implement "dynamic" line width mode for docstring code formatting (#9098) 2023-12-12 09:58:07 -05:00
generated.rs New AST nodes for f-string elements (#8835) 2023-12-07 10:28:05 -06:00
lib.rs ruff_python_formatter: implement "dynamic" line width mode for docstring code formatting (#9098) 2023-12-12 09:58:07 -05:00
main.rs Formatter and parser refactoring (#7569) 2023-09-26 15:29:43 +02:00
options.rs ruff_python_formatter: implement "dynamic" line width mode for docstring code formatting (#9098) 2023-12-12 09:58:07 -05:00
prelude.rs Accept any `Into<AnyNodeRef>` as `Comments` arguments (#5205) 2023-06-20 16:49:21 +00:00
preview.rs Create dedicated `is_*_enabled` functions for each preview style (#8988) 2023-12-04 05:38:54 +00:00
shared_traits.rs ruff_python_formatter: copy and inline shared traits (#8656) 2023-11-13 12:16:04 -05:00
verbatim.rs Preserve trailing semicolons when using `fmt: off` (#8275) 2023-10-30 00:22:34 +00:00