-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Changes to validate_docstring script to be able to check all docstrings at once #22408
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
b31fc10
5d2815f
5bb7b9b
86327d4
188f4a3
0d25298
577308e
156b997
3a5e7fd
1a8aee9
aa4807a
1d2c5c0
db782fd
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 |
---|---|---|
|
@@ -45,6 +45,24 @@ | |
|
||
|
||
def get_api_items(): | ||
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. Thanks for the docstring it helps a lot! Is there a way to make a minimal test for this? Don't want to go overboard with tests here but I am worried that if this were to somehow break in the future it could allow subtle failures in subsequent tests to go through unnoticed 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. Makes sense to me, but I'd address it in a separate PR |
||
""" | ||
Parse api.rst file from the documentation, and extract all the functions, | ||
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. Should we make the first sentence one line? 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 change this? Maybe missed on prior review 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. You've got the one liner summary above. 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. My mistake - thanks for clarifying |
||
methods, classes, attributes... This should include all pandas public API. | ||
|
||
Yields | ||
------ | ||
name : str | ||
The name of the object (e.g. 'pandas.Series.str.upper). | ||
func : function | ||
The object itself. In most cases this will be a function or method, | ||
but it can also be classes, properties, cython objects... | ||
section : str | ||
The name of the section in the API page where the object item is | ||
located. | ||
subsection : str | ||
The name of the subsection in the API page where the object item is | ||
located. | ||
""" | ||
api_fname = os.path.join(BASE_PATH, 'doc', 'source', 'api.rst') | ||
|
||
previous_line = current_section = current_subsection = '' | ||
|
@@ -177,9 +195,15 @@ def is_function_or_method(self): | |
|
||
@property | ||
def source_file_name(self): | ||
""" | ||
File name where the object is implemented (e.g. pandas/core/frame.py). | ||
""" | ||
try: | ||
fname = inspect.getsourcefile(self.code_obj) | ||
except TypeError: | ||
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 does this do? 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 exactly? the |
||
# In some cases the object is something complex like a cython | ||
# object that can't be easily introspected. An it's better to | ||
# return the source code file of the object as None, than crash | ||
pass | ||
else: | ||
if fname: | ||
|
@@ -188,9 +212,15 @@ def source_file_name(self): | |
|
||
@property | ||
def source_file_def_line(self): | ||
""" | ||
Number of line where the object is defined in its file. | ||
""" | ||
try: | ||
return inspect.getsourcelines(self.code_obj)[-1] | ||
except (OSError, TypeError): | ||
# In some cases the object is something complex like a cython | ||
# object that can't be easily introspected. An it's better to | ||
# return the line number as None, than crash | ||
pass | ||
|
||
@property | ||
|
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.
Rather complex function - can we add a docstring to explain what this is doing?