2009-02-15 03:45:46 -06:00
|
|
|
.. highlightlang:: python
|
|
|
|
|
|
|
|
HTML theming support
|
|
|
|
====================
|
|
|
|
|
|
|
|
.. versionadded:: 0.6
|
|
|
|
|
|
|
|
Sphinx supports changing the appearance of its HTML output via *themes*. A
|
|
|
|
theme is a collection of HTML templates, stylesheet(s) and other static files.
|
|
|
|
Additionally, it has a configuration file which specifies from which theme to
|
|
|
|
inherit, which highlighting style to use, and what options exist for customizing
|
|
|
|
the theme's look and feel.
|
|
|
|
|
|
|
|
Themes are meant to be project-unaware, so they can be used for different
|
|
|
|
projects without change.
|
|
|
|
|
|
|
|
|
|
|
|
Using a theme
|
|
|
|
-------------
|
|
|
|
|
|
|
|
Using an existing theme is easy. If the theme is builtin to Sphinx, you only
|
|
|
|
need to set the :confval:`html_theme` config value. With the
|
|
|
|
:confval:`html_theme_options` config value you can set theme-specific options
|
|
|
|
that change the look and feel. For example, you could have the following in
|
|
|
|
your :file:`conf.py`::
|
|
|
|
|
2015-02-23 07:51:30 -06:00
|
|
|
html_theme = "classic"
|
2009-02-15 03:45:46 -06:00
|
|
|
html_theme_options = {
|
|
|
|
"rightsidebar": "true",
|
2009-05-17 05:20:04 -05:00
|
|
|
"relbarbgcolor": "black"
|
2009-02-15 03:45:46 -06:00
|
|
|
}
|
|
|
|
|
2015-02-23 07:51:30 -06:00
|
|
|
That would give you the classic theme, but with a sidebar on the right side and
|
2009-02-15 03:45:46 -06:00
|
|
|
a black background for the relation bar (the bar with the navigation links at
|
|
|
|
the page's top and bottom).
|
|
|
|
|
2013-09-16 09:57:58 -05:00
|
|
|
If the theme does not come with Sphinx, it can be in two static forms: either a
|
2009-02-15 03:45:46 -06:00
|
|
|
directory (containing :file:`theme.conf` and other needed files), or a zip file
|
|
|
|
with the same contents. Either of them must be put where Sphinx can find it;
|
|
|
|
for this there is the config value :confval:`html_theme_path`. It gives a list
|
|
|
|
of directories, relative to the directory containing :file:`conf.py`, that can
|
|
|
|
contain theme directories or zip files. For example, if you have a theme in the
|
|
|
|
file :file:`blue.zip`, you can put it right in the directory containing
|
|
|
|
:file:`conf.py` and use this configuration::
|
|
|
|
|
|
|
|
html_theme = "blue"
|
|
|
|
html_theme_path = ["."]
|
|
|
|
|
2017-04-20 07:21:04 -05:00
|
|
|
The third form is a python package. If a theme you want to use is distributed
|
2017-04-27 07:24:12 -05:00
|
|
|
as a python package, you can use it after installing
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2013-09-16 09:57:58 -05:00
|
|
|
|
2017-04-20 07:21:04 -05:00
|
|
|
# installing theme package
|
|
|
|
$ pip install sphinxjp.themes.dotted
|
2013-09-16 09:57:58 -05:00
|
|
|
|
2017-04-20 07:21:04 -05:00
|
|
|
# use it in your conf.py
|
|
|
|
html_theme = "dotted"
|
2009-02-15 03:45:46 -06:00
|
|
|
|
2013-09-17 00:51:30 -05:00
|
|
|
|
2009-02-15 03:45:46 -06:00
|
|
|
.. _builtin-themes:
|
|
|
|
|
|
|
|
Builtin themes
|
|
|
|
--------------
|
|
|
|
|
2016-06-06 07:42:58 -05:00
|
|
|
.. cssclass:: longtable
|
|
|
|
|
2010-01-17 16:24:40 -06:00
|
|
|
+--------------------+--------------------+
|
|
|
|
| **Theme overview** | |
|
2009-11-16 07:48:52 -06:00
|
|
|
+--------------------+--------------------+
|
2016-08-23 04:42:12 -05:00
|
|
|
| |alabaster| | |classic| |
|
2009-11-16 07:48:52 -06:00
|
|
|
| | |
|
2016-08-23 04:42:12 -05:00
|
|
|
| *alabaster* | *classic* |
|
2015-02-23 07:51:30 -06:00
|
|
|
+--------------------+--------------------+
|
2016-08-23 04:42:12 -05:00
|
|
|
| |sphinxdoc| | |scrolls| |
|
2015-02-23 07:51:30 -06:00
|
|
|
| | |
|
2016-08-23 04:42:12 -05:00
|
|
|
| *sphinxdoc* | *scrolls* |
|
2009-11-16 07:48:52 -06:00
|
|
|
+--------------------+--------------------+
|
2016-08-23 04:42:12 -05:00
|
|
|
| |agogo| | |traditional| |
|
2009-11-16 07:48:52 -06:00
|
|
|
| | |
|
2016-08-23 04:42:12 -05:00
|
|
|
| *agogo* | *traditional* |
|
2009-11-16 07:48:52 -06:00
|
|
|
+--------------------+--------------------+
|
2016-08-23 04:42:12 -05:00
|
|
|
| |nature| | |haiku| |
|
2009-11-16 07:48:52 -06:00
|
|
|
| | |
|
2016-08-23 04:42:12 -05:00
|
|
|
| *nature* | *haiku* |
|
2009-11-16 07:48:52 -06:00
|
|
|
+--------------------+--------------------+
|
2016-08-23 04:42:12 -05:00
|
|
|
| |pyramid| | |bizstyle| |
|
2010-01-07 07:16:53 -06:00
|
|
|
| | |
|
2016-08-23 04:42:12 -05:00
|
|
|
| *pyramid* | *bizstyle* |
|
2014-08-14 23:38:02 -05:00
|
|
|
+--------------------+--------------------+
|
2009-11-16 07:48:52 -06:00
|
|
|
|
2015-02-23 07:51:30 -06:00
|
|
|
.. |alabaster| image:: themes/alabaster.png
|
|
|
|
.. |classic| image:: themes/classic.png
|
|
|
|
.. |sphinxdoc| image:: themes/sphinxdoc.png
|
|
|
|
.. |scrolls| image:: themes/scrolls.png
|
|
|
|
.. |agogo| image:: themes/agogo.png
|
|
|
|
.. |traditional| image:: themes/traditional.png
|
|
|
|
.. |nature| image:: themes/nature.png
|
|
|
|
.. |haiku| image:: themes/haiku.png
|
|
|
|
.. |pyramid| image:: themes/pyramid.png
|
|
|
|
.. |bizstyle| image:: themes/bizstyle.png
|
2009-11-16 07:48:52 -06:00
|
|
|
|
|
|
|
Sphinx comes with a selection of themes to choose from.
|
|
|
|
|
2015-02-23 07:51:30 -06:00
|
|
|
.. cssclass:: clear
|
|
|
|
|
2009-11-16 07:48:52 -06:00
|
|
|
These themes are:
|
2009-02-15 03:45:46 -06:00
|
|
|
|
|
|
|
* **basic** -- This is a basically unstyled layout used as the base for the
|
2010-01-07 07:27:37 -06:00
|
|
|
other themes, and usable as the base for custom themes as well. The HTML
|
2011-01-15 04:33:45 -06:00
|
|
|
contains all important elements like sidebar and relation bar. There are
|
|
|
|
these options (which are inherited by the other themes):
|
2009-02-15 03:45:46 -06:00
|
|
|
|
|
|
|
- **nosidebar** (true or false): Don't include the sidebar. Defaults to
|
2014-06-18 11:34:28 -05:00
|
|
|
``False``.
|
2009-02-15 03:45:46 -06:00
|
|
|
|
2018-01-04 13:13:29 -06:00
|
|
|
- **sidebarwidth** (int or str): Width of the sidebar in pixels.
|
|
|
|
This can be an int, which is interpreted as pixels or a valid CSS
|
|
|
|
dimension string such as '70em' or '50%'. Defaults to 230 pixels.
|
|
|
|
|
|
|
|
- **body_min_width** (int or str): Minimal width of the document body.
|
|
|
|
This can be an int, which is interpreted as pixels or a valid CSS
|
|
|
|
dimension string such as '70em' or '50%'. Use 0 if you don't want
|
|
|
|
a width limit. Defaults may depend on the theme (often 450px).
|
|
|
|
|
|
|
|
- **body_max_width** (int or str): Maximal width of the document body.
|
|
|
|
This can be an int, which is interpreted as pixels or a valid CSS
|
|
|
|
dimension string such as '70em' or '50%'. Use 'none' if you don't
|
|
|
|
want a width limit. Defaults may depend on the theme (often 800px).
|
2011-01-15 04:33:45 -06:00
|
|
|
|
2015-02-23 07:51:30 -06:00
|
|
|
* **alabaster** -- `Alabaster theme`_ is a modified "Kr" Sphinx theme from @kennethreitz
|
|
|
|
(especially as used in his Requests project), which was itself originally based on
|
2017-05-30 06:06:32 -05:00
|
|
|
@mitsuhiko's theme used for Flask & related projects.
|
|
|
|
Check out at its `installation page`_ how to set up properly
|
|
|
|
:confval:`html_sidebars` for its use.
|
2015-02-23 07:51:30 -06:00
|
|
|
|
2018-04-18 21:51:48 -05:00
|
|
|
.. _Alabaster theme: https://pypi.org/project/alabaster/
|
2018-01-20 16:04:57 -06:00
|
|
|
.. _installation page: https://alabaster.readthedocs.io/en/latest/installation.html
|
2015-02-23 07:51:30 -06:00
|
|
|
|
2016-02-13 09:00:42 -06:00
|
|
|
* **classic** -- This is the classic theme, which looks like `the Python 2
|
|
|
|
documentation <https://docs.python.org/2/>`_. It can be customized via
|
|
|
|
these options:
|
2009-02-15 03:45:46 -06:00
|
|
|
|
|
|
|
- **rightsidebar** (true or false): Put the sidebar on the right side.
|
2014-06-18 11:34:28 -05:00
|
|
|
Defaults to ``False``.
|
2009-02-15 03:45:46 -06:00
|
|
|
|
|
|
|
- **stickysidebar** (true or false): Make the sidebar "fixed" so that it
|
|
|
|
doesn't scroll out of view for long body content. This may not work well
|
2014-06-18 11:34:28 -05:00
|
|
|
with all browsers. Defaults to ``False``.
|
2009-02-15 03:45:46 -06:00
|
|
|
|
2010-05-24 16:14:35 -05:00
|
|
|
- **collapsiblesidebar** (true or false): Add an *experimental* JavaScript
|
|
|
|
snippet that makes the sidebar collapsible via a button on its side.
|
2014-06-18 11:34:28 -05:00
|
|
|
*Doesn't work with "stickysidebar".* Defaults to ``False``.
|
2010-05-24 16:14:35 -05:00
|
|
|
|
2010-05-24 05:57:07 -05:00
|
|
|
- **externalrefs** (true or false): Display external links differently from
|
2014-06-18 11:34:28 -05:00
|
|
|
internal links. Defaults to ``False``.
|
2010-05-24 05:57:07 -05:00
|
|
|
|
2009-02-15 03:45:46 -06:00
|
|
|
There are also various color and font options that can change the color scheme
|
|
|
|
without having to write a custom stylesheet:
|
|
|
|
|
|
|
|
- **footerbgcolor** (CSS color): Background color for the footer line.
|
|
|
|
- **footertextcolor** (CSS color): Text color for the footer line.
|
|
|
|
- **sidebarbgcolor** (CSS color): Background color for the sidebar.
|
2010-08-23 11:11:26 -05:00
|
|
|
- **sidebarbtncolor** (CSS color): Background color for the sidebar collapse
|
2014-06-18 11:34:28 -05:00
|
|
|
button (used when *collapsiblesidebar* is ``True``).
|
2009-02-15 03:45:46 -06:00
|
|
|
- **sidebartextcolor** (CSS color): Text color for the sidebar.
|
|
|
|
- **sidebarlinkcolor** (CSS color): Link color for the sidebar.
|
|
|
|
- **relbarbgcolor** (CSS color): Background color for the relation bar.
|
|
|
|
- **relbartextcolor** (CSS color): Text color for the relation bar.
|
|
|
|
- **relbarlinkcolor** (CSS color): Link color for the relation bar.
|
|
|
|
- **bgcolor** (CSS color): Body background color.
|
|
|
|
- **textcolor** (CSS color): Body text color.
|
|
|
|
- **linkcolor** (CSS color): Body link color.
|
2009-06-05 03:41:02 -05:00
|
|
|
- **visitedlinkcolor** (CSS color): Body color for visited links.
|
2009-02-27 05:11:35 -06:00
|
|
|
- **headbgcolor** (CSS color): Background color for headings.
|
|
|
|
- **headtextcolor** (CSS color): Text color for headings.
|
|
|
|
- **headlinkcolor** (CSS color): Link color for headings.
|
2009-02-15 03:45:46 -06:00
|
|
|
- **codebgcolor** (CSS color): Background color for code blocks.
|
|
|
|
- **codetextcolor** (CSS color): Default text color for code blocks, if not
|
|
|
|
set differently by the highlighting style.
|
|
|
|
|
|
|
|
- **bodyfont** (CSS font-family): Font for normal text.
|
|
|
|
- **headfont** (CSS font-family): Font for headings.
|
|
|
|
|
2017-08-06 14:46:27 -05:00
|
|
|
* **sphinxdoc** -- The theme originally used by this documentation. It features
|
|
|
|
a sidebar on the right side. There are currently no options beyond
|
|
|
|
*nosidebar* and *sidebarwidth*.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
The Sphinx documentation now uses
|
|
|
|
`an adjusted version of the sphinxdoc theme
|
|
|
|
<https://github.com/sphinx-doc/sphinx/tree/master/doc/_themes/sphinx13>`_.
|
2009-02-15 03:45:46 -06:00
|
|
|
|
2009-09-08 14:49:27 -05:00
|
|
|
* **scrolls** -- A more lightweight theme, based on `the Jinja documentation
|
2011-01-04 04:37:56 -06:00
|
|
|
<http://jinja.pocoo.org/>`_. The following color options are available:
|
2009-09-08 14:49:27 -05:00
|
|
|
|
|
|
|
- **headerbordercolor**
|
|
|
|
- **subheadlinecolor**
|
|
|
|
- **linkcolor**
|
|
|
|
- **visitedlinkcolor**
|
|
|
|
- **admonitioncolor**
|
|
|
|
|
2009-11-16 07:48:52 -06:00
|
|
|
* **agogo** -- A theme created by Andi Albrecht. The following options are
|
|
|
|
supported:
|
|
|
|
|
|
|
|
- **bodyfont** (CSS font family): Font for normal text.
|
|
|
|
- **headerfont** (CSS font family): Font for headings.
|
|
|
|
- **pagewidth** (CSS length): Width of the page content, default 70em.
|
|
|
|
- **documentwidth** (CSS length): Width of the document (without sidebar),
|
|
|
|
default 50em.
|
|
|
|
- **sidebarwidth** (CSS length): Width of the sidebar, default 20em.
|
|
|
|
- **bgcolor** (CSS color): Background color.
|
|
|
|
- **headerbg** (CSS value for "background"): background for the header area,
|
|
|
|
default a grayish gradient.
|
|
|
|
- **footerbg** (CSS value for "background"): background for the footer area,
|
|
|
|
default a light gray gradient.
|
|
|
|
- **linkcolor** (CSS color): Body link color.
|
|
|
|
- **headercolor1**, **headercolor2** (CSS color): colors for <h1> and <h2>
|
|
|
|
headings.
|
|
|
|
- **headerlinkcolor** (CSS color): Color for the backreference link in
|
|
|
|
headings.
|
2010-02-28 02:36:27 -06:00
|
|
|
- **textalign** (CSS *text-align* value): Text alignment for the body, default
|
|
|
|
is ``justify``.
|
2009-11-16 07:48:52 -06:00
|
|
|
|
2010-01-03 12:40:07 -06:00
|
|
|
* **nature** -- A greenish theme. There are currently no options beyond
|
2011-01-15 04:33:45 -06:00
|
|
|
*nosidebar* and *sidebarwidth*.
|
2010-01-03 12:40:07 -06:00
|
|
|
|
2011-01-04 10:49:59 -06:00
|
|
|
* **pyramid** -- A theme from the Pyramid web framework project, designed by
|
2011-01-15 19:31:40 -06:00
|
|
|
Blaise Laflamme. There are currently no options beyond *nosidebar* and
|
2011-01-15 04:33:45 -06:00
|
|
|
*sidebarwidth*.
|
2011-01-04 10:49:59 -06:00
|
|
|
|
2010-01-07 07:16:53 -06:00
|
|
|
* **haiku** -- A theme without sidebar inspired by the `Haiku OS user guide
|
2016-02-13 09:00:42 -06:00
|
|
|
<https://www.haiku-os.org/docs/userguide/en/contents.html>`_. The following
|
2010-01-07 07:16:53 -06:00
|
|
|
options are supported:
|
|
|
|
|
2014-06-18 11:34:28 -05:00
|
|
|
- **full_logo** (true or false, default ``False``): If this is true, the
|
|
|
|
header will only show the :confval:`html_logo`. Use this for large logos.
|
|
|
|
If this is false, the logo (if present) will be shown floating right, and
|
|
|
|
the documentation title will be put in the header.
|
2010-01-07 07:16:53 -06:00
|
|
|
- **textcolor**, **headingcolor**, **linkcolor**, **visitedlinkcolor**,
|
|
|
|
**hoverlinkcolor** (CSS colors): Colors for various body elements.
|
|
|
|
|
2009-11-16 07:50:51 -06:00
|
|
|
* **traditional** -- A theme resembling the old Python documentation. There are
|
2011-01-15 04:33:45 -06:00
|
|
|
currently no options beyond *nosidebar* and *sidebarwidth*.
|
2009-11-16 07:50:51 -06:00
|
|
|
|
2011-05-23 14:09:51 -05:00
|
|
|
* **epub** -- A theme for the epub builder. This theme tries to save visual
|
|
|
|
space which is a sparse resource on ebook readers. The following options
|
|
|
|
are supported:
|
|
|
|
|
2014-06-18 11:34:28 -05:00
|
|
|
- **relbar1** (true or false, default ``True``): If this is true, the
|
2011-05-23 14:09:51 -05:00
|
|
|
`relbar1` block is inserted in the epub output, otherwise it is omitted.
|
2014-06-18 11:34:28 -05:00
|
|
|
- **footer** (true or false, default ``True``): If this is true, the
|
2014-06-18 10:19:01 -05:00
|
|
|
`footer` block is inserted in the epub output, otherwise it is omitted.
|
2009-02-15 04:03:16 -06:00
|
|
|
|
2014-08-14 23:38:02 -05:00
|
|
|
- **bizstyle** -- A simple bluish theme. The following options are supported
|
|
|
|
beyond *nosidebar* and *sidebarwidth*:
|
|
|
|
|
|
|
|
- **rightsidebar** (true or false): Put the sidebar on the right side.
|
|
|
|
Defaults to ``False``.
|
|
|
|
|
2014-08-15 02:49:11 -05:00
|
|
|
.. versionadded:: 1.3
|
2015-02-23 07:51:30 -06:00
|
|
|
'alabaster', 'sphinx_rtd_theme' and 'bizstyle' theme.
|
2014-08-15 02:49:11 -05:00
|
|
|
|
2015-02-23 07:51:30 -06:00
|
|
|
.. versionchanged:: 1.3
|
|
|
|
The 'default' theme has been renamed to 'classic'. 'default' is still
|
2016-04-02 12:39:32 -05:00
|
|
|
available, however it will emit a notice that it is an alias for the new
|
2015-02-23 07:51:30 -06:00
|
|
|
'alabaster' theme.
|
2014-08-14 23:38:02 -05:00
|
|
|
|
2009-02-15 04:03:16 -06:00
|
|
|
Creating themes
|
|
|
|
---------------
|
|
|
|
|
|
|
|
As said, themes are either a directory or a zipfile (whose name is the theme
|
|
|
|
name), containing the following:
|
|
|
|
|
|
|
|
* A :file:`theme.conf` file, see below.
|
|
|
|
* HTML templates, if needed.
|
|
|
|
* A ``static/`` directory containing any static files that will be copied to the
|
2010-11-24 10:12:05 -06:00
|
|
|
output static directory on build. These can be images, styles, script files.
|
2009-02-15 04:03:16 -06:00
|
|
|
|
|
|
|
The :file:`theme.conf` file is in INI format [1]_ (readable by the standard
|
2009-02-17 05:20:09 -06:00
|
|
|
Python :mod:`ConfigParser` module) and has the following structure:
|
|
|
|
|
|
|
|
.. sourcecode:: ini
|
2009-02-15 04:03:16 -06:00
|
|
|
|
|
|
|
[theme]
|
|
|
|
inherit = base theme
|
|
|
|
stylesheet = main CSS name
|
|
|
|
pygments_style = stylename
|
2017-10-22 01:12:31 -05:00
|
|
|
sidebars = localtoc.html, relations.html, sourcelink.html, searchbox.html
|
2009-02-15 04:03:16 -06:00
|
|
|
|
|
|
|
[options]
|
|
|
|
variable = default value
|
|
|
|
|
|
|
|
* The **inherit** setting gives the name of a "base theme", or ``none``. The
|
2009-02-15 04:38:23 -06:00
|
|
|
base theme will be used to locate missing templates (most themes will not have
|
|
|
|
to supply most templates if they use ``basic`` as the base theme), its options
|
|
|
|
will be inherited, and all of its static files will be used as well.
|
2009-02-15 04:03:16 -06:00
|
|
|
|
|
|
|
* The **stylesheet** setting gives the name of a CSS file which will be
|
|
|
|
referenced in the HTML header. If you need more than one CSS file, either
|
|
|
|
include one from the other via CSS' ``@import``, or use a custom HTML template
|
|
|
|
that adds ``<link rel="stylesheet">`` tags as necessary. Setting the
|
|
|
|
:confval:`html_style` config value will override this setting.
|
|
|
|
|
|
|
|
* The **pygments_style** setting gives the name of a Pygments style to use for
|
|
|
|
highlighting. This can be overridden by the user in the
|
|
|
|
:confval:`pygments_style` config value.
|
|
|
|
|
2017-10-22 01:12:31 -05:00
|
|
|
* The **sidebars** setting gives the comma separated list of sidebar templates
|
|
|
|
for constructing sidebars. This can be overridden by the user in the
|
|
|
|
:confval:`html_sidebars` config value.
|
|
|
|
|
2009-02-15 04:03:16 -06:00
|
|
|
* The **options** section contains pairs of variable names and default values.
|
|
|
|
These options can be overridden by the user in :confval:`html_theme_options`
|
|
|
|
and are accessible from all templates as ``theme_<name>``.
|
|
|
|
|
2017-10-22 01:12:31 -05:00
|
|
|
.. versionadded:: 1.7
|
|
|
|
sidebar settings
|
2009-02-15 04:03:16 -06:00
|
|
|
|
2017-04-20 07:21:04 -05:00
|
|
|
.. _distribute-your-theme:
|
|
|
|
|
|
|
|
Distribute your theme as a python package
|
|
|
|
-----------------------------------------
|
|
|
|
|
|
|
|
As a way to distribute your theme, you can use python package. Python package
|
|
|
|
brings to users easy setting up ways.
|
|
|
|
|
|
|
|
To distribute your theme as a python package, please define an entry point
|
|
|
|
called ``sphinx.html_themes`` in your setup.py file, and write a ``setup()``
|
2017-04-23 02:03:46 -05:00
|
|
|
function to register your themes using ``add_html_theme()`` API in it::
|
2017-04-20 07:21:04 -05:00
|
|
|
|
|
|
|
# 'setup.py'
|
|
|
|
setup(
|
|
|
|
...
|
|
|
|
entry_points = {
|
|
|
|
'sphinx.html_themes': [
|
|
|
|
'name_of_theme = your_package',
|
|
|
|
]
|
|
|
|
},
|
|
|
|
...
|
|
|
|
)
|
|
|
|
|
|
|
|
# 'your_package.py'
|
|
|
|
from os import path
|
|
|
|
|
|
|
|
def setup(app):
|
|
|
|
app.add_html_theme('name_of_theme', path.abspath(path.dirname(__file__)))
|
|
|
|
|
2017-04-23 02:03:46 -05:00
|
|
|
|
|
|
|
If your theme package contains two or more themes, please call ``add_html_theme()``
|
|
|
|
twice or more.
|
|
|
|
|
2017-04-20 07:21:04 -05:00
|
|
|
.. versionadded:: 1.2
|
|
|
|
'sphinx_themes' entry_points feature.
|
|
|
|
|
|
|
|
.. deprecated:: 1.6
|
|
|
|
``sphinx_themes`` entry_points has been deprecated.
|
|
|
|
|
|
|
|
.. versionadded:: 1.6
|
|
|
|
``sphinx.html_themes`` entry_points feature.
|
|
|
|
|
2009-02-15 04:38:23 -06:00
|
|
|
Templating
|
|
|
|
~~~~~~~~~~
|
|
|
|
|
|
|
|
The :doc:`guide to templating <templating>` is helpful if you want to write your
|
|
|
|
own templates. What is important to keep in mind is the order in which Sphinx
|
|
|
|
searches for templates:
|
|
|
|
|
|
|
|
* First, in the user's ``templates_path`` directories.
|
|
|
|
* Then, in the selected theme.
|
|
|
|
* Then, in its base theme, its base's base theme, etc.
|
|
|
|
|
2009-02-15 09:10:10 -06:00
|
|
|
When extending a template in the base theme with the same name, use the theme
|
|
|
|
name as an explicit directory: ``{% extends "basic/layout.html" %}``. From a
|
|
|
|
user ``templates_path`` template, you can still use the "exclamation mark"
|
|
|
|
syntax as described in the templating document.
|
2009-02-15 04:38:23 -06:00
|
|
|
|
|
|
|
|
2009-02-15 04:03:16 -06:00
|
|
|
Static templates
|
2009-02-15 04:38:23 -06:00
|
|
|
~~~~~~~~~~~~~~~~
|
2009-02-15 04:03:16 -06:00
|
|
|
|
|
|
|
Since theme options are meant for the user to configure a theme more easily,
|
|
|
|
without having to write a custom stylesheet, it is necessary to be able to
|
|
|
|
template static files as well as HTML files. Therefore, Sphinx supports
|
|
|
|
so-called "static templates", like this:
|
|
|
|
|
|
|
|
If the name of a file in the ``static/`` directory of a theme (or in the user's
|
|
|
|
static path, for that matter) ends with ``_t``, it will be processed by the
|
|
|
|
template engine. The ``_t`` will be left from the final file name. For
|
2015-02-23 07:51:30 -06:00
|
|
|
example, the *classic* theme has a file ``static/classic.css_t`` which uses
|
2009-02-15 04:03:16 -06:00
|
|
|
templating to put the color options into the stylesheet. When a documentation
|
2015-02-23 07:51:30 -06:00
|
|
|
is built with the classic theme, the output directory will contain a
|
|
|
|
``_static/classic.css`` file where all template tags have been processed.
|
2009-02-15 04:03:16 -06:00
|
|
|
|
2009-02-19 16:31:34 -06:00
|
|
|
|
2009-02-15 04:03:16 -06:00
|
|
|
.. [1] It is not an executable Python file, as opposed to :file:`conf.py`,
|
|
|
|
because that would pose an unnecessary security risk if themes are
|
|
|
|
shared.
|
2016-08-23 04:42:12 -05:00
|
|
|
|
|
|
|
Third Party Themes
|
|
|
|
------------------
|
|
|
|
|
|
|
|
.. cssclass:: longtable
|
|
|
|
|
|
|
|
+--------------------+--------------------+
|
|
|
|
| **Theme overview** | |
|
|
|
|
+--------------------+--------------------+
|
|
|
|
| |sphinx_rtd_theme| | |
|
|
|
|
| | |
|
|
|
|
| *sphinx_rtd_theme* | |
|
|
|
|
+--------------------+--------------------+
|
|
|
|
|
|
|
|
.. |sphinx_rtd_theme| image:: themes/sphinx_rtd_theme.png
|
|
|
|
|
|
|
|
* **sphinx_rtd_theme** -- `Read the Docs Sphinx Theme`_.
|
|
|
|
This is a mobile-friendly sphinx theme that was made for readthedocs.org.
|
|
|
|
View a working demo over on readthedocs.org. You can get install and options
|
|
|
|
information at `Read the Docs Sphinx Theme`_ page.
|
|
|
|
|
2018-04-18 21:51:48 -05:00
|
|
|
.. _Read the Docs Sphinx Theme: https://pypi.org/project/sphinx_rtd_theme/
|
2016-08-23 04:42:12 -05:00
|
|
|
|
|
|
|
.. versionchanged:: 1.4
|
|
|
|
**sphinx_rtd_theme** has become optional.
|
2018-01-30 08:40:00 -06:00
|
|
|
|
|
|
|
|
|
|
|
Besides this, there are a lot of third party themes. You can find them on
|
|
|
|
PyPI__, GitHub__, sphinx-themes.org__ and so on.
|
|
|
|
|
|
|
|
.. __: https://pypi.python.org/pypi?:action=browse&c=599
|
|
|
|
.. __: https://github.com/search?utf8=%E2%9C%93&q=sphinx+theme&type=
|
|
|
|
.. __: https://sphinx-themes.org/
|