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

Allow multiline strings to be rendered as comments #57

Open
wants to merge 2 commits into
base: master
from

Conversation

@wmvanvliet
Copy link

wmvanvliet commented Mar 8, 2019

Picking this up from #45

So, docstrings are an important part of Python code and one may wish to render them as comments instead of normal strings. However, differentiating when a multiline string is being used as a docstring and when not, is tricky and probably slow.

In absence of a perfect solution, I propose the following. We split out multiline strings into their own class pythonMultiString. By default, it is linked to String like we do with so many other string types:

highlight link pythonMultiString String

So, nothing changes out of the box.

However, if users want to assume all multiline strings are docstrings, they can add this to their configs:

highlight link pythonMultiString Comment

and everyone can be happy.

@nfnty
Copy link
Member

nfnty commented Feb 25, 2020

Highlighting all multiline strings as comments seems really strange to me. Not sure about this, since it adds complexity and possibly making highlighting less performant.

Also, there are a few string groups that haven't been split into multiline yet in this PR.

@wmvanvliet
Copy link
Author

wmvanvliet commented Feb 25, 2020

Highlighting all multiline strings as comments seems really strange to me.

And for me, not highlighting docstrings as comments looks weird in most colorschemes. I work a lot on data analysis code and docstrings spanning 50 lines are common.

Hence a user configurable variable to turn it on/off depending on your preference.

@nfnty
Copy link
Member

nfnty commented Feb 26, 2020

I understand the docstring usecase, but like I said highlighting all multiline strings as comments is weird and hacky.

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

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.