mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fail better in `ExceptionDocumenter.can_document_member
` (#11660)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
parent
7d046a862f
commit
74329d9c51
4
CHANGES
4
CHANGES
@ -24,6 +24,10 @@ Bugs fixed
|
|||||||
for sibling files in a subdirectory.
|
for sibling files in a subdirectory.
|
||||||
Patch by Albert Shih.
|
Patch by Albert Shih.
|
||||||
* #11659: Allow ``?config=...`` in :confval:`mathjax_path`.
|
* #11659: Allow ``?config=...`` in :confval:`mathjax_path`.
|
||||||
|
* #11654: autodoc: Fail with a more descriptive error message
|
||||||
|
when an object claims to be an instance of ``type``,
|
||||||
|
but is not a class.
|
||||||
|
Patch by James Braza.
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
-------
|
-------
|
||||||
|
@ -1913,7 +1913,17 @@ class ExceptionDocumenter(ClassDocumenter):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any,
|
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
|
try:
|
||||||
return isinstance(member, type) and issubclass(member, BaseException)
|
return isinstance(member, type) and issubclass(member, BaseException)
|
||||||
|
except TypeError as exc:
|
||||||
|
# It's possible for a member to be considered a type, but fail
|
||||||
|
# issubclass checks due to not being a class. For example:
|
||||||
|
# https://github.com/sphinx-doc/sphinx/issues/11654#issuecomment-1696790436
|
||||||
|
msg = (
|
||||||
|
f'{cls.__name__} failed to discern if member {member} with'
|
||||||
|
f' membername {membername} is a BaseException subclass.'
|
||||||
|
)
|
||||||
|
raise ValueError(msg) from exc
|
||||||
|
|
||||||
|
|
||||||
class DataDocumenterMixinBase:
|
class DataDocumenterMixinBase:
|
||||||
|
Loading…
Reference in New Issue
Block a user