Hey there,
Can we update the Python Language definition in order to add folding markers for python docstrings (particularly for long function docstrings)?
Since there is an explicit beginning and end marker for these, I reckon this should be pretty easy, but I'm not sure how to add it in the face of that foldingStartMarker regex I see in the Python bundle (I have the latest one from SVN).
So, the convention (from what I understand) is this:
A long doc strings for a function looks like so: ----- python code ------- def my_function(param1, param2): """This function does xyz
There is some long documentation here ... ... ... blah blah ... .... """" # real python code here -----------------------------
So, something like adding a fold start and stop marker for """ could do the trick (the indentation levels should be the same for start and stop """ when folding is necessary).
Of course you can have this: ----------- def my_function(param1, param2): """Short docstring"""" # real python code here ----------
So I don't know if that will hose it any, but I'm guessing it would be ok since you can one-line { .. } code in languages that have brace begin/end block markers.
Thanks, -steve
On 12/9/2006, at 4:02, Steve Lianoglou wrote:
Can we update the Python Language definition in order to add folding markers for python docstrings (particularly for long function docstrings)?
I made this change to the Python grammar:
• make doc-strings foldable, at least when first line of the string has """ + at least one character and no terminating """ — the last line needs to only contain """
Though empty lines in doc-strings might confuse the other folding patterns, but that was already the case.
Hi Allan,
I made this change to the Python grammar:
• make doc-strings foldable, at least when first line of the string has """ + at least one character and no terminating """ — the last line needs to only contain """ Though empty lines in doc-strings might confuse the other folding patterns, but that was already the case.
It seems that empty lines in the doc-string are tripping up the doc- string fold itself.
Assume * are folding markers, then I get:
* """First line of doc string. second line * more... """"
It looks like we can combat that by putting an extra space as the "first" char of the blank line (at the appropriate indent level) ... so it's not a big deal.
Thanks for adding that into the language.
-steve