sphinx/doc/extdev/appapi.rst

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

195 lines
3.5 KiB
ReStructuredText
Raw Normal View History

.. highlight:: rst
2008-03-18 13:19:21 -05:00
Application API
===============
.. module:: sphinx.application
:synopsis: Application class and extensibility interface.
2008-03-12 16:37:22 -05: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.
.. 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 16:37:22 -05:00
.. currentmodule:: sphinx.application
.. automethod:: Sphinx.setup_extension
.. automethod:: Sphinx.require_sphinx
.. automethod:: Sphinx.connect
.. automethod:: Sphinx.disconnect
.. automethod:: Sphinx.add_builder
.. automethod:: Sphinx.add_config_value
.. automethod:: Sphinx.add_event
.. automethod:: Sphinx.set_translator
.. automethod:: Sphinx.add_node
.. automethod:: Sphinx.add_enumerable_node
.. automethod:: Sphinx.add_directive
.. automethod:: Sphinx.add_role
.. automethod:: Sphinx.add_generic_role
.. automethod:: Sphinx.add_domain
.. automethod:: Sphinx.add_directive_to_domain
2008-03-18 13:19:21 -05:00
.. automethod:: Sphinx.add_role_to_domain
2008-03-18 13:19:21 -05:00
.. automethod:: Sphinx.add_index_to_domain
2008-03-18 13:19:21 -05:00
.. automethod:: Sphinx.add_object_type
2008-03-28 13:45:32 -05:00
.. automethod:: Sphinx.add_crossref_type
2008-03-28 13:45:32 -05:00
.. automethod:: Sphinx.add_transform
2008-03-28 13:45:32 -05:00
.. automethod:: Sphinx.add_post_transform
2008-03-12 16:37:22 -05:00
.. automethod:: Sphinx.add_js_file
2008-03-28 13:45:32 -05:00
.. automethod:: Sphinx.add_css_file
.. automethod:: Sphinx.add_latex_package
.. automethod:: Sphinx.add_lexer
2008-03-28 13:45:32 -05:00
.. automethod:: Sphinx.add_autodocumenter
2008-03-28 13:45:32 -05:00
.. automethod:: Sphinx.add_autodoc_attrgetter
2008-03-28 13:45:32 -05:00
.. automethod:: Sphinx.add_search_language
2008-03-28 13:45:32 -05:00
.. automethod:: Sphinx.add_source_suffix
.. automethod:: Sphinx.add_source_parser
2008-03-28 13:45:32 -05:00
.. automethod:: Sphinx.add_env_collector
2008-03-28 13:45:32 -05:00
.. automethod:: Sphinx.add_html_theme
.. automethod:: Sphinx.add_html_math_renderer
2018-05-16 10:57:09 -05:00
.. automethod:: Sphinx.add_message_catalog
2018-02-25 06:41:39 -06:00
.. automethod:: Sphinx.is_parallel_allowed
.. exception:: ExtensionError
All these methods raise this exception if something went wrong with the
extension API.
Emitting events
---------------
.. class:: Sphinx
:no-index:
.. automethod:: emit
.. automethod:: emit_firstresult
2008-03-12 16:37:22 -05:00
2017-07-15 11:48:09 -05:00
Sphinx runtime information
--------------------------
The application object also provides runtime information as attributes.
.. attribute:: Sphinx.project
Target project. See :class:`.Project`.
2018-06-05 08:57:04 -05:00
.. attribute:: Sphinx.srcdir
2017-07-15 11:48:09 -05:00
Source directory.
2018-06-05 08:57:04 -05:00
.. attribute:: Sphinx.confdir
2017-07-15 11:48:09 -05:00
Directory containing ``conf.py``.
2018-06-05 08:57:04 -05:00
.. attribute:: Sphinx.doctreedir
2017-07-15 11:48:09 -05:00
Directory for storing pickled doctrees.
2018-06-05 08:57:04 -05:00
.. attribute:: Sphinx.outdir
2017-07-15 11:48:09 -05:00
Directory for storing built document.
.. autoattribute:: Sphinx.fresh_env_used
2008-03-12 16:37:22 -05:00
Sphinx core events
------------------
.. note:: Moved to :ref:`events`.
Checking the Sphinx version
---------------------------
.. currentmodule:: sphinx
Use this to adapt your extension to API changes in Sphinx.
.. autodata:: version_info
The Config object
-----------------
.. currentmodule:: sphinx.config
2013-10-12 14:01:25 -05:00
.. autoclass:: Config
.. py:class:: ENUM
:no-typesetting:
.. _template-bridge:
The template bridge
-------------------
.. currentmodule:: sphinx.application
.. autoclass:: TemplateBridge
:members:
2014-01-21 02:54:31 -06:00
.. _exceptions:
Exceptions
----------
.. module:: sphinx.errors
.. autoexception:: SphinxError
2014-01-21 02:54:31 -06:00
.. autoexception:: ConfigError
2014-01-21 02:54:31 -06:00
.. autoexception:: ExtensionError
2014-01-21 02:54:31 -06:00
.. autoexception:: ThemeError
2014-01-21 02:54:31 -06:00
.. autoexception:: VersionRequirementError