From ce4302520367f0249b3e250876cd3de82f740144 Mon Sep 17 00:00:00 2001 From: sfc-gh-mvashishtha Date: Mon, 10 Jun 2024 20:33:27 -0700 Subject: [PATCH] Fix docstrings Signed-off-by: sfc-gh-mvashishtha --- modin/utils.py | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/modin/utils.py b/modin/utils.py index f0cb3d8b861..3f44d28fd07 100644 --- a/modin/utils.py +++ b/modin/utils.py @@ -386,7 +386,19 @@ def _replace_doc( def _documentable_obj(obj: object) -> bool: - """Check if `obj` docstring could be patched.""" + """ + Check whether we can replace the docstring of `obj`. + + Parameters + ---------- + obj : object + Object whose docstring we want to replace. + + Returns + ------- + bool + Whether we can replace the docstring. + """ return bool( callable(obj) and not inspect.isclass(obj) @@ -399,10 +411,11 @@ def _documentable_obj(obj: object) -> bool: def _update_inherited_docstrings(doc_module: DocModule) -> None: """ Update all inherited docstrings. + Parameters ---------- - doc_module: DocModule - The current DocModule + doc_module : DocModule + The current DocModule. """ for doc_inheritance_call in _docstring_inheritance_calls: doc_inheritance_call(doc_module=doc_module.get()) # type: ignore[call-arg] @@ -416,6 +429,27 @@ def _inherit_docstrings_in_place( overwrite_existing: bool = False, apilink: Optional[Union[str, List[str]]] = None, ) -> None: + """ + Replace `cls_or_func` docstrings with `parent` docstrings in place. + + Parameters + ---------- + cls_or_func : Fn + The class or function whose docstrings we need to update. + doc_module : str + The docs module. + parent : object + Parent object from which the decorated object inherits __doc__. + excluded : list, default: [] + List of parent objects from which the class does not + inherit docstrings. + overwrite_existing : bool, default: False + Allow overwriting docstrings that already exist in + the decorated class. + apilink : str | List[str], optional + If non-empty, insert the link(s) to pandas API documentation. + Should be the prefix part in the URL template, e.g. "pandas.DataFrame". + """ # Import the docs module and get the class (e.g. `DataFrame`). imported_doc_module = importlib.import_module(doc_module) # Set the default parent so we can use it in case some docs are missing from