Debian Codegraph @

doc/development/howtos/setup_extension.rst

raw
1 Depend on another extension
2 ===========================
3
4 Sometimes your extension depends on the functionality of another
5 Sphinx extension. Most Sphinx extensions are activated in a
6 project's :file:`conf.py` file, but this is not available to you as an
7 extension developer.
8
9 .. module:: sphinx.application
10 :no-index:
11
12 To ensure that another extension is activated as a part of your own extension,
13 use the :meth:`sphinx.application.Sphinx.setup_extension` method. This will
14 activate another extension at run-time, ensuring that you have access to its
15 functionality.
16
17 For example, the following code activates the :mod:`sphinx.ext.autodoc` extension:
18
19 .. code-block:: python
20
21 def setup(app):
22 app.setup_extension('sphinx.ext.autodoc')
23
24 .. note::
25
26 Since your extension will depend on another, make sure to include
27 it as a part of your extension's installation requirements.