SimpylFold icon indicating copy to clipboard operation
SimpylFold copied to clipboard

Option to start definition fold after docstring

Open securitygeneration opened this issue 8 years ago • 13 comments

It would be nice to have a config option to always display the docstring, even when the method is folded.

securitygeneration avatar Feb 28 '17 12:02 securitygeneration

What do you mean by "always display the docstring"? Please, elaborate.

nfnty avatar Feb 28 '17 16:02 nfnty

So even when folded:

def method(): " Docstring " +-- 20 lines ------------

Fold the method body but not its declaration or docstring?

securitygeneration avatar Mar 03 '17 15:03 securitygeneration

I vote against implementing this, as it increases code complexity and predictability of folds for little gain.

nfnty avatar Mar 05 '17 12:03 nfnty

I agree. Unless we start seeing a significant number of requests for this, I don't think it's worth the added complexity.

tmhedberg avatar Mar 05 '17 15:03 tmhedberg

I would use this feature, if it were implemented.

jakabk avatar Apr 03 '17 07:04 jakabk

Opposite of this issue #93

ghost avatar Nov 16 '17 21:11 ghost

I'd like to have this feature also. Somehow it's nice to read all/a half/visual of folds docstrings.

ghost avatar Nov 16 '17 21:11 ghost

I also want this feature.

ekiefl avatar Jan 19 '18 07:01 ekiefl

I was also looking for an option to toggle this, but there appears to be none. +1 for this feature. Seeing the function header (with all the syntax coloring etc - the fold itself is colorless) increases readability. Using the builtin indent fold behaviour you get this feature as a side effect. Unfortunately the indent fold has other problems.

chtenb avatar Mar 04 '18 18:03 chtenb

+1. I was looking for an option where, when I open a python file, all method implementations are folded, but all the function headers and docs are visible. E.g.,

def foo():
    """
    does the thing
    """
    [+] FOLDED

tommyjcarpenter avatar Jan 03 '19 20:01 tommyjcarpenter

Leaving a comment here as this feature is closest to the behaviour I'd be expecting from folds. I am actually a little annoyed by the fact that there is no option to fold only the body of namespaces (class/method/function definition), i.e. results one would get when using vim's native set foldmethod=indent. Having the definitions included into the fold removes syntax highlighting from them and messes up the indentation.

So I think having the option to fold only the 'body' together with the already present functionality to include/exclude docstrings in the fold would constitute what people are asking for here.

Either way, thanks for the plugin, I really appreciate the conscious choice of keeping the feature set small.

Added screenshot to clarify 'body' folding Screenshot from 2019-07-16 14-26-57

fprawits avatar Jul 16 '19 12:07 fprawits

The screenshot above really shows why this feature is so needed. It allows you to identify interesting/relevant parts of the code, which are not always obvious from the method name (particularly when there are similar methods). As a security person, I too appreciate keeping code to a minimum, but I can't see this adding significant complexity.

securitygeneration avatar Aug 16 '19 09:08 securitygeneration

Would love to see something similar to @fprawits 's screenshot.. I like the folding but really wish I still had the highlighting on the function signature and just the body folded.

kevlarr avatar Oct 13 '20 14:10 kevlarr