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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update error message and test validator
  • Loading branch information
thoo committed Oct 24, 2018
commit 6a64a629215cba57b25c6d38a1b82507fe67d81b
24 changes: 11 additions & 13 deletions scripts/tests/test_validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,6 @@ def method(self, foo=None, bar=None):
"""
pass


class BadSeeAlso(object):

def prefix_pandas(self):
"""
Return prefix with `pandas` from See Also sec
"""
pass

class BadSummaries(object):

def wrong_line(self):
Expand Down Expand Up @@ -553,6 +544,13 @@ def no_punctuation(self):
"""
return "Hello world!"

class BadSeeAlso(object):

def prefix_pandas(self):
"""
Return prefix with `pandas` from See Also sec
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you briefly describe the test here. It'll be more useful than this sentence (see other tests for reference). Also, make sure there are no two spaces together, and that the text finishes with a period.

"""
pass

class TestValidator(object):

Expand Down Expand Up @@ -616,9 +614,6 @@ def test_bad_generic_functions(self, func):
assert errors

@pytest.mark.parametrize("klass,func,msgs", [
#SeeAlso tests
('BadSeeAlso', 'prefix_pandas',
('Should not start with pandas',)),
# Summary tests
('BadSummaries', 'wrong_line',
('should start in the line immediately after the opening quotes',)),
Expand Down Expand Up @@ -667,7 +662,10 @@ 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),
# SeeAlso tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space between See Also

('BadSeeAlso', 'prefix_pandas',
('Should not start with pandas',)),
])
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: 3 additions & 2 deletions scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,9 @@ def validate_one(func_name):
if not rel_desc:
errs.append('Missing description for '
'See Also "{}" reference'.format(rel_name))
if rel_name[:7].lower() == 'pandas.':
errs.append('{} should not have prefix `pandas`'.format(rel_name))
if rel_name.startswith('pandas.'):
errs.append('{} in the `See Also` section does not need the `pandas` prefix, '
'use {} instead.'.format(rel_name,rel_name.replace('pandas.','')))
for line in doc.raw_doc.splitlines():
if re.match("^ *\t", line):
errs.append('Tabs found at the start of line "{}", '
Expand Down