2008-03-09 21:32:24 +00:00
|
|
|
.. _extensions:
|
|
|
|
|
|
|
|
|
|
Sphinx Extensions
|
|
|
|
|
=================
|
|
|
|
|
|
|
|
|
|
.. module:: sphinx.application
|
|
|
|
|
:synopsis: Application class and extensibility interface.
|
|
|
|
|
|
|
|
|
|
Since many projects will need special features in their documentation, Sphinx is
|
|
|
|
|
designed to be extensible on several levels.
|
|
|
|
|
|
2008-12-21 00:10:47 +01:00
|
|
|
This is what you can do in an extension: First, you can add new
|
|
|
|
|
:term:`builder`\s to support new output formats or actions on the parsed
|
|
|
|
|
documents. Then, it is possible to register custom reStructuredText roles and
|
|
|
|
|
directives, extending the markup. And finally, there are so-called "hook
|
|
|
|
|
points" at strategic places throughout the build process, where an extension can
|
|
|
|
|
register a hook and run specialized code.
|
|
|
|
|
|
|
|
|
|
An extension is simply a Python module. When an extension is loaded, Sphinx
|
|
|
|
|
imports this module and executes its ``setup()`` function, which in turn
|
|
|
|
|
notifies Sphinx of everything the extension offers -- see the extension tutorial
|
|
|
|
|
for examples.
|
|
|
|
|
|
|
|
|
|
The configuration file itself can be treated as an extension if it contains a
|
|
|
|
|
``setup()`` function. All other extensions to load must be listed in the
|
|
|
|
|
:confval:`extensions` configuration value.
|
2008-04-06 17:38:55 +00:00
|
|
|
|
2008-03-12 21:37:22 +00:00
|
|
|
.. toctree::
|
2008-03-09 21:32:24 +00:00
|
|
|
|
2008-12-21 00:10:47 +01:00
|
|
|
ext/tutorial
|
2008-03-16 11:19:26 +00:00
|
|
|
ext/appapi
|
|
|
|
|
ext/builderapi
|
2008-03-09 21:32:24 +00:00
|
|
|
|
|
|
|
|
|
2008-03-12 21:37:22 +00:00
|
|
|
Builtin Sphinx extensions
|
|
|
|
|
-------------------------
|
2008-03-09 21:32:24 +00:00
|
|
|
|
2008-03-12 21:37:22 +00:00
|
|
|
These extensions are built in and can be activated by respective entries in the
|
|
|
|
|
:confval:`extensions` configuration value:
|
2008-03-09 21:32:24 +00:00
|
|
|
|
2008-03-12 21:37:22 +00:00
|
|
|
.. toctree::
|
2008-03-09 21:32:24 +00:00
|
|
|
|
2008-03-16 11:19:26 +00:00
|
|
|
ext/autodoc
|
2009-03-16 01:30:09 +01:00
|
|
|
ext/autosummary
|
2008-03-16 11:19:26 +00:00
|
|
|
ext/doctest
|
2008-08-04 17:31:25 +00:00
|
|
|
ext/intersphinx
|
2008-08-06 13:04:14 +00:00
|
|
|
ext/math
|
2009-03-04 23:52:56 +01:00
|
|
|
ext/graphviz
|
|
|
|
|
ext/inheritance
|
2008-03-16 11:19:26 +00:00
|
|
|
ext/refcounting
|
|
|
|
|
ext/ifconfig
|
|
|
|
|
ext/coverage
|
2008-11-09 19:46:32 +01:00
|
|
|
ext/todo
|
2009-05-02 20:38:45 +02:00
|
|
|
ext/extlinks
|
2010-01-13 23:53:01 +01:00
|
|
|
ext/viewcode
|
2010-05-24 15:12:27 +02:00
|
|
|
ext/oldcmarkup
|
2008-11-16 13:32:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Third-party extensions
|
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
|
|
There are several extensions that are not (yet) maintained in the Sphinx
|
|
|
|
|
distribution. The `Wiki at BitBucket`_ maintains a list of those.
|
|
|
|
|
|
2008-12-21 00:10:47 +01:00
|
|
|
If you write an extension that you think others will find useful, please write
|
2010-01-02 00:09:01 +01:00
|
|
|
to the project mailing list (`join here <http://groups.google.com/group/sphinx-dev>`_)
|
|
|
|
|
and we'll find the proper way of including or hosting it for the public.
|
2008-12-21 00:10:47 +01:00
|
|
|
|
2008-11-16 13:32:04 +01:00
|
|
|
.. _Wiki at BitBucket: http://www.bitbucket.org/birkenfeld/sphinx/wiki/Home
|
2008-12-21 00:10:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Where to put your own extensions?
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
Extensions local to a project should be put within the project's directory
|
|
|
|
|
structure. Set Python's module search path, ``sys.path``, accordingly so that
|
|
|
|
|
Sphinx can find them.
|
|
|
|
|
E.g., if your extension ``foo.py`` lies in the ``exts`` subdirectory of the
|
|
|
|
|
project root, put into :file:`conf.py`::
|
|
|
|
|
|
|
|
|
|
import sys, os
|
|
|
|
|
|
|
|
|
|
sys.path.append(os.path.abspath('exts'))
|
|
|
|
|
|
|
|
|
|
extensions = ['foo']
|
|
|
|
|
|
|
|
|
|
You can also install extensions anywhere else on ``sys.path``, e.g. in the
|
|
|
|
|
``site-packages`` directory.
|