Skip to content

Commit

Permalink
DocumentationComment: Fix missing ending colon
Browse files Browse the repository at this point in the history
Fix for missing ending colon, which made parser
to break.
Fixes #2143
  • Loading branch information
damngamerz committed Jun 25, 2017
1 parent 852ba5e commit fa7bd17
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions coalib/bearlib/languages/documentation/DocumentationComment.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ def _parse_documentation_with_symbols(self,
# splitted contains the whole line from the param's name,
# which in turn is further divided into its name and desc.
splitted = line[param_offset:].split(param_identifiers[1], 1)
# parser breaks if param_identifiers[1] is not present.
# This checks for space and then splits the line accordingly
# to extract param's name and desc.
if len(splitted) == 1:
splitted = line[param_offset:].split(' ', 1)
cur_param = splitted[0].strip()

param_desc = splitted[1]
Expand All @@ -143,6 +148,11 @@ def _parse_documentation_with_symbols(self,
exception_identifiers[0]) + len(exception_identifiers[0])
splitted = line[exception_offset:].split(
exception_identifiers[1], 1)
# parser breaks if exception_identifiers[1] is not present.
# This checks for space and then splits the line accordingly
# to extract exception's name and desc.
if len(splitted) == 1:
splitted = line[exception_offset:].split(' ', 1)
cur_exception = splitted[0].strip()

exception_desc = splitted[1]
Expand Down
11 changes: 11 additions & 0 deletions tests/bearlib/languages/documentation/DocumentationCommentTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,17 @@ def test_python_doxygen(self):

self.assertEqual(parsed_docs, expected)

def test_python_missing_ending_colon(self):
doc = (' This is a malformed docstring\n'
' :param abc test description1\n'
' :raises xyz test description2\n')
expected = [self.Description(desc=' This is a malformed docstring\n'),
self.Parameter(name='abc',
desc=' test description1\n'),
self.ExceptionValue(name='xyz',
desc=' test description2\n')]
self.check_docstring(doc, expected)


class JavaDocumentationCommentTest(DocumentationCommentTest):

Expand Down

0 comments on commit fa7bd17

Please sign in to comment.