Closed mennthor closed 7 years ago
Hi @mennthor,
thanks for your comment! Could you please give a short example of what you're trying to do? Just give a small code example.
Otherwise, my first impression is you want something like
class A(object):
def my_method(self, a):
"""
Do something
Parameters
----------
a: int
Some random number
"""
pass
class B(A):
def my_method(self, a, b):
"""
Do something more advanced
Parameters
----------
a: int
Some random number
b: int
An additional number
"""
pass
In that case you could just do
from docrep import DocstringProcessor
docstrings = DocstringProcessor()
class A(object):
@docstrings.get_sectionsf('A.my_method')
@docstrings.dedent
def my_method(self, a):
"""
Do something
Parameters
----------
a: int
Some random number
"""
pass
class B(A):
@docstrings.dedent
def my_method(self, a, b):
"""
Do something more advanced
Parameters
----------
%(A.my_method.parameters)s
b: int
An additional number
"""
pass
Does this solve your problem?
Yes, that's exactly what I wanted to do. Many thanks :) Thanks for making this package, too 👍
Thanks! You're welcome.
I tried to use it between inherited classes. E.g. class B inherits from A and overrides a function with some extra args, so I want to use the same docstring for the identical arguments and just add in the extras.
If I use it like in your example and just wrap it inside classes, the second class can't find the keys defined in the first one (which seems reasonable, as it is a new scope):
... is not a valid key!
.How would this work/does this work with docrep?