ruff
ruff copied to clipboard
Enforcing docstring length (not the code snippets)
Is it possible to enforce docstring length (I know this possible for code snippets, but I mean the strings). Here's an example: Enforce docstring line length of 75:
def f(a, b):
"""
Very long long long long long long long long long long long long long long long long long description.
Parameters
----------
a: int
First number to add
b: int
Second number to add
Returns
-------
int
Another long long long long long long long long long long long long long long long long description.
"""
def f(a, b):
"""
Very long long long long long long long long long long long long long long
long long long description.
Parameters
----------
a: int
First number to add
b: int
Second number to add
Returns
-------
int
Another long long long long long long long long long long long long
long long long long description.
"""
Hy @ma-sadeghi
Not yet. We want to add docstring (the comment content) formatting in the future and are also thinking about string formatting in general (automatically splitting or collapsing them) but this isn't supported today.
@MichaReiser thanks for your quick reply. Looking forward to it!
Not sure if this is also what you had in mind @ma-sadeghi, but I'd suggest not only convert this:
def foo():
"""
Foo foo foo foo foo foo foo foo foo foo one two three four five six seven eight nine ten.
"""
return "foo"
Into:
def foo():
"""
Foo foo foo foo foo foo foo foo foo foo one two three four five six
seven eight nine ten.
"""
return "foo"
But also:
def foo():
"""
Foo foo foo foo foo foo foo foo foo foo
one two three four five six seven eight
nine ten.
"""
return "foo"
Into:
def foo():
"""
Foo foo foo foo foo foo foo foo foo foo one two three four five six
seven eight nine ten.
"""
return "foo"
@Peque Yep, that makes sense!
+1 to this request