2008-03-18 18:19:21 +00:00
|
|
|
.. highlight:: rest
|
|
|
|
|
|
2014-01-20 17:21:44 +01:00
|
|
|
Application API
|
|
|
|
|
===============
|
|
|
|
|
|
|
|
|
|
.. module:: sphinx.application
|
|
|
|
|
:synopsis: Application class and extensibility interface.
|
2008-03-12 21:37:22 +00:00
|
|
|
|
2008-04-13 18:16:55 +00:00
|
|
|
|
2017-10-22 14:59:09 +01:00
|
|
|
Each Sphinx extension is a Python module with at least a :func:`setup`
|
|
|
|
|
function. This function is called at initialization time with one argument,
|
|
|
|
|
the application object representing the Sphinx process.
|
2014-01-20 17:21:44 +01:00
|
|
|
|
|
|
|
|
.. class:: Sphinx
|
|
|
|
|
|
|
|
|
|
This application object has the public API described in the following.
|
|
|
|
|
|
|
|
|
|
Extension setup
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
These methods are usually called in an extension's ``setup()`` function.
|
|
|
|
|
|
|
|
|
|
Examples of using the Sphinx extension API can be seen in the :mod:`sphinx.ext`
|
|
|
|
|
package.
|
2008-03-12 21:37:22 +00:00
|
|
|
|
2017-10-22 14:59:09 +01:00
|
|
|
.. currentmodule:: sphinx.application
|
2009-01-10 22:18:18 +01:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.setup_extension
|
2008-08-05 10:25:40 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.require_sphinx
|
2008-08-05 10:25:40 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.connect
|
2008-08-05 10:25:40 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.disconnect
|
2018-01-20 22:47:42 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_builder
|
2016-02-14 00:38:27 +09:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_config_value
|
2016-02-14 00:38:27 +09:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_event
|
2016-02-14 00:38:27 +09:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.set_translator
|
2016-02-13 21:22:21 +09:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_node
|
2016-02-13 21:22:21 +09:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_enumerable_node
|
2016-02-13 21:22:21 +09:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_directive
|
2008-05-24 18:03:56 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_role
|
2018-01-21 10:55:30 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_generic_role
|
2018-01-21 10:55:30 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_domain
|
2018-01-21 10:55:30 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_directive_to_domain
|
2008-03-18 18:19:21 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_role_to_domain
|
2008-03-18 18:19:21 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_index_to_domain
|
2008-03-18 18:19:21 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_object_type
|
2008-03-28 18:45:32 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_crossref_type
|
2008-03-28 18:45:32 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_transform
|
2008-03-28 18:45:32 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_post_transform
|
2008-03-12 21:37:22 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_js_file
|
2008-03-28 18:45:32 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_css_file
|
2009-10-27 19:58:40 +01:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_latex_package
|
2018-01-20 22:47:42 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_lexer
|
2008-03-28 18:45:32 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_autodocumenter
|
2008-03-28 18:45:32 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_autodoc_attrgetter
|
2008-03-28 18:45:32 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_search_language
|
2008-03-28 18:45:32 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_source_suffix
|
2018-02-11 21:13:32 +09:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_source_parser
|
2008-03-28 18:45:32 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_env_collector
|
2008-03-28 18:45:32 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_html_theme
|
2014-01-20 17:21:44 +01:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_html_math_renderer
|
2018-05-17 00:57:09 +09:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.add_message_catalog
|
2018-02-25 21:41:39 +09:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: Sphinx.is_parallel_allowed
|
2018-01-21 10:57:24 +00:00
|
|
|
|
2014-01-20 17:21:44 +01:00
|
|
|
.. exception:: ExtensionError
|
|
|
|
|
|
|
|
|
|
All these methods raise this exception if something went wrong with the
|
|
|
|
|
extension API.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Emitting events
|
|
|
|
|
---------------
|
|
|
|
|
|
2017-10-22 14:59:09 +01:00
|
|
|
.. class:: Sphinx
|
2023-07-28 22:30:26 +01:00
|
|
|
:no-index:
|
2008-08-04 09:54:45 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: emit
|
2018-01-20 22:47:42 +00:00
|
|
|
|
2021-01-24 00:08:04 +09:00
|
|
|
.. automethod:: emit_firstresult
|
2008-03-12 21:37:22 +00:00
|
|
|
|
2010-01-17 18:24:35 +01:00
|
|
|
|
2017-07-16 01:48:09 +09:00
|
|
|
Sphinx runtime information
|
|
|
|
|
--------------------------
|
|
|
|
|
|
|
|
|
|
The application object also provides runtime information as attributes.
|
|
|
|
|
|
2018-01-18 18:23:57 +09:00
|
|
|
.. attribute:: Sphinx.project
|
|
|
|
|
|
|
|
|
|
Target project. See :class:`.Project`.
|
|
|
|
|
|
2018-06-05 22:57:04 +09:00
|
|
|
.. attribute:: Sphinx.srcdir
|
2017-07-16 01:48:09 +09:00
|
|
|
|
|
|
|
|
Source directory.
|
|
|
|
|
|
2018-06-05 22:57:04 +09:00
|
|
|
.. attribute:: Sphinx.confdir
|
2017-07-16 01:48:09 +09:00
|
|
|
|
|
|
|
|
Directory containing ``conf.py``.
|
|
|
|
|
|
2018-06-05 22:57:04 +09:00
|
|
|
.. attribute:: Sphinx.doctreedir
|
2017-07-16 01:48:09 +09:00
|
|
|
|
|
|
|
|
Directory for storing pickled doctrees.
|
|
|
|
|
|
2018-06-05 22:57:04 +09:00
|
|
|
.. attribute:: Sphinx.outdir
|
2017-07-16 01:48:09 +09:00
|
|
|
|
|
|
|
|
Directory for storing built document.
|
|
|
|
|
|
2024-06-21 15:48:59 +02:00
|
|
|
.. autoattribute:: Sphinx.fresh_env_used
|
|
|
|
|
|
2008-03-12 21:37:22 +00:00
|
|
|
Sphinx core events
|
|
|
|
|
------------------
|
|
|
|
|
|
2024-06-20 10:40:22 +02:00
|
|
|
.. note:: Moved to :ref:`events`.
|
2008-04-13 18:16:55 +00:00
|
|
|
|
2013-10-12 20:48:03 +02:00
|
|
|
Checking the Sphinx version
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
|
|
.. currentmodule:: sphinx
|
|
|
|
|
|
|
|
|
|
Use this to adapt your extension to API changes in Sphinx.
|
|
|
|
|
|
2017-10-22 14:59:09 +01:00
|
|
|
.. autodata:: version_info
|
2013-10-12 20:48:03 +02:00
|
|
|
|
|
|
|
|
|
2014-01-20 17:21:44 +01:00
|
|
|
The Config object
|
|
|
|
|
-----------------
|
2008-04-13 18:16:55 +00:00
|
|
|
|
2017-12-04 20:30:23 +00:00
|
|
|
.. currentmodule:: sphinx.config
|
2013-10-12 21:01:25 +02:00
|
|
|
|
2017-12-04 20:30:23 +00:00
|
|
|
.. autoclass:: Config
|
2010-02-28 14:45:43 +01:00
|
|
|
|
2024-01-03 21:51:39 +00:00
|
|
|
.. py:class:: ENUM
|
|
|
|
|
:no-typesetting:
|
|
|
|
|
|
2010-02-28 14:45:43 +01:00
|
|
|
|
2014-01-20 17:21:44 +01:00
|
|
|
.. _template-bridge:
|
2010-02-28 14:45:43 +01:00
|
|
|
|
2014-01-20 17:21:44 +01:00
|
|
|
The template bridge
|
|
|
|
|
-------------------
|
2010-02-28 14:45:43 +01:00
|
|
|
|
2014-01-20 17:21:44 +01:00
|
|
|
.. currentmodule:: sphinx.application
|
2010-02-28 14:45:43 +01:00
|
|
|
|
2014-01-20 17:21:44 +01:00
|
|
|
.. autoclass:: TemplateBridge
|
2010-02-28 14:45:43 +01:00
|
|
|
:members:
|
2014-01-21 09:54:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
.. _exceptions:
|
|
|
|
|
|
|
|
|
|
Exceptions
|
|
|
|
|
----------
|
|
|
|
|
|
|
|
|
|
.. module:: sphinx.errors
|
|
|
|
|
|
2017-12-03 20:07:06 +00:00
|
|
|
.. autoexception:: SphinxError
|
2014-01-21 09:54:31 +01:00
|
|
|
|
2017-12-03 20:07:06 +00:00
|
|
|
.. autoexception:: ConfigError
|
2014-01-21 09:54:31 +01:00
|
|
|
|
2017-12-03 20:07:06 +00:00
|
|
|
.. autoexception:: ExtensionError
|
2014-01-21 09:54:31 +01:00
|
|
|
|
2017-12-03 20:07:06 +00:00
|
|
|
.. autoexception:: ThemeError
|
2014-01-21 09:54:31 +01:00
|
|
|
|
2017-12-03 20:07:06 +00:00
|
|
|
.. autoexception:: VersionRequirementError
|