mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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.
This commit is contained in:
parent
88c72be190
commit
e6c8dd5727
@ -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.
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user