Skip to content

Commit

Permalink
add support for nested accessors in documenter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fraserdominicdavid authored Oct 19, 2023
1 parent 0cd8ae3 commit dd90b20
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions sphinx_autosummary_accessors/documenters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,6 @@
from sphinx.ext.autodoc.importer import import_module


class AccessorDocumenter(MethodDocumenter):
"""
Specialized Documenter subclass for accessors.
"""

objtype = "accessor"
directivetype = "method"

# lower than MethodDocumenter so this is not chosen for normal methods
priority = 0.6

def format_signature(self):
# this method gives an error/warning for the accessors, therefore
# overriding it (accessor has no arguments)
return ""


class AccessorLevelDocumenter(Documenter):
"""
Specialized Documenter subclass for objects on accessor level (methods,
Expand Down Expand Up @@ -79,6 +62,23 @@ def resolve_name(self, modname, parents, path, base):
return modname, parents + [base]


class AccessorDocumenter(AccessorLevelDocumenter, MethodDocumenter):
"""
Specialized Documenter subclass for accessors.
"""

objtype = "accessor"
directivetype = "method"

# lower than MethodDocumenter so this is not chosen for normal methods
priority = 0.6

def format_signature(self):
# this method gives an error/warning for the accessors, therefore
# overriding it (accessor has no arguments)
return ""


class AccessorAttributeDocumenter(AccessorLevelDocumenter, AttributeDocumenter):
objtype = "accessorattribute"
directivetype = "attribute"
Expand Down

0 comments on commit dd90b20

Please sign in to comment.