blob: 682db4ef3e429af0d702e11df4d2f2f1705193b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
.. highlight:: rst
Application API
===============
.. module:: sphinx.application
:synopsis: Application class and extensibility interface.
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.
.. 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
.. automethod:: Sphinx.add_role_to_domain
.. automethod:: Sphinx.add_index_to_domain
.. automethod:: Sphinx.add_object_type
.. automethod:: Sphinx.add_crossref_type
.. automethod:: Sphinx.add_transform
.. automethod:: Sphinx.add_post_transform
.. automethod:: Sphinx.add_js_file
.. automethod:: Sphinx.add_css_file
.. automethod:: Sphinx.add_latex_package
.. automethod:: Sphinx.add_lexer
.. automethod:: Sphinx.add_autodocumenter
.. automethod:: Sphinx.add_autodoc_attrgetter
.. automethod:: Sphinx.add_search_language
.. automethod:: Sphinx.add_source_suffix
.. automethod:: Sphinx.add_source_parser
.. automethod:: Sphinx.add_env_collector
.. automethod:: Sphinx.add_html_theme
.. automethod:: Sphinx.add_html_math_renderer
.. automethod:: Sphinx.add_message_catalog
.. 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
Sphinx runtime information
--------------------------
The application object also provides runtime information as attributes.
.. attribute:: Sphinx.project
Target project. See :class:`.Project`.
.. attribute:: Sphinx.srcdir
Source directory.
.. attribute:: Sphinx.confdir
Directory containing ``conf.py``.
.. attribute:: Sphinx.doctreedir
Directory for storing pickled doctrees.
.. attribute:: Sphinx.outdir
Directory for storing built document.
.. autoattribute:: Sphinx.fresh_env_used
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
.. autoclass:: Config
.. py:class:: ENUM
:no-typesetting:
.. _template-bridge:
The template bridge
-------------------
.. currentmodule:: sphinx.application
.. autoclass:: TemplateBridge
:members:
.. _exceptions:
Exceptions
----------
.. module:: sphinx.errors
.. autoexception:: SphinxError
.. autoexception:: ConfigError
.. autoexception:: ExtensionError
.. autoexception:: ThemeError
.. autoexception:: VersionRequirementError
|