Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-05-17 12:53:34 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-05-17 13:18:10 +0300
commit3206e3154afc8d948ff9cdbc7bd22775bea839ba (patch)
tree57314ccd5691b55ce67d98c4b8aca94a7e21be38 /sphinx/application.py
parent5f51a1e63f9442439466b7acede87ad21d49bdc0 (diff)
Add allowed_exceptions parameter to Sphinx.emit() (refs: #7683)
It allows handlers to raise specified exceptions.
Diffstat (limited to 'sphinx/application.py')
-rw-r--r--sphinx/application.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/sphinx/application.py b/sphinx/application.py
index 8f06bf9cf..b02fb4d60 100644
--- a/sphinx/application.py
+++ b/sphinx/application.py
@@ -436,22 +436,32 @@ class Sphinx:
logger.debug('[app] disconnecting event: [id=%s]', listener_id)
self.events.disconnect(listener_id)
- def emit(self, event: str, *args: Any) -> List:
+ def emit(self, event: str, *args: Any,
+ allowed_exceptions: Tuple["Type[Exception]", ...] = ()) -> List:
"""Emit *event* and pass *arguments* to the callback functions.
Return the return values of all callbacks as a list. Do not emit core
Sphinx events in extensions!
+
+ .. versionchanged:: 3.1
+
+ Added *allowed_exceptions* to specify path-through exceptions
"""
- return self.events.emit(event, *args)
+ return self.events.emit(event, *args, allowed_exceptions=allowed_exceptions)
- def emit_firstresult(self, event: str, *args: Any) -> Any:
+ def emit_firstresult(self, event: str, *args: Any,
+ allowed_exceptions: Tuple["Type[Exception]", ...] = ()) -> Any:
"""Emit *event* and pass *arguments* to the callback functions.
Return the result of the first callback that doesn't return ``None``.
.. versionadded:: 0.5
+ .. versionchanged:: 3.1
+
+ Added *allowed_exceptions* to specify path-through exceptions
"""
- return self.events.emit_firstresult(event, *args)
+ return self.events.emit_firstresult(event, *args,
+ allowed_exceptions=allowed_exceptions)
# registering addon parts