Skip to content

Commit c0acf6d

Browse files
add support for nested accessors in documenter (#108)
Move `AccessorDocumenter` after `AccessorLevelDocumenter` and inherit the latter for the modified `resolve_name()` method which adds support for nested accessors. This allows the usage of the `autoaccessor` directive for nested accessors.
1 parent ba3ca3e commit c0acf6d

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

sphinx_autosummary_accessors/documenters.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,6 @@
22
from sphinx.ext.autodoc.importer import import_module
33

44

5-
class AccessorDocumenter(MethodDocumenter):
6-
"""
7-
Specialized Documenter subclass for accessors.
8-
"""
9-
10-
objtype = "accessor"
11-
directivetype = "method"
12-
13-
# lower than MethodDocumenter so this is not chosen for normal methods
14-
priority = 0.6
15-
16-
def format_signature(self):
17-
# this method gives an error/warning for the accessors, therefore
18-
# overriding it (accessor has no arguments)
19-
return ""
20-
21-
225
class AccessorLevelDocumenter(Documenter):
236
"""
247
Specialized Documenter subclass for objects on accessor level (methods,
@@ -79,6 +62,23 @@ def resolve_name(self, modname, parents, path, base):
7962
return modname, parents + [base]
8063

8164

65+
class AccessorDocumenter(AccessorLevelDocumenter, MethodDocumenter):
66+
"""
67+
Specialized Documenter subclass for accessors.
68+
"""
69+
70+
objtype = "accessor"
71+
directivetype = "method"
72+
73+
# lower than MethodDocumenter so this is not chosen for normal methods
74+
priority = 0.6
75+
76+
def format_signature(self):
77+
# this method gives an error/warning for the accessors, therefore
78+
# overriding it (accessor has no arguments)
79+
return ""
80+
81+
8282
class AccessorAttributeDocumenter(AccessorLevelDocumenter, AttributeDocumenter):
8383
objtype = "accessorattribute"
8484
directivetype = "attribute"

0 commit comments

Comments
 (0)