diff options
author | Takayuki Shimizukawa <shimizukawa@gmail.com> | 2013-12-09 10:55:51 +0000 |
---|---|---|
committer | Takayuki Shimizukawa <shimizukawa@gmail.com> | 2013-12-09 10:55:51 +0000 |
commit | 1d5c7d1f2014fb3f78b13218f2699db33555da4b (patch) | |
tree | a9b34ee91a221397554dc7594c6842e50c6fdeff /sphinx/ext/autodoc.py | |
parent | 4fd9d846d6989dda38bac94a49848e5e3c811696 (diff) | |
download | sphinx-git-1d5c7d1f2014fb3f78b13218f2699db33555da4b.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 fac2d72fd..8d78feb21 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 |