Skip to content

Commit

Permalink
Fix issue google#309
Browse files Browse the repository at this point in the history
  • Loading branch information
xosnos committed Apr 24, 2021
1 parent c1266d0 commit 9496fc7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fire/docstrings.py
Expand Up @@ -338,7 +338,8 @@ def _as_arg_name_and_type(text):
tokens = text.split()
if len(tokens) < 2:
return None
if _is_arg_name(tokens[0]):
if _is_arg_name(tokens[0]) and not _is_arg_name(tokens[1]):
# if _is_arg_name(tokens[0]):
type_token = ' '.join(tokens[1:])
type_token = type_token.lstrip('{([').rstrip('])}')
return tokens[0], type_token
Expand Down Expand Up @@ -406,7 +407,8 @@ def _consume_google_args_line(line_info, state):
state.current_arg = arg
else:
if state.current_arg:
state.current_arg.description.lines.append(split_line[0])
state.current_arg.description.lines.append(first + ':' + second)
# state.current_arg.description.lines.append(split_line[0])
else:
if state.current_arg:
state.current_arg.description.lines.append(split_line[0])
Expand Down
27 changes: 27 additions & 0 deletions fire/docstrings_test.py
Expand Up @@ -170,6 +170,33 @@ def test_google_format_multiline_arg_description(self):
)
self.assertEqual(expected_docstring_info, docstring_info)

def test_google_format_multiline_arg_description_with_colon(self):
docstring = """Docstring summary.
This is a longer description of the docstring. It spans multiple lines, as
is allowed.
Args:
param1 (int): The first parameter.
param2 (str): The second parameter. This has a lot of text, enough to
cover two lines. This description also contains a : colon.
"""
docstring_info = docstrings.parse(docstring)
expected_docstring_info = DocstringInfo(
summary='Docstring summary.',
description='This is a longer description of the docstring. It spans '
'multiple lines, as\nis allowed.',
args=[
ArgInfo(name='param1', type='int',
description='The first parameter.'),
ArgInfo(name='param2', type='str',
description='The second parameter. This has a lot of text, '
'enough to cover two lines. This description '
'also contains a : colon.'),
],
)
self.assertEqual(expected_docstring_info, docstring_info)

def test_rst_format_typed_args_and_returns(self):
docstring = """Docstring summary.
Expand Down

0 comments on commit 9496fc7

Please sign in to comment.