what are the available sphinx callback events during epub generation
- User
what are the available sphinx callback events during epub generation
- Assistant
In Sphinx, the documentation generator, there are several events that can be hooked into using the
conf.pyconfiguration file to customize behavior during various stages of the build process, including EPUB generation. Here is a list of some key Sphinx events:- builder-inited: Triggered when the builder object is created.
- config-inited: Triggered after the configuration is initialized.
- env-get-outdated: Return a list of outdated docnames.
- env-merge-info: Merge in data of a subprocess by parallel build.
- env-purge-doc: Clean up any data linked to a specific document.
- env-before-read-docs: Called before reading all documents.
- source-read: Source files are read and the text can be modified before parsing.
- doctree-read: Called after reading a document into the doctree (parse stage).
- missing-reference: Handle missing references.
- doctree-resolved: Called when the doctree is transformed, but before writing output.
- env-updated: Called after environment is updated by doctrees.
- build-finished: Called after the build process ends, including for EPUB.
For EPUB-specific customization, you may be particularly interested in how certain events can help you manage and modify the content after it has been read from sources and before it is output in EPUB format. Here's how to hook into a basic event in your
conf.py:pythondef setup(app): app.connect('builder-inited', custom_builder_inited) app.connect('build-finished', custom_build_finished) def custom_builder_inited(app): # Custom code for 'builder-inited' event pass def custom_build_finished(app, exception): # Custom code for 'build-finished' event # This works for all builders including epub passFor more detailed and EPUB-specific processing, you might use
doctree-resolvedif you're interested in manipulating the document tree before it gets rendered into different formats.python