Skip to content

DOC: Validate that See Also section items do not contain the pandas. prefix #23145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 27, 2018
20 changes: 19 additions & 1 deletion scripts/tests/test_validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,20 @@ def no_punctuation(self):
return "Hello world!"


class BadSeeAlso(object):

def prefix_pandas(self):
"""
Have `pandas` prefix in See Also section.

See Also
--------
pandas.Series.rename : Alter Series index labels or name.
DataFrame.head : The first `n` rows of the caller object.
"""
pass


class TestValidator(object):

def _import_path(self, klass=None, func=None):
Expand Down Expand Up @@ -656,7 +670,11 @@ def test_bad_generic_functions(self, func):
pytest.param('BadReturns', 'no_description', ('foo',),
marks=pytest.mark.xfail),
pytest.param('BadReturns', 'no_punctuation', ('foo',),
marks=pytest.mark.xfail)
marks=pytest.mark.xfail),
# See Also tests
('BadSeeAlso', 'prefix_pandas',
('pandas.Series.rename in `See Also` section '
'does not need `pandas` prefix',))
])
def test_bad_examples(self, capsys, klass, func, msgs):
result = validate_one(self._import_path(klass=klass, func=func)) # noqa:F821
Expand Down
5 changes: 4 additions & 1 deletion scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,10 @@ def validate_one(func_name):
if not rel_desc:
errs.append('Missing description for '
'See Also "{}" reference'.format(rel_name))

if rel_name.startswith('pandas.'):
errs.append('{} in `See Also` section does not '
'need `pandas` prefix, use {} instead.'
.format(rel_name, rel_name[len('pandas.'):]))
for line in doc.raw_doc.splitlines():
if re.match("^ *\t", line):
errs.append('Tabs found at the start of line "{}", '
Expand Down