-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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 7 commits
ac1ca24
b06cdbf
25382b9
cd861fe
cb4bcc3
748b167
37da2cc
ccfa4d6
3039d78
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 |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
|
||
|
||
PRIVATE_CLASSES = ['NDFrame', 'IndexOpsMixin'] | ||
DIRECTIVES = ['versionadded', 'versionchanged', 'deprecated'] | ||
|
||
|
||
def _load_obj(obj_name): | ||
|
@@ -233,9 +234,19 @@ def correct_parameters(self): | |
def parameter_type(self, param): | ||
return self.doc_parameters[param][0] | ||
|
||
def parameter_desc(self, param): | ||
def raw_parameter_desc(self, param): | ||
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. @datapythonista I know you wanted this but I would prefer not to include unless it serves a purpose. May even be better served as a keyword argument going forward instead of a dedicated method so would rather not go down this path until needed. Outside of that I think this change looks good 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. We can just have |
||
return self.doc_parameters[param][1] | ||
|
||
def parameter_desc(self, param): | ||
desc = self.raw_parameter_desc(param) | ||
# Find and strip out any sphinx directives | ||
for directive in DIRECTIVES: | ||
full_directive = '.. {}'.format(directive) | ||
if full_directive in desc: | ||
# Only retain any description before the directive | ||
desc = desc[:desc.index(full_directive)] | ||
return desc | ||
|
||
@property | ||
def see_also(self): | ||
return collections.OrderedDict((name, ''.join(desc)) | ||
|
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'm not sure about
versionadded
andversionchanged
, butdeprecated
can have a description after if, for example:And it can be even multiline. Do you mind adding a test for that? I'm not sure if this is working with the current implementation.
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.
Also, if you check the
convert_datetime64
ofto_records
, there are cases where the directives come before the description. I'm happy if we consider only valid having them in one place (before or after the description). But, can we make the script generate a descriptive error for it? I guess with the current implementation we'll report that the parameter has no description.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've added a test case for multi-line descriptions.
Directive positioning is a bit more tricky. Enforcing them to be in one place would help, but the problem comes when trying to determine if text after the directive is directive description, or just generic parameter description. We need to make this distinction in order to produce a nice error message.
This is made harder by the fact that we're currently working with
doc_parameters
, which smooshes the whole description into one single-line string.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 enforcement after description is fine. I think @datapythonista is correct in that it will generate an error, albeit with the wrong message. If we wanted to clean that up I'd suggest a separate PR, though @datapythonista I'll leave that decision up to you