Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format doctests in docstrings #8811

Merged
merged 11 commits into from
Nov 27, 2023
Merged
Prev Previous commit
ruff_python_formatter: add CRLF test
This test ensures that CRLF line endings are set correctly within a
reformatted code snippet.
  • Loading branch information
BurntSushi committed Nov 27, 2023
commit 47e6e7650e9e8f199a2548092d88f0efb258e027
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
crates/ruff_linter/resources/test/fixtures/isort/line_ending_crlf.py text eol=crlf
crates/ruff_linter/resources/test/fixtures/pycodestyle/W605_1.py text eol=crlf

crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples_crlf.py text eol=crlf
crates/ruff_python_formatter/tests/snapshots/format@docstring_code_examples_crlf.py.snap text eol=crlf

ruff.schema.json linguist-generated=true text=auto eol=lf
*.md.snap linguist-language=Markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"docstring_code": "enabled",
"indent_style": "space",
"indent_width": 4,
"line_ending": "CarriageReturnLineFeed"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def doctest_line_ending():
"""
Do cool stuff.
>>> def foo( x ):
... print( x )
...
... print( x )
"""
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
source: crates/ruff_python_formatter/tests/fixtures.rs
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring_code_examples_crlf.py
---
## Input
```python
def doctest_line_ending():
"""
Do cool stuff.
>>> def foo( x ):
... print( x )
...
... print( x )
"""
pass
```

## Outputs
### Output 1
```
indent-style = space
line-width = 88
indent-width = 4
quote-style = Double
line-ending = CarriageReturnLineFeed
magic-trailing-comma = Respect
docstring-code = Enabled
preview = Disabled
```

```python
def doctest_line_ending():
"""
Do cool stuff.
>>> def foo(x):
... print(x)
...
... print(x)
"""
pass
```



Loading