-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
BUG: Ignore versionadded directive when checking for periods at docstring end #22423
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 1 commit
ac1ca24
b06cdbf
25382b9
cd861fe
cb4bcc3
748b167
37da2cc
ccfa4d6
3039d78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
|
||
|
||
PRIVATE_CLASSES = ['NDFrame', 'IndexOpsMixin'] | ||
DIRECTIVES = ['.. versionadded', '.. versionchanged', '.. deprecated'] | ||
|
||
|
||
def _load_obj(obj_name): | ||
|
@@ -466,13 +467,15 @@ def validate_one(func_name): | |
'should start with a ' | ||
'capital letter'.format(param)) | ||
|
||
if '.. versionadded::' in doc.parameter_desc(param): | ||
index = doc.parameter_desc(param).index('.. versionadded::') | ||
# Check for periods at the end of the description before the | ||
# versionadded directive | ||
period_check_index = index - 1 | ||
else: | ||
period_check_index = -1 | ||
period_check_index = -1 | ||
for directive in DIRECTIVES: | ||
if directive in doc.parameter_desc(param): | ||
# Get index of character before start of directive | ||
index = doc.parameter_desc(param).index(directive) - 1 | ||
# If this directive is closest to the description, use it. | ||
if index < period_check_index or period_check_index is -1: | ||
period_check_index = index | ||
|
||
if doc.parameter_desc(param)[period_check_index] != '.': | ||
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. What do you think about creating a new property in the class I think the code will be much more readable if we have this logic there, and in this part of the code where all validations happen we simply have something like 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. Yes, I agree that would be more useful and readable; I'll make a property. |
||
param_errs.append('Parameter "{}" description ' | ||
'should finish with "."'.format(param)) | ||
|
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.
afaik, all sphinx directives start with
..
so I think it's better to have just the names here.