-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: Deprecation directive in Docstrings should be placed before the extended summary #24188
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 3 commits
1f7f9b8
0388292
3950b3c
dae5a76
470f265
27811ee
5599343
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 |
---|---|---|
|
@@ -407,6 +407,20 @@ def sections_in_wrong_order(self): | |
before Examples. | ||
""" | ||
|
||
def deprecation_in_wrong_order(self): | ||
""" | ||
This is what old method does. | ||
|
||
This is an extended summary with more details about | ||
what `some_old_method` does. | ||
|
||
The extended summary can contain multiple paragraphs. | ||
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. Do you mind of instead of this description, explain what is wrong in the PR here. 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. Have changed the description to explain what is wrong with the Docstring |
||
|
||
.. deprecated:: 1.0 | ||
This should generate an error as it needs to go before | ||
extended summary. | ||
""" | ||
|
||
def method_wo_docstrings(self): | ||
pass | ||
|
||
|
@@ -772,6 +786,8 @@ def test_bad_generic_functions(self, func): | |
('BadGenericDocStrings', 'sections_in_wrong_order', | ||
('Sections are in the wrong order. Correct order is: Parameters, ' | ||
'See Also, Examples',)), | ||
('BadGenericDocStrings', 'deprecation_in_wrong_order', | ||
('Deprecation warning should precede extended summary',)), | ||
('BadSeeAlso', 'desc_no_period', | ||
('Missing period at end of description for See Also "Series.iloc"',)), | ||
('BadSeeAlso', 'desc_first_letter_lowercase', | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -79,6 +79,7 @@ | |||||||||||||
'GL07': 'Sections are in the wrong order. Correct order is: ' | ||||||||||||||
'{correct_sections}', | ||||||||||||||
'GL08': 'The object does not have a docstring', | ||||||||||||||
'GL09': 'Deprecation warning should precede extended summary', | ||||||||||||||
'SS01': 'No summary found (a short summary in a single line should be ' | ||||||||||||||
'present at the beginning of the docstring)', | ||||||||||||||
'SS02': 'Summary does not start with a capital letter', | ||||||||||||||
|
@@ -624,6 +625,10 @@ def get_validation_data(doc): | |||||||||||||
errs.append(error('GL07', | ||||||||||||||
correct_sections=', '.join(correct_order))) | ||||||||||||||
|
||||||||||||||
if (doc.deprecated and not doc.name.startswith('pandas.Panel') | ||||||||||||||
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. Are there many wrong cases in 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. pandas/scripts/validate_docstrings.py Lines 494 to 499 in 77278ba
Actually I have changed |
||||||||||||||
and not doc.extended_summary.startswith('.. deprecated:: ')): | ||||||||||||||
errs.append(error('GL09')) | ||||||||||||||
|
||||||||||||||
if not doc.summary: | ||||||||||||||
errs.append(error('SS01')) | ||||||||||||||
else: | ||||||||||||||
|
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.
What was the reason for doing this?
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.
That was done so that the generated docstring matches the expected format of -
Summary
.. deprecated::
Extended Summary
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.
If the validation doesn't fail, I guess this is correct. But if you can copy the output of
./scripts/validate_docstrings.py pandas.Series.<this_method>
in a comment, so we can see how the final version is, that would be great.Uh oh!
There was an error while loading. Please reload this page.
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.
For the final version, running
python ./scripts/validate_docstrings.py pandas.Series.ptp --errors=GL09
gives -The unchanged
generic.py
file fails the validation with an output like below, where there is additional whitespace before the deprecated directive (does not match required format) -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.
Use numpy.ptp instead
should be indented with four spaces (the.. deprecated::
is not ok, aligned with the summary)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.
It actually displays like below, I think when I pasted the text here it got reformatted -
Is this ok?
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.
The deprecated is correctly aligned. The rest will need to be changed (the summary should fit in a single line, and the rest should go to the standard summary), but that's from the original code, and we'll take care later in a separate PR.
So, happy with it here.