Skip to content

Commit

Permalink
DOC: Validate space before colon docstring parameters pandas-dev#23483 (
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyhyunkim authored and tm9k1 committed Nov 19, 2018
1 parent 32a50dc commit 61f1047
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 2 additions & 3 deletions scripts/tests/test_validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,9 +761,8 @@ def test_bad_generic_functions(self, func):
('BadParameters', 'missing_params',
('Parameters {**kwargs} not documented',)),
('BadParameters', 'bad_colon_spacing',
('Parameters {kind} not documented',
'Unknown parameters {kind: str}',
'Parameter "kind: str" has no type')),
('Parameter "kind" requires a space before the colon '
'separating the parameter name and type',)),
('BadParameters', 'no_description_period',
('Parameter "kind" description should finish with "."',)),
('BadParameters', 'no_description_period_with_directive',
Expand Down
8 changes: 7 additions & 1 deletion scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
'PR08': 'Parameter "{param_name}" description should start with a '
'capital letter',
'PR09': 'Parameter "{param_name}" description should finish with "."',
'PR10': 'Parameter "{param_name}" requires a space before the colon '
'separating the parameter name and type',
'RT01': 'No Returns section found',
'YD01': 'No Yields section found',
'SA01': 'See Also section not found',
Expand Down Expand Up @@ -644,7 +646,11 @@ def validate_one(func_name):
for param in doc.doc_parameters:
if not param.startswith("*"): # Check can ignore var / kwargs
if not doc.parameter_type(param):
errs.append(error('PR04', param_name=param))
if ':' in param:
errs.append(error('PR10',
param_name=param.split(':')[0]))
else:
errs.append(error('PR04', param_name=param))
else:
if doc.parameter_type(param)[-1] == '.':
errs.append(error('PR05', param_name=param))
Expand Down

0 comments on commit 61f1047

Please sign in to comment.