Skip to content

Commit

Permalink
Merge pull request #66 from smspillaz/escaped-regions-docstrings
Browse files Browse the repository at this point in the history
spelling: Don't eject from escaped region in multiline docstring
  • Loading branch information
smspillaz committed Mar 22, 2017
2 parents 65caed3 + 51e22d3 commit 66e9576
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
10 changes: 8 additions & 2 deletions polysquarelinter/spelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def from_text(self, line, line_index, column, is_escaped):
(0, 0),
None)

def should_terminate_now(self, line):
def should_terminate_now(self, line, waiting_for):
"""Whether parsing within a comment should terminate now.
This is used for comment systems where there is no comment-ending
Expand All @@ -437,6 +437,9 @@ def should_terminate_now(self, line):
could end at a line ending. It returns true if, for a given line,
line is not a comment.
"""
if waiting_for not in (ParserState.EOL, self._end):
return False

if self._continue_regex:
return (re.match(self._continue_regex, line) is None)

Expand Down Expand Up @@ -551,7 +554,10 @@ def get_transition(self, # suppress(too-many-arguments)
# an explicit end marker. We can't detect line endings here because
# we want a disabled region to continue across multiple lines.
if (column == 0 and
comment_system_transitions.should_terminate_now(line)):
comment_system_transitions.should_terminate_now(
line,
self._resume_waiting_for
)):
return (InTextParser(), 0, None)

# Need to be a bit careful here, since we need to check what the
Expand Down
15 changes: 15 additions & 0 deletions test/test_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,21 @@ def test_no_spelling_error_comments_multiline_blocked_region(self, style):
style)
self.assertTrue(result)

@parameterized.expand(_KNOWN_STYLES)
def test_no_spelling_error_backticks_docstrings(self, style):
"""No spelling errors inside docstring where blocked out."""
content = (
"{s}{e}\n"
"\"\"\"Header.\n"
"```\n"
"esssscaped"
"```\n"
"\"\"\"\n"
"technical_term\n"
)
result = self._spellcheck_lint(content, style)
self.assertTrue(result)

@parameterized.expand(_KNOWN_STYLES)
def test_no_persist_multiline_blocked_region(self, style):
"""Don't persist multi-line blocked region."""
Expand Down

0 comments on commit 66e9576

Please sign in to comment.