Skip to content
Browse files

DocumentationAPI: Ignore triple quote strings

Ignore whole triple quoted string literal

Fixes #4631
  • Loading branch information
damngamerz committed Aug 12, 2017
1 parent 893c858 commit cebe4f22a05e71a24cf98c8559cb140bf3df4505
@@ -246,4 +246,14 @@ def extract_documentation_with_markers(content, docstyle_definition):
if doc:
yield doc
# Ignore string literals
ignore_regex = re.compile(
'^\s*r?(?P<marker>' +
('|'.join(re.escape(s) for s in doc.marker[0])) +
# Starting line of doc_string where marker is present
start_line = doc.range.start.line - 1
ignore_string_match =[start_line])

if ignore_string_match:
yield doc
@@ -246,6 +246,32 @@ def test_DocBaseClass_extraction_PYTHON3_3(self):
TextPosition(1, 1))])

def test_DocBaseClass_extraction_PYTHON3_4(self):
data = ['\n', 'triple_quote_string_test = """\n',
'This is not a docstring\n', '"""\n']

docstyle_PYTHON3_default = DocstyleDefinition.load('PYTHON3',

# Nothing is yielded as triple quote string literals are being
# ignored.
list(DocBaseClass.extract(data, 'PYTHON3', 'default')),

def test_DocBaseClass_extraction_PYTHON3_5(self):
data = ['r"""\n', 'This is a raw docstring\n', '"""\n']

docstyle_PYTHON3_default = DocstyleDefinition.load('PYTHON3',

list(DocBaseClass.extract(data, 'PYTHON3', 'default')),
[DocumentationComment('\nThis is a raw docstring\n',
docstyle_PYTHON3_default, 'r',
TextPosition(1, 2))])

def test_generate_diff(self):
data_old = ['\n', '""" documentation in single line """\n']
for doc_comment in DocBaseClass.extract(
@@ -75,3 +75,8 @@ def foobar_triangle(side_A, side_B, side_C):

return side_A + side_B + side_C

# This example of triple quote string literal is ignored.
triple_quote_string_literal_test = """
This is a triple quoted string and is not a valid docstring.

0 comments on commit cebe4f2

Please sign in to comment.
You can’t perform that action at this time.