-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Add docstring validations for "See Also" section #23143
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
Changes from 5 commits
2755055
09ec596
d3313cd
1fabcad
067dad8
6901171
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,6 +334,33 @@ def method(self, foo=None, bar=None): | |
pass | ||
|
||
|
||
class BadSeeAlso(object): | ||
|
||
def desc_no_period(self): | ||
""" | ||
Return the first 5 elements of the Series. | ||
|
||
See Also | ||
-------- | ||
Series.tail : Return the last 5 elements of the Series. | ||
Series.iloc : Return a slice of the elements in the Series, | ||
which can also be used to return the first or last n | ||
""" | ||
pass | ||
|
||
def desc_first_letter_lowercase(self): | ||
""" | ||
Return the first 5 elements of the Series. | ||
|
||
see Also | ||
-------- | ||
Series.tail : return the last 5 elements of the Series. | ||
Series.iloc : Return a slice of the elements in the Series, | ||
which can also be used to return the first or last n. | ||
""" | ||
pass | ||
|
||
|
||
class BadSummaries(object): | ||
|
||
def wrong_line(self): | ||
|
@@ -564,6 +591,11 @@ def test_bad_generic_functions(self, func): | |
assert errors | ||
|
||
@pytest.mark.parametrize("klass,func,msgs", [ | ||
# See Also tests | ||
('BadSeeAlso', 'desc_no_period', | ||
('Missing period at end of description',)), | ||
('BadSeeAlso', 'desc_first_letter_lowercase', | ||
('should be capitalized',)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you test that the element reported is the element with the problem? Meaning that |
||
# Summary tests | ||
('BadSummaries', 'wrong_line', | ||
('should start in the line immediately after the opening quotes',)), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -496,10 +496,18 @@ def validate_one(func_name): | |
wrns.append('See Also section not found') | ||
else: | ||
for rel_name, rel_desc in doc.see_also.items(): | ||
if not rel_desc: | ||
if rel_desc: | ||
if not rel_desc.endswith('.'): | ||
errs.append('Missing period at end of description for ' | ||
'See Also "{}" reference'.format(rel_name)) | ||
if not rel_desc[0].isupper(): | ||
errs.append('Description should be capitalized for ' | ||
'See Also "{}" reference'.format(rel_name)) | ||
else: | ||
errs.append('Missing description for ' | ||
'See Also "{}" reference'.format(rel_name)) | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This blank line is not valid according to PEP-8. If you take a look at the checks, you'll see that travis is red, and if you go to its log, you'll see that this is the reason. |
||
for line in doc.raw_doc.splitlines(): | ||
if re.match("^ *\t", line): | ||
errs.append('Tabs found at the start of line "{}", ' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the lower case is a typo here, right?