Skip to content

Commit 59f7781

Browse files
committed
fix spliting of parameter lines.
if ' : ' is present twice in the line this drops any test after the second ' : ', which happens in some docstring that have the `default : stuff` idiom
1 parent 4e7c5ad commit 59f7781

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

numpydoc/docscrape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def _parse_param_list(self, content, single_element_is_type=False):
220220
while not r.eof():
221221
header = r.read().strip()
222222
if ' : ' in header:
223-
arg_name, arg_type = header.split(' : ')[:2]
223+
arg_name, arg_type = header.split(' : ', maxsplit=1)
224224
else:
225225
if single_element_is_type:
226226
arg_name, arg_type = '', header

numpydoc/tests/test_docscrape.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
5656
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
5757
value drawn from the distribution.
58+
dtype : data type object, optional (default : float)
59+
The type and size of the data to be returned.
5860
list of str
5961
This is not a real return value. It exists to test
6062
anonymous return values.
@@ -199,20 +201,25 @@ def test_other_parameters():
199201

200202

201203
def test_returns():
202-
assert len(doc['Returns']) == 3
204+
assert len(doc['Returns']) == 4
203205
arg, arg_type, desc = doc['Returns'][0]
204206
assert arg == 'out'
205207
assert arg_type == 'ndarray'
206208
assert desc[0].startswith('The drawn samples')
207209
assert desc[-1].endswith('distribution.')
208-
210+
209211
arg, arg_type, desc = doc['Returns'][1]
212+
assert arg == 'dtype'
213+
assert arg_type == 'data type object, optional (default : float)'
214+
assert desc[0].startswith('The type and size')
215+
216+
arg, arg_type, desc = doc['Returns'][2]
210217
assert arg == ''
211218
assert arg_type == 'list of str'
212219
assert desc[0].startswith('This is not a real')
213220
assert desc[-1].endswith('anonymous return values.')
214221

215-
arg, arg_type, desc = doc['Returns'][2]
222+
arg, arg_type, desc = doc['Returns'][3]
216223
assert arg == ''
217224
assert arg_type == 'no_description'
218225
assert not ''.join(desc).strip()
@@ -404,6 +411,8 @@ def test_str():
404411
405412
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
406413
value drawn from the distribution.
414+
dtype : data type object, optional (default : float)
415+
The type and size of the data to be returned.
407416
list of str
408417
This is not a real return value. It exists to test
409418
anonymous return values.
@@ -570,6 +579,9 @@ def test_sphinx_str():
570579
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
571580
value drawn from the distribution.
572581
582+
**dtype** : data type object, optional (default : float)
583+
The type and size of the data to be returned.
584+
573585
list of str
574586
This is not a real return value. It exists to test
575587
anonymous return values.

0 commit comments

Comments
 (0)