diff options
author | david ham <david.ham@imperial.ac.uk> | 2013-08-12 19:26:37 +0100 |
---|---|---|
committer | david ham <david.ham@imperial.ac.uk> | 2013-08-12 19:26:37 +0100 |
commit | 71d18ceddbea78189fd58a21cdb098e98833b251 (patch) | |
tree | 37acf6977a8cf05ba3cf933edfa80ce54af26ca6 /sphinx/ext/autodoc.py | |
parent | 7e9f9c814af42c8b7c15d5de132ba4a99be8a71b (diff) | |
download | sphinx-71d18ceddbea78189fd58a21cdb098e98833b251.tar.gz |
Create a derivative of the DocstringSignatureMixin which strips
signature strings from attributes. This scenario can occur when using
Cython and turning methods into attributes with an @property
decorator.
Diffstat (limited to 'sphinx/ext/autodoc.py')
-rw-r--r-- | sphinx/ext/autodoc.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 555a3106..53c7a250 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -924,6 +924,20 @@ class DocstringSignatureMixin(object): self.args, self.retann = result return Documenter.format_signature(self) +class DocstringStripSignatureMixin(DocstringSignatureMixin): + """ + Mixin for AttributeDocumenter to provide the + feature of stripping any function signature from the docstring. + """ + def format_signature(self): + if self.args is None and self.env.config.autodoc_docstring_signature: + # only act if a signature is not explicitly given already, and if + # the feature is enabled + result = self._find_signature() + if result is not None: + self.retann = result[1] + return Documenter.format_signature(self) + class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): """ @@ -1188,7 +1202,7 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): pass -class AttributeDocumenter(ClassLevelDocumenter): +class AttributeDocumenter(DocstringStripSignatureMixin,ClassLevelDocumenter): """ Specialized Documenter subclass for attributes. """ |