mirror of
https://github.com/readthedocs/sphinx-autoapi
synced 2024-11-10 01:10:27 +00:00
Fixed autodoc directives documenting properties as methods
This commit is contained in:
parent
e281137654
commit
06a1969d11
@ -29,6 +29,7 @@ Bug Fixes
|
||||
* `#244 <https://github.com/readthedocs/sphinx-autoapi/issues/244>`:
|
||||
Fixed an unnecessary deprecation warning being raised when running
|
||||
sphinx-build from the same directory as conf.py.
|
||||
* Fixed properties documented by Autodoc directives geting documented as methods.
|
||||
|
||||
|
||||
V1.5.1 (2020-10-01)
|
||||
|
@ -212,6 +212,24 @@ class AutoapiMethodDocumenter(
|
||||
self.add_line(" :{}:".format(property_type), sourcename)
|
||||
|
||||
|
||||
class AutoapiPropertyDocumenter(
|
||||
AutoapiMethodDocumenter, AutoapiDocumenter, autodoc.PropertyDocumenter
|
||||
):
|
||||
objtype = "apiproperty"
|
||||
directivetype = "method"
|
||||
# Always prefer AutoapiDocumenters
|
||||
priority = autodoc.MethodDocumenter.priority * 100 + 100 + 1
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member, membername, isattr, parent):
|
||||
return isinstance(member, PythonMethod) and "property" in member.properties
|
||||
|
||||
def add_directive_header(self, sig):
|
||||
super(AutoapiPropertyDocumenter, self).add_directive_header(sig)
|
||||
sourcename = self.get_sourcename()
|
||||
self.add_line(" :property:", sourcename)
|
||||
|
||||
|
||||
class AutoapiDataDocumenter(AutoapiDocumenter, autodoc.DataDocumenter):
|
||||
objtype = "apidata"
|
||||
directivetype = "data"
|
||||
|
@ -303,6 +303,7 @@ def setup(app):
|
||||
app.add_config_value("autoapi_python_class_content", "class", "html")
|
||||
app.add_config_value("autoapi_generate_api_docs", True, "html")
|
||||
app.add_autodocumenter(documenters.AutoapiFunctionDocumenter)
|
||||
app.add_autodocumenter(documenters.AutoapiPropertyDocumenter)
|
||||
app.add_autodocumenter(documenters.AutoapiDecoratorDocumenter)
|
||||
app.add_autodocumenter(documenters.AutoapiClassDocumenter)
|
||||
app.add_autodocumenter(documenters.AutoapiMethodDocumenter)
|
||||
|
Loading…
Reference in New Issue
Block a user