You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if you want to limit the duplication of the docstrings (because now all the attributes/methods that needed to be added to dispatch to self._crs have a copy of the docstring), I think it should be relatively easy to use a decorator that automatically adds the docstring of the cython class.
Something like
def inherit_doc():
"""
A decorator adding the docstring from the equivalent `_CRS` method.
"""
def decorator(decorated):
original_method = getattr(_CRS, decorated.__name__, None)
if original_method:
doc = original_method.__doc__ or ""
else:
doc = ""
decorated.__doc__ = doc
return decorated
return decorator
I have been thinking on this for a while. It definitely bothered me to have to copy over the docstrings from the cython _CRS class.
However, I think it is useful for developers to see the docstrings in the ,py file.
Current format:
defto_json(self, pretty=False, indentation=2):
""" .. versionadded:: 2.4.0 Convert the object to a JSON string. Parameters ---------- pretty: bool If True, it will set the output to be a multiline string. Defaults to False. indentation: int If pretty is True, it will set the width of the indentation. Default is 2. Returns ------- str """returnself._crs.to_json(pretty=pretty, indentation=indentation)
I am thinking I will leave it as is for the time being. I appreciate your suggestion @jorisvandenbossche as it was a nice solution that I thought would have been a good method to handle duplicate docstrings.
if you want to limit the duplication of the docstrings (because now all the attributes/methods that needed to be added to dispatch to
self._crs
have a copy of the docstring), I think it should be relatively easy to use a decorator that automatically adds the docstring of the cython class.Something like
Originally posted by @jorisvandenbossche in #793 (comment)
The text was updated successfully, but these errors were encountered: