Skip to content

Commit 8d32f24

Browse files
committed
Leading and trailing blank lines in parameter description should not affect output
1 parent d7f30e7 commit 8d32f24

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

numpydoc/docscrape.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
import sys
1414

1515

16+
def strip_blank_lines(l):
17+
"Remove leading and trailing blank lines from a list of lines"
18+
while l and not l[0].strip():
19+
del l[0]
20+
while l and not l[-1].strip():
21+
del l[-1]
22+
return l
23+
24+
1625
class Reader(object):
1726
"""A line-based string reader.
1827
@@ -214,6 +223,7 @@ def _parse_param_list(self, content):
214223

215224
desc = r.read_to_next_unindented_line()
216225
desc = dedent_lines(desc)
226+
desc = strip_blank_lines(desc)
217227

218228
params.append((arg_name, arg_type, desc))
219229

numpydoc/tests/test_docscrape.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def test_parameters():
172172
arg, arg_type, desc = doc['Parameters'][1]
173173
assert_equal(arg_type, '(N, N) ndarray')
174174
assert desc[0].startswith('Covariance matrix')
175-
assert doc['Parameters'][0][-1][-2] == ' (1+2+3)/3'
175+
assert doc['Parameters'][0][-1][-1] == ' (1+2+3)/3'
176176

177177

178178
def test_other_parameters():
@@ -354,7 +354,6 @@ def test_str():
354354
.. math::
355355
356356
(1+2+3)/3
357-
358357
cov : (N, N) ndarray
359358
Covariance matrix of the distribution.
360359
shape : tuple of ints
@@ -948,6 +947,7 @@ def test_duplicate_signature():
948947
f : callable ``f(t, y, *f_args)``
949948
Aaa.
950949
jac : callable ``jac(t, y, *jac_args)``
950+
951951
Bbb.
952952
953953
Attributes

0 commit comments

Comments
 (0)