Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folding for raw docstrings #49

Merged
merged 3 commits into from Jan 25, 2016
Merged

Folding for raw docstrings #49

merged 3 commits into from Jan 25, 2016

Conversation

sotlampr
Copy link
Contributor

When a docstring contains latex expressions, ex. for Sphinx documentation, it is convenient to have the docstring as a raw string, e.g.

r""" This is a docstring that contains a latex expression
    y = \sum_{i=0}^{|\mathcal{D}|} (W_i \cdot X_i) +  b
"""

With this patch, SimpylFold will now take care and fold this kind of docstrings.

@@ -6,7 +6,7 @@ let b:loaded_SimpylFold = 1
let s:blank_regex = '\v^\s*(\#.*)?$'
let s:def_regex = '^\%(\s*\%(class\|def\) \w\+\|if\s*__name__\s*==\s*''__main__'':\s*\)'
let s:multiline_def_end_regex = '):$'
let s:docstring_start_regex = '^\s*\("""\|''''''\)\%(.*\1\s*$\)\@!'
let s:docstring_start_regex = '^\s*\("""\|r"""\|''''''\)\%(.*\1\s*$\)\@!'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raw strings can be triply single-quoted as well (r'''...'''). This pattern only matches the double-quoted variant. Additionally, it is legal to use a capital R instead of lowercase r. Something like [rR]? should address these cases.

tmhedberg added a commit that referenced this pull request Jan 25, 2016
Folding for raw docstrings
@tmhedberg tmhedberg merged commit 7c39b2e into tmhedberg:master Jan 25, 2016
@tmhedberg
Copy link
Owner

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants