mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
doc: Fix autodoc extension example
`directivetype` is set to mimic `ClassDocumenter`. Reflect that. `isinstance` would work on the enum members, but that is not what we want here. `issubclass` raises a TypeError when called on objects that are not classes.
This commit is contained in:
@@ -9,7 +9,7 @@ from sphinx.ext.autodoc import ClassDocumenter, bool_option
|
||||
|
||||
class IntEnumDocumenter(ClassDocumenter):
|
||||
objtype = 'intenum'
|
||||
directivetype = 'class'
|
||||
directivetype = ClassDocumenter.objtype
|
||||
priority = 10 + ClassDocumenter.priority
|
||||
option_spec = dict(ClassDocumenter.option_spec)
|
||||
option_spec['hex'] = bool_option
|
||||
@@ -18,7 +18,10 @@ class IntEnumDocumenter(ClassDocumenter):
|
||||
def can_document_member(cls,
|
||||
member: Any, membername: str,
|
||||
isattr: bool, parent: Any) -> bool:
|
||||
return isinstance(member, IntEnum)
|
||||
try:
|
||||
return issubclass(member, IntEnum)
|
||||
except TypeError:
|
||||
return False
|
||||
|
||||
def add_directive_header(self, sig: str) -> None:
|
||||
super().add_directive_header(sig)
|
||||
|
||||
Reference in New Issue
Block a user