Closed mennthor closed 7 years ago
Hi Thorben,
you're getting two problems here:
@d.get_sectionsf("A")
@d.dedent
are called after the class has been compiled, i.e.__init__
doesn't know about the @d.get_sectionsf("A")
call.
@d.dedent
callBut you can solve this problem by using directly the __doc__
attribute of the class in combination with the dedents
and get_sections
method:
import docrep
d = docrep.DocstringProcessor()
class A():
__doc__ = d.get_sections(d.dedents("""
Docstring from A
Parameters
----------
a : int
Some value passed to _func.
"""), "A")
def __init__(self, a):
self._func(a)
@d.dedent
def _func(self, a):
"""
Doc from _func
Parameters
----------
%(A.parameters)s
"""
print(d.params)
return
That works :) Thanks again for the detailed answer 👍
You're welcome!
I tried a bit more and again I'm stuck. I usually document the
__init__
method in the class docstring rather than in__init__
itself.So I tried
This gives:
However,
d.params
has:What works instead is just to document the
__init__
method. But old habits and stuff...Is there a way around this, or am I again just not seeing how it works? I guess the
f
inget_sectionsf
is forfunction
, but I don't see the difference to a class, which also has__doc__
? Best, Thorben