mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Preview Style: Format module level docstring (#9725)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
80fc02e7d5
commit
b47f85eb69
5 changed files with 30 additions and 143 deletions
|
@ -1,133 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/module_docstring_2.py
|
||||
---
|
||||
## Input
|
||||
|
||||
```python
|
||||
"""I am a very helpful module docstring.
|
||||
|
||||
With trailing spaces:
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
||||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
Ut enim ad minim veniam,
|
||||
quis nostrud exercitation ullamco laboris
|
||||
nisi ut aliquip ex ea commodo consequat.
|
||||
Duis aute irure dolor in reprehenderit in voluptate
|
||||
velit esse cillum dolore eu fugiat nulla pariatur.
|
||||
Excepteur sint occaecat cupidatat non proident,
|
||||
sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
a = 1
|
||||
|
||||
|
||||
"""Look at me I'm a docstring...
|
||||
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
........................................................NOT!
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
b = 2
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,6 +1,6 @@
|
||||
"""I am a very helpful module docstring.
|
||||
|
||||
-With trailing spaces:
|
||||
+With trailing spaces:
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
||||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
Ut enim ad minim veniam,
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```python
|
||||
"""I am a very helpful module docstring.
|
||||
|
||||
With trailing spaces:
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
||||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
Ut enim ad minim veniam,
|
||||
quis nostrud exercitation ullamco laboris
|
||||
nisi ut aliquip ex ea commodo consequat.
|
||||
Duis aute irure dolor in reprehenderit in voluptate
|
||||
velit esse cillum dolore eu fugiat nulla pariatur.
|
||||
Excepteur sint occaecat cupidatat non proident,
|
||||
sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
"""
|
||||
|
||||
a = 1
|
||||
|
||||
|
||||
"""Look at me I'm a docstring...
|
||||
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
........................................................NOT!
|
||||
"""
|
||||
|
||||
|
||||
b = 2
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```python
|
||||
"""I am a very helpful module docstring.
|
||||
|
||||
With trailing spaces:
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
||||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
Ut enim ad minim veniam,
|
||||
quis nostrud exercitation ullamco laboris
|
||||
nisi ut aliquip ex ea commodo consequat.
|
||||
Duis aute irure dolor in reprehenderit in voluptate
|
||||
velit esse cillum dolore eu fugiat nulla pariatur.
|
||||
Excepteur sint occaecat cupidatat non proident,
|
||||
sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
"""
|
||||
|
||||
a = 1
|
||||
|
||||
|
||||
"""Look at me I'm a docstring...
|
||||
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
............................................................
|
||||
........................................................NOT!
|
||||
"""
|
||||
|
||||
|
||||
b = 2
|
||||
```
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/quote_styl
|
|||
---
|
||||
## Input
|
||||
```python
|
||||
'single'
|
||||
'single' # this string is treated as a docstring
|
||||
"double"
|
||||
r'r single'
|
||||
r"r double"
|
||||
|
@ -73,7 +73,7 @@ source_type = Python
|
|||
```
|
||||
|
||||
```python
|
||||
'single'
|
||||
'single' # this string is treated as a docstring
|
||||
'double'
|
||||
r'r single'
|
||||
r'r double'
|
||||
|
@ -135,7 +135,8 @@ def docstring_single():
|
|||
--- Stable
|
||||
+++ Preview
|
||||
@@ -1,4 +1,5 @@
|
||||
'single'
|
||||
-'single' # this string is treated as a docstring
|
||||
+"single" # this string is treated as a docstring
|
||||
+
|
||||
'double'
|
||||
r'r single'
|
||||
|
@ -159,7 +160,7 @@ source_type = Python
|
|||
```
|
||||
|
||||
```python
|
||||
"single"
|
||||
"single" # this string is treated as a docstring
|
||||
"double"
|
||||
r"r single"
|
||||
r"r double"
|
||||
|
@ -221,7 +222,7 @@ def docstring_single():
|
|||
--- Stable
|
||||
+++ Preview
|
||||
@@ -1,4 +1,5 @@
|
||||
"single"
|
||||
"single" # this string is treated as a docstring
|
||||
+
|
||||
"double"
|
||||
r"r single"
|
||||
|
@ -245,7 +246,7 @@ source_type = Python
|
|||
```
|
||||
|
||||
```python
|
||||
'single'
|
||||
'single' # this string is treated as a docstring
|
||||
"double"
|
||||
r'r single'
|
||||
r"r double"
|
||||
|
@ -307,7 +308,8 @@ def docstring_single():
|
|||
--- Stable
|
||||
+++ Preview
|
||||
@@ -1,4 +1,5 @@
|
||||
'single'
|
||||
-'single' # this string is treated as a docstring
|
||||
+"single" # this string is treated as a docstring
|
||||
+
|
||||
"double"
|
||||
r'r single'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue