Event Manager API¶
- class sphinx.events.EventManager(app: Sphinx)[소스]¶
Event manager for Sphinx.
- add(name: str) None[소스]¶
Register a custom Sphinx event called name.
This is needed to be able to emit the event.
- 매개변수:
name – The name of the event.
- connect(name: Literal['config-inited'], callback: Callable[[Sphinx, Config], None], priority: int) int[소스]¶
- connect(name: Literal['builder-inited'], callback: Callable[[Sphinx], None], priority: int) int
- connect(name: Literal['env-get-outdated'], callback: Callable[[Sphinx, BuildEnvironment, Set[str], Set[str], Set[str]], Sequence[str]], priority: int) int
- connect(name: Literal['env-before-read-docs'], callback: Callable[[Sphinx, BuildEnvironment, list[str]], None], priority: int) int
- connect(name: Literal['env-purge-doc'], callback: Callable[[Sphinx, BuildEnvironment, str], None], priority: int) int
- connect(name: Literal['source-read'], callback: Callable[[Sphinx, str, list[str]], None], priority: int) int
- connect(name: Literal['include-read'], callback: Callable[[Sphinx, Path, str, list[str]], None], priority: int) int
- connect(name: Literal['doctree-read'], callback: Callable[[Sphinx, nodes.document], None], priority: int) int
- connect(name: Literal['env-merge-info'], callback: Callable[[Sphinx, BuildEnvironment, Set[str], BuildEnvironment], None], priority: int) int
- connect(name: Literal['env-updated'], callback: Callable[[Sphinx, BuildEnvironment], str], priority: int) int
- connect(name: Literal['env-get-updated'], callback: Callable[[Sphinx, BuildEnvironment], Iterable[str]], priority: int) int
- connect(name: Literal['env-check-consistency'], callback: Callable[[Sphinx, BuildEnvironment], None], priority: int) int
- connect(name: Literal['write-started'], callback: Callable[[Sphinx, Builder], None], priority: int) int
- connect(name: Literal['doctree-resolved'], callback: Callable[[Sphinx, nodes.document, str], None], priority: int) int
- connect(name: Literal['missing-reference'], callback: Callable[[Sphinx, BuildEnvironment, addnodes.pending_xref, nodes.TextElement], nodes.reference | None], priority: int) int
- connect(name: Literal['warn-missing-reference'], callback: Callable[[Sphinx, Domain, addnodes.pending_xref], bool | None], priority: int) int
- connect(name: Literal['build-finished'], callback: Callable[[Sphinx, Exception | None], None], priority: int) int
- connect(name: Literal['html-collect-pages'], callback: Callable[[Sphinx], Iterable[tuple[str, dict[str, Any], str]]], priority: int) int
- connect(name: Literal['html-page-context'], callback: Callable[[Sphinx, str, str, dict[str, Any], nodes.document], str | None], priority: int) int
- connect(name: Literal['linkcheck-process-uri'], callback: Callable[[Sphinx, str], str | None], priority: int) int
- connect(name: Literal['object-description-transform'], callback: Callable[[Sphinx, str, str, addnodes.desc_content], None], priority: int) int
- connect(name: Literal['autodoc-process-docstring'], callback: _AutodocProcessDocstringListener, priority: int) int
- connect(name: Literal['autodoc-before-process-signature'], callback: _AutodocBeforeProcessSignatureListener, priority: int) int
- connect(name: Literal['autodoc-process-signature'], callback: _AutodocProcessSignatureListener, priority: int) int
- connect(name: Literal['autodoc-process-bases'], callback: _AutodocProcessBasesListener, priority: int) int
- connect(name: Literal['autodoc-skip-member'], callback: _AutodocSkipMemberListener, priority: int) int
- connect(name: Literal['todo-defined'], callback: Callable[[Sphinx, todo_node], None], priority: int) int
- connect(name: Literal['viewcode-find-source'], callback: Callable[[Sphinx, str], tuple[str, dict[str, tuple[Literal['class', 'def', 'other'], int, int]]]], priority: int) int
- connect(name: Literal['viewcode-follow-imported'], callback: Callable[[Sphinx, str, str], str | None], priority: int) int
- connect(name: str, callback: Callable[..., Any], priority: int) int
Connect a handler to specific event.
Register callback to be called when the name event is emitted.
See event callbacks for details on available core events and the arguments of their corresponding callback functions.
- 매개변수:
name – The name of the target event.
callback – Callback function for the event.
priority – The priority of the callback. The callbacks will be invoked in ascending order of priority.
- 반환:
A listener ID, for use with the
disconnect()method.
버전 3.0에서 변경: Support priority
- disconnect(listener_id: int) None[소스]¶
Disconnect the handler given by listener_id.
- 매개변수:
listener_id – A listener_id previously returned by
connect().
- emit(name: str, *args: Any, allowed_exceptions: tuple[type[Exception], ...] = ()) list[Any][소스]¶
Emit a Sphinx event.
This emits the name event and passes args to the handler functions. Return the return values of all handlers as a list. Do not emit core Sphinx events in extensions!
- 매개변수:
name – The name of the event that will be emitted.
args – The arguments for the event, to be passed to the handler functions.
allowed_exceptions – The list of exceptions that are allowed in the handlers.
버전 3.1에서 변경: Added allowed_exceptions to specify path-through exceptions
- emit_firstresult(name: str, *args: Any, allowed_exceptions: tuple[type[Exception], ...] = ()) Any[소스]¶
Emit a Sphinx event and return the first result.
This emits the name event and passes args to the handler functions. The first non-None result is returned.
- 매개변수:
name – The name of the event that will be emitted.
args – The arguments for the event, to be passed to the handler functions.
allowed_exceptions – The list of exceptions that are allowed in the handlers.
Added in version 0.5.
버전 3.1에서 변경: Added allowed_exceptions to specify path-through exceptions