|
326 | 326 | from sphinx.ext.autosummary import Autosummary
|
327 | 327 |
|
328 | 328 |
|
| 329 | +class AccessorDocumenter(MethodDocumenter): |
| 330 | + """ |
| 331 | + Specialized Documenter subclass for accessors. |
| 332 | + """ |
| 333 | + |
| 334 | + objtype = 'accessor' |
| 335 | + directivetype = 'method' |
| 336 | + |
| 337 | + # lower than MethodDocumenter so this is not chosen for normal methods |
| 338 | + priority = 0.6 |
| 339 | + |
| 340 | + def format_signature(self): |
| 341 | + # this method gives an error/warning for the accessors, therefore |
| 342 | + # overriding it (accessor has no arguments) |
| 343 | + return '' |
| 344 | + |
| 345 | + |
329 | 346 | class AccessorLevelDocumenter(Documenter):
|
330 | 347 | """
|
331 | 348 | Specialized Documenter subclass for objects on accessor level (methods,
|
@@ -381,12 +398,17 @@ class AccessorAttributeDocumenter(AccessorLevelDocumenter, AttributeDocumenter):
|
381 | 398 | objtype = 'accessorattribute'
|
382 | 399 | directivetype = 'attribute'
|
383 | 400 |
|
| 401 | + # lower than AttributeDocumenter so this is not chosen for normal attributes |
| 402 | + priority = 0.6 |
384 | 403 |
|
385 | 404 | class AccessorMethodDocumenter(AccessorLevelDocumenter, MethodDocumenter):
|
386 | 405 |
|
387 | 406 | objtype = 'accessormethod'
|
388 | 407 | directivetype = 'method'
|
389 | 408 |
|
| 409 | + # lower than MethodDocumenter so this is not chosen for normal methods |
| 410 | + priority = 0.6 |
| 411 | + |
390 | 412 |
|
391 | 413 | class AccessorCallableDocumenter(AccessorLevelDocumenter, MethodDocumenter):
|
392 | 414 | """
|
@@ -483,6 +505,7 @@ def remove_flags_docstring(app, what, name, obj, options, lines):
|
483 | 505 |
|
484 | 506 | def setup(app):
|
485 | 507 | app.connect("autodoc-process-docstring", remove_flags_docstring)
|
| 508 | + app.add_autodocumenter(AccessorDocumenter) |
486 | 509 | app.add_autodocumenter(AccessorAttributeDocumenter)
|
487 | 510 | app.add_autodocumenter(AccessorMethodDocumenter)
|
488 | 511 | app.add_autodocumenter(AccessorCallableDocumenter)
|
|
0 commit comments