Replies: 1 comment
-
Quick self-answer here - solved it like this:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, first off -- thanks for this amazing library, I've had a ton of fun using it on my codebase.
I'm trying to address a case where there is a string argument (
SimpleString
) that exceeds the desired line length:I'd like to have this be transformed into a parenthesized concatenated string that is split/wrapped such that each of its elements, including the proper indentation, do no exceed 80 characters in line length:
Here is as far as I've gotten:
wrap_strings.py
I've got several questions:
SimpleString
that's longer than 80 chars with indent (usingPositionProvider
, not sure if there's a better way)ConcatenatedString
where any of the elements is longer than 80 chars. In this case I'd like to collect all of the elements and re-produce a correctly concatenated string none of the elements of which are longer than 80 chars with indent.Conceptually, I've taken a look at how
ConcatenatedString
s are expressed, and it seems like I'd have to do some sort of a recursion where I slice off the left side of the string up toline_length - indent
index, assign it to the left side of theConcatenatedString
, and pass the remainder down to the same function, until the right side of the string + indent does not exceed 80 chars.I'm a bit stumped on how to do this because when I tried assigning left and right on an empty
ConcatenatedString
I realized they're read-only (makes sense), so I probably need to build some sort of a recursive visitor that performs the logic I described above.What's the best way to move forward?
Thanks in advance for any help.
Beta Was this translation helpful? Give feedback.
All reactions