Giter Club home page Giter Club logo

Comments (6)

tmhedberg avatar tmhedberg commented on July 19, 2024

Yes, let g:SimpylFold_fold_docstring = 0 should prevent docstring folding.

from simpylfold.

savchenko avatar savchenko commented on July 19, 2024

Tried this, doesn't help. Testing with the following code:

import platform


def sys_type():
    """
    Returns system type
    """
    return platform.system()

def sys_version():
    """
    Returns system version
    """
    return platform.version()

Opening the file:
screen shot 2016-03-03 at 21 37 20

leader+f2:
screen shot 2016-03-03 at 21 39 29

As you can see, docstring lines are still folded. I have the following code in my .vimrc:

" Folding for *.py
autocmd BufWinEnter *.py setlocal foldexpr=SimpylFold(v:lnum) foldmethod=expr
autocmd BufWinLeave *.py setlocal foldexpr< foldmethod<

Full version of .vimrc: http://pastebin.com/JpkZvU8E

I guess it doesn't parse first """ correctly, if plugin can skip 1st line of double-quotes, then actual docstring will be shown. If I can help identifying a problem without vimscript knowledge – please let me know.

from simpylfold.

tmhedberg avatar tmhedberg commented on July 19, 2024

I may have misunderstood your original question. Are you asking how to prevent the docstrings from being folded, or how to ensure that, when they are folded, the first line of the docstring remains visible on the fold?

from simpylfold.

savchenko avatar savchenko commented on July 19, 2024

I would say the 2nd option. Idea is to show the general code overview when user opens a file with bazillion of functions. Something like:

import blah

# +-- 256 lines: def flip(coin): -----------------
""" Flips the :param: coin """

# +-- 16 lines: def stop_war(planet): ------------
""" Stops war on the :param: planet """

# +-- 512 lines: def something(): ----------------
""" Long description
     of complicated function
     which sounds like a hokku """

# is used just to avoid red highlights in Python code.

from simpylfold.

tmhedberg avatar tmhedberg commented on July 19, 2024

I see, sorry for misunderstanding.

It's not displaying the docstring in the fold because you're not putting the first line of the docstring on the same line as the opening quotes. If you format your docstrings like this:

"""This is a single-line docstring."""

or like this:

python
"""This is a multi-line docstring.
There's more than one line here.
"""


then they'll be displayed in the fold as long as you have `let g:SimpylFold_docstring_preview = 1` set.

Your use of a newline after the opening quotes is unconventional in Python; the common formatting conventions are standardized in [PEP 257](https://www.python.org/dev/peps/pep-0257/). This plugin generally assumes that you follow all of the widely used formatting conventions of the language. Handling idiosyncratic, non-standard formatting preferences correctly would require including a full Python parser in the plugin, which I'm not interested in doing.

This specific special case could be addressed by adding a few lines to the `SimpylFoldText` function. If you're interested in writing a patch that does this, I'd consider applying it.

from simpylfold.

savchenko avatar savchenko commented on July 19, 2024

Sure, I'll take a look tomorrow. Thanks.

from simpylfold.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.