Skip to content

Commit 977b044

Browse files
authored
Merge pull request #46 from MarketSquare/splittoolongline_doc
Add docs to SplitTooLongLine transformer
2 parents 44ccc6e + 10b7b98 commit 977b044

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

robotidy/transformers/SplitTooLongLine.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,41 @@
22
ModelTransformer,
33
Token
44
)
5+
from robotidy.decorators import check_start_end_line
56

67

78
EOL = Token(Token.EOL)
89
CONTINUATION = Token(Token.CONTINUATION)
910

1011

1112
class SplitTooLongLine(ModelTransformer):
13+
"""
14+
Split too long lines.
15+
If any line in keyword call exceeds given length limit (configurable using ``line_length``, 120 by default) it will be
16+
split::
17+
18+
Keyword With Longer Name ${arg1} ${arg2} ${arg3} # let's assume that arg2 is at 120 char
19+
20+
To::
21+
22+
Keyword With Longer Name ${arg1}
23+
... ${arg2} ${arg3}
24+
25+
Using ``split_on_every_arg`` flag (``False`` by default), you can force the formatter to put every argument in a new line::
26+
27+
Keyword With Longer Name
28+
... ${arg1}
29+
... ${arg2}
30+
... ${arg3}
31+
32+
Supports global formatting params: ``space_count``, ``--startline`` and ``--endline``.
33+
"""
1234
def __init__(self, line_length: int = 120, split_on_every_arg: bool = False):
1335
super().__init__()
1436
self.line_length = line_length
1537
self.split_on_every_arg = split_on_every_arg
1638

39+
@check_start_end_line
1740
def visit_KeywordCall(self, node): # noqa
1841
if all(line[-1].end_col_offset < self.line_length for line in node.lines):
1942
return node

0 commit comments

Comments
 (0)