diff options
author | shimizukawa <shimizukawa@gmail.com> | 2013-12-09 10:55:51 +0000 |
---|---|---|
committer | shimizukawa <shimizukawa@gmail.com> | 2013-12-09 10:55:51 +0000 |
commit | cc06d3e8033786bef0661f9c54e1795d5e678fae (patch) | |
tree | a9b34ee91a221397554dc7594c6842e50c6fdeff /sphinx/ext/autodoc.py | |
parent | 55d8f94240637cd111b10ec4fc150e6564524d67 (diff) | |
download | sphinx-cc06d3e8033786bef0661f9c54e1795d5e678fae.tar.gz |
Fix: autodoc class __init__ override not removed from docstring. Closes #1138
Diffstat (limited to 'sphinx/ext/autodoc.py')
-rw-r--r-- | sphinx/ext/autodoc.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index fac2d72f..8d78feb2 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -1071,8 +1071,18 @@ class ClassDocumenter(ModuleLevelDocumenter): # for classes, what the "docstring" is can be controlled via a # config value; the default is only the class docstring if content in ('both', 'init'): - initdocstring = self.get_attr( - self.get_attr(self.object, '__init__', None), '__doc__') + # get __init__ method document from __init__.__doc__ + if self.env.config.autodoc_docstring_signature: + # only act if the feature is enabled + init_doc = MethodDocumenter(self.directive, '__init__') + init_doc.object = self.get_attr(self.object, '__init__', None) + init_doc.objpath = ['__init__'] + init_doc._find_signature() # this effects to get_doc() result + initdocstring = '\n'.join( + ['\n'.join(l) for l in init_doc.get_doc(encoding)]) + else: + initdocstring = self.get_attr( + self.get_attr(self.object, '__init__', None), '__doc__') # for new-style classes, no __init__ means default __init__ if initdocstring == object.__init__.__doc__: initdocstring = None |