Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Another attempt at #45 and #57, namely to properly highlight docstrings as comments.
For now, this implementation is very ugly, but it actually works. It only highlights things that should be docstrings without touching other types of multiline strings. This is accomplished by checking for
:
characters and combining that withnextgroup=pythonDocString
to interpret the first directly following multiline string as a docstring. Another case is added for the first multiline string appearing at the top of the file.See https://gist.github.com/wmvanvliet/36471bb456151d93b86c402b64684b0a for a bunch of challenging test cases.
The implementation is messy right now to work around a specific problem. Any pointers on how to solve this more elegantly are greatly appreciated. The problem is that
nextgroup=pythonDocString skipempty
will skip newlines, but not spaces in its search for the docstring, and so it will only find it when the docstring starts on the first column of a line. For now, the workaround is to match+^\s*"""+
as a docstring, i.e. also match the leading whitespace, but this causes the docstring rule to have precedence over the normal+"""+
multiline pattern. Ideally, the multiline rule should take precedence and have this precedence temporarily overwritten by the presence of a:
mark.