-
-
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 4 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 |
---|---|---|
|
@@ -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,12 @@ def get_validation_data(doc): | |
errs.append(error('GL07', | ||
correct_sections=', '.join(correct_order))) | ||
|
||
pattern = re.compile('.. deprecated:: ') | ||
if (bool(pattern.search(doc.summary)) | ||
or bool(pattern.search(doc.extended_summary))): | ||
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 creating a property also, not sure why we implemented it this way (and it was possibly me), but I think 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. Sure I can do that, I had a few doubts - did you mean to also change the current Also is there any special significance of the 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. the current So, the idea would be to have a property to check the cases deprecated with the directive (so, 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. Got it, thanks! Have updated both properties in this manner, please have a look, |
||
if 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.