Skip to content

Commit 566dbed

Browse files
authored
update docs (#2)
* update docs * add desc
1 parent ac1c4f9 commit 566dbed

5 files changed

Lines changed: 14 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ruff-format"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
edition = "2024"
55
license = "MIT"
66
readme = "README.md"

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,26 @@ pip install ruff-format
1515
## Usage
1616

1717
```python
18-
from ruff_format import format_string, is_valid_syntax
18+
from ruff_format import format_string, is_valid_syntax, parse_code
1919

2020
code = """
2121
def hello( x,y, z ):
2222
print( x+y+z )
2323
"""
2424

25+
# Check if code has valid syntax
2526
assert is_valid_syntax(code)
2627

28+
# Parse code (raises RuntimeError on syntax errors)
29+
parse_code(code)
30+
31+
# Format code (default line width: 80)
2732
formatted = format_string(code)
2833
print(formatted)
34+
35+
# Format with a custom line width
36+
formatted = format_string(code, line_width=120)
37+
print(formatted)
2938
```
3039

3140
## Development

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ build-backend = "maturin"
44

55
[project]
66
name = "ruff-format"
7+
description = "Python bindings for the Ruff code formatter, built with Rust and PyO3."
78
requires-python = ">=3.8"
89
license = { text = "MIT" }
910
classifiers = [

ruff_format.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def is_valid_syntax(code: str) -> bool:
1818
True if the code has valid syntax, False otherwise.
1919
"""
2020

21-
def format_string(code: str, *, line_width: int) -> str:
21+
def format_string(code: str, *, line_width: int = 80) -> str:
2222
"""Format a Python code string using Ruff.
2323
2424
Args:

0 commit comments

Comments
 (0)