Skip to content

Commit 2140561

Browse files
committed
FIX raises an error if a section appears twice
closes numpy#64
1 parent 8dd78ec commit 2140561

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

numpydoc/docscrape.py

+5
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,11 @@ def _parse(self):
327327
if not section.startswith('..'):
328328
section = (s.capitalize() for s in section.split(' '))
329329
section = ' '.join(section)
330+
if self[section]:
331+
msg = ("The section %s appears twice in the docstring." %
332+
section)
333+
raise ValueError(msg)
334+
330335
if section in ('Parameters', 'Returns', 'Yields', 'Raises',
331336
'Warns', 'Other Parameters', 'Attributes',
332337
'Methods'):

numpydoc/tests/test_docscrape.py

+16
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,22 @@ def test_returnyield():
209209
"""
210210
assert_raises(ValueError, NumpyDocString, doc_text)
211211

212+
213+
def test_section_twice():
214+
doc_text = """
215+
Test having a section Notes twice
216+
217+
Notes
218+
-----
219+
See the next note for more information
220+
221+
Notes
222+
-----
223+
That should break...
224+
"""
225+
assert_raises(ValueError, NumpyDocString, doc_text)
226+
227+
212228
def test_notes():
213229
assert doc['Notes'][0].startswith('Instead')
214230
assert doc['Notes'][-1].endswith('definite.')

0 commit comments

Comments
 (0)