diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/blank_line_before_class_docstring.options.json b/crates/ruff_python_formatter/resources/test/fixtures/ruff/blank_line_before_class_docstring.options.json new file mode 100644 index 00000000000000..8925dd0a8280f7 --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/blank_line_before_class_docstring.options.json @@ -0,0 +1,5 @@ +[ + { + "preview": "enabled" + } +] diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/blank_line_before_class_docstring.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/blank_line_before_class_docstring.py new file mode 100644 index 00000000000000..a8dbbafebbfd13 --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/blank_line_before_class_docstring.py @@ -0,0 +1,38 @@ +class NormalDocstring: + + """This is a docstring.""" + + +class DocstringWithComment0: + # This is a comment + """This is a docstring.""" + + +class DocstringWithComment1: + # This is a comment + + """This is a docstring.""" + + +class DocstringWithComment2: + + # This is a comment + """This is a docstring.""" + + +class DocstringWithComment3: + + # This is a comment + + """This is a docstring.""" + + +class DocstringWithComment4: + + + # This is a comment + + + """This is a docstring.""" + + diff --git a/crates/ruff_python_formatter/tests/snapshots/format@blank_line_before_class_docstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@blank_line_before_class_docstring.py.snap new file mode 100644 index 00000000000000..b3986d0395ff1a --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/format@blank_line_before_class_docstring.py.snap @@ -0,0 +1,95 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/blank_line_before_class_docstring.py +--- +## Input +```python +class NormalDocstring: + + """This is a docstring.""" + + +class DocstringWithComment0: + # This is a comment + """This is a docstring.""" + + +class DocstringWithComment1: + # This is a comment + + """This is a docstring.""" + + +class DocstringWithComment2: + + # This is a comment + """This is a docstring.""" + + +class DocstringWithComment3: + + # This is a comment + + """This is a docstring.""" + + +class DocstringWithComment4: + + + # This is a comment + + + """This is a docstring.""" + + +``` + +## Outputs +### Output 1 +``` +indent-style = space +line-width = 88 +indent-width = 4 +quote-style = Double +line-ending = LineFeed +magic-trailing-comma = Respect +docstring-code = Disabled +docstring-code-line-width = "dynamic" +preview = Enabled +``` + +```python +class NormalDocstring: + """This is a docstring.""" + + +class DocstringWithComment0: + # This is a comment + """This is a docstring.""" + + +class DocstringWithComment1: + # This is a comment + + """This is a docstring.""" + + +class DocstringWithComment2: + # This is a comment + """This is a docstring.""" + + +class DocstringWithComment3: + # This is a comment + + """This is a docstring.""" + + +class DocstringWithComment4: + # This is a comment + + """This is a docstring.""" +``` + + +