Skip to content

Commit b42c0e8

Browse files
Moisanvictor
authored and
victor
committed
Test in scripts/validate_docstrings.py that the short summary is always one line long (pandas-dev#22617)
1 parent 3a4b501 commit b42c0e8

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

scripts/tests/test_validate_docstrings.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,15 @@ def multi_line(self):
362362
which is not correct.
363363
"""
364364

365+
def two_paragraph_multi_line(self):
366+
"""
367+
Extends beyond one line
368+
which is not correct.
369+
370+
Extends beyond one line, which in itself is correct but the
371+
previous short summary should still be an issue.
372+
"""
373+
365374

366375
class BadParameters(object):
367376
"""
@@ -556,7 +565,9 @@ def test_bad_generic_functions(self, func):
556565
('BadSummaries', 'no_capitalization',
557566
('Summary must start with infinitive verb',)),
558567
('BadSummaries', 'multi_line',
559-
('a short summary in a single line should be present',)),
568+
('Summary should fit in a single line.',)),
569+
('BadSummaries', 'two_paragraph_multi_line',
570+
('Summary should fit in a single line.',)),
560571
# Parameters tests
561572
('BadParameters', 'missing_params',
562573
('Parameters {**kwargs} not documented',)),

scripts/validate_docstrings.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,12 @@ def double_blank_lines(self):
163163

164164
@property
165165
def summary(self):
166-
if not self.doc['Extended Summary'] and len(self.doc['Summary']) > 1:
167-
return ''
168166
return ' '.join(self.doc['Summary'])
169167

168+
@property
169+
def num_summary_lines(self):
170+
return len(self.doc['Summary'])
171+
170172
@property
171173
def extended_summary(self):
172174
if not self.doc['Extended Summary'] and len(self.doc['Summary']) > 1:
@@ -452,6 +454,8 @@ def validate_one(func_name):
452454
errs.append('Summary must start with infinitive verb, '
453455
'not third person (e.g. use "Generate" instead of '
454456
'"Generates")')
457+
if doc.num_summary_lines > 1:
458+
errs.append("Summary should fit in a single line.")
455459
if not doc.extended_summary:
456460
wrns.append('No extended summary found')
457461

0 commit comments

Comments
 (0)