Skip to content

Commit

Permalink
Test in scripts/validate_docstrings.py that the short summary is alwa…
Browse files Browse the repository at this point in the history
…ys one line long (pandas-dev#22617)
  • Loading branch information
Moisan authored and victor committed Sep 30, 2018
1 parent 3a4b501 commit b42c0e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
13 changes: 12 additions & 1 deletion scripts/tests/test_validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,15 @@ def multi_line(self):
which is not correct.
"""

def two_paragraph_multi_line(self):
"""
Extends beyond one line
which is not correct.
Extends beyond one line, which in itself is correct but the
previous short summary should still be an issue.
"""


class BadParameters(object):
"""
Expand Down Expand Up @@ -556,7 +565,9 @@ def test_bad_generic_functions(self, func):
('BadSummaries', 'no_capitalization',
('Summary must start with infinitive verb',)),
('BadSummaries', 'multi_line',
('a short summary in a single line should be present',)),
('Summary should fit in a single line.',)),
('BadSummaries', 'two_paragraph_multi_line',
('Summary should fit in a single line.',)),
# Parameters tests
('BadParameters', 'missing_params',
('Parameters {**kwargs} not documented',)),
Expand Down
8 changes: 6 additions & 2 deletions scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,12 @@ def double_blank_lines(self):

@property
def summary(self):
if not self.doc['Extended Summary'] and len(self.doc['Summary']) > 1:
return ''
return ' '.join(self.doc['Summary'])

@property
def num_summary_lines(self):
return len(self.doc['Summary'])

@property
def extended_summary(self):
if not self.doc['Extended Summary'] and len(self.doc['Summary']) > 1:
Expand Down Expand Up @@ -452,6 +454,8 @@ def validate_one(func_name):
errs.append('Summary must start with infinitive verb, '
'not third person (e.g. use "Generate" instead of '
'"Generates")')
if doc.num_summary_lines > 1:
errs.append("Summary should fit in a single line.")
if not doc.extended_summary:
wrns.append('No extended summary found')

Expand Down

0 comments on commit b42c0e8

Please sign in to comment.