mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:56 +00:00
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.
This commit is contained in:
parent
5559827a78
commit
b972455ac7
11 changed files with 3394 additions and 12 deletions
|
@ -363,7 +363,7 @@ preview = {preview:?}"#,
|
|||
line_ending = self.0.line_ending(),
|
||||
magic_trailing_comma = self.0.magic_trailing_comma(),
|
||||
docstring_code = self.0.docstring_code(),
|
||||
docstring_code_line_width = self.0.docstring_code_line_width().value(),
|
||||
docstring_code_line_width = self.0.docstring_code_line_width(),
|
||||
preview = self.0.preview()
|
||||
)
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue