Skip to content

fix splitting of parameter lines. #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpydoc/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def _parse_param_list(self, content, single_element_is_type=False):
while not r.eof():
header = r.read().strip()
if ' : ' in header:
arg_name, arg_type = header.split(' : ')[:2]
arg_name, arg_type = header.split(' : ', maxsplit=1)
else:
if single_element_is_type:
arg_name, arg_type = '', header
Expand Down
22 changes: 20 additions & 2 deletions numpydoc/tests/test_docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
Given a shape of, for example, (m,n,k), m*n*k samples are
generated, and packed in an m-by-n-by-k arrangement. Because
each sample is N-dimensional, the output shape is (m,n,k,N).
dtype : data type object, optional (default : float)
The type and size of the data to be returned.

Returns
-------
Expand Down Expand Up @@ -180,7 +182,7 @@ def test_extended_summary():


def test_parameters():
assert len(doc['Parameters']) == 3
assert len(doc['Parameters']) == 4
names = [n for n, _, _ in doc['Parameters']]
assert all(a == b for a, b in zip(names, ['mean', 'cov', 'shape']))

Expand All @@ -189,6 +191,17 @@ def test_parameters():
assert desc[0].startswith('Covariance matrix')
assert doc['Parameters'][0][-1][-1] == ' (1+2+3)/3'

arg, arg_type, desc = doc['Parameters'][2]
assert arg == 'shape'
assert arg_type == 'tuple of ints'
assert desc[0].startswith('Given')
assert doc['Parameters'][0][-1][-1] == ' (1+2+3)/3'

arg, arg_type, desc = doc['Parameters'][3]
assert arg == 'dtype'
assert arg_type == 'data type object, optional (default : float)'
assert desc[0].startswith('The type and size')


def test_other_parameters():
assert len(doc['Other Parameters']) == 1
Expand All @@ -205,7 +218,7 @@ def test_returns():
assert arg_type == 'ndarray'
assert desc[0].startswith('The drawn samples')
assert desc[-1].endswith('distribution.')

arg, arg_type, desc = doc['Returns'][1]
assert arg == ''
assert arg_type == 'list of str'
Expand Down Expand Up @@ -394,6 +407,8 @@ def test_str():
Given a shape of, for example, (m,n,k), m*n*k samples are
generated, and packed in an m-by-n-by-k arrangement. Because
each sample is N-dimensional, the output shape is (m,n,k,N).
dtype : data type object, optional (default : float)
The type and size of the data to be returned.

Returns
-------
Expand Down Expand Up @@ -560,6 +575,9 @@ def test_sphinx_str():
generated, and packed in an m-by-n-by-k arrangement. Because
each sample is N-dimensional, the output shape is (m,n,k,N).

**dtype** : data type object, optional (default : float)
The type and size of the data to be returned.

:Returns:

**out** : ndarray
Expand Down