Skip to content

Commit fa7bd17

Browse files
committed
DocumentationComment: Fix missing ending colon
Fix for missing ending colon, which made parser to break. Fixes #2143
1 parent 852ba5e commit fa7bd17

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎coalib/bearlib/languages/documentation/DocumentationComment.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ def _parse_documentation_with_symbols(self,
131131
# splitted contains the whole line from the param's name,
132132
# which in turn is further divided into its name and desc.
133133
splitted = line[param_offset:].split(param_identifiers[1], 1)
134+
# parser breaks if param_identifiers[1] is not present.
135+
# This checks for space and then splits the line accordingly
136+
# to extract param's name and desc.
137+
if len(splitted) == 1:
138+
splitted = line[param_offset:].split(' ', 1)
134139
cur_param = splitted[0].strip()
135140

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

148158
exception_desc = splitted[1]

‎tests/bearlib/languages/documentation/DocumentationCommentTest.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,17 @@ def test_python_doxygen(self):
214214

215215
self.assertEqual(parsed_docs, expected)
216216

217+
def test_python_missing_ending_colon(self):
218+
doc = (' This is a malformed docstring\n'
219+
' :param abc test description1\n'
220+
' :raises xyz test description2\n')
221+
expected = [self.Description(desc=' This is a malformed docstring\n'),
222+
self.Parameter(name='abc',
223+
desc=' test description1\n'),
224+
self.ExceptionValue(name='xyz',
225+
desc=' test description2\n')]
226+
self.check_docstring(doc, expected)
227+
217228

218229
class JavaDocumentationCommentTest(DocumentationCommentTest):
219230

0 commit comments

Comments
 (0)