This is a fork of sphinx-rtd-theme by Read The Docs. This fork is used by the ESP-IDF Programming Guide. Espressif forked this theme when we moved ESP-IDF Programming Guide away from Read The Docs' hosted service and needed some functionality that neither RTD nor the theme could provide out of the box.
This theme must be imported as a Python package not using html_theme_path, as it relies on some code in __init__.py
. To debug the theme in development, best approach I've found is:
- Run
python3 setup.py build
in this directory. - In top of IDF docs
conf_common.py
, add a temporarysys.path.append('/path/to/here/build/lib')
. - Run IDF docs build, it will import the just-built theme from this directory as a package.
- New JavaScript file
idf_embeds.js
is compiled intotheme.js
, sets up version footer.
Set the following additional config variables in the Sphinx project:
idf_target
- slug of the IDF target (ie esp32, esp32s2). Optional, but ifidf_target
is set thenidf_targets
must be set and vice versa. If these two are unset, no "Targets" section is generated in the navigation footer.idf_targets
- Python list with short names of all supported IDF targets (ie["esp32", "esp32s2"]
).languages
- Python list with short names of all supported languages (ie["en", "zh_CN"]
). Must be set to at least one language element (the current project's language)project_slug
- short name of the project as a URL slug (ieesp-idf
)versions_url
- URL to download theversions.js
file fromproject_homepage
- URL of the project's main page (GitHub, etc)
The file found at the versions_url
location should be a JavaScript file describing all current versions. It should take this form:
``` var DOCUMENTATION_VERSIONS = {
"DEFAULTS": { "has_targets": false }, "VERSIONS": [
{ "name": "latest", "has_targets": true }, { "name": "v4.0" }, { "name": "v3.3.1" }, { "name": "v3.3", "old": true }, { "name": "v3.2.3" }, { "name": "v3.2.2", "old": true }, { "name": "v3.1.6" }, { "name": "v3.1.5", "old": true }, { "name": "v3.0.9", "old": true }, { "name": "v4.0-rc", "pre_release": true }, { "name": "v4.0-beta2", "pre_release": true }, { "name": "release-v4.1", "pre_release": true }, { "name": "release-v4.0", "pre_release": true }, { "name": "release-v3.3", "pre_release": true }, { "name": "release-v3.2", "pre_release": true }, { "name": "release-v3.1", "pre_release": true },]
Note
This file is JavaScript so it can be easily included in a script tag, but it's expected to contain a single assignment statement which assigns the DOCUMENTATION_VERSIONS
variable to a valid JSON object. Doing any other JavaScript computation in this file is invalid.
Inside the DOCUMENTATION_VERSIONS
object:
VERSIONS
key is a list of versions, where each version is a JSON object with at minimum aname
key which is the version name "slug", and optionally one or more of the following keys: -has_targets
is true if the URLs for these docs have a target element, ie<project>/<language>/<version>/<target>
. False if the URL format is<project>/<language>/<version>
. A single project can have some versions which include and some which exclude the target URL component, and the theme will try to generate version links that add or drop the<target>
element as applicable. -old
is true if this version is not current, will be shown in "Old Versions" section under the main versions. -pre_release
is true if this version is a prerelease not a stable release, will be shown in "Prereleases" section under the main versionsDEFAULTS
key contains the default values for any keys which are not supplied in an individual version object. This exists as "sugar" to make the file more readable.
This Sphinx theme was designed to provide a great reader experience for documentation users on both desktop and mobile devices. This theme is used primarily on Read the Docs but can work with any Sphinx project. You can find a working demo of the theme in the theme documentation
This theme is distributed on PyPI and can be installed with pip
:
$ pip install sphinx-rtd-theme
To use the theme in your Sphinx project, you will need to add the following to
your conf.py
file:
import sphinx_idf_theme
extensions = [
...
"sphinx_idf_theme",
]
html_theme = "sphinx_idf_theme"
For more information read the full documentation on installing the theme
This theme is highly customizable on both the page level and on a global level. To see all the possible configuration options, read the documentation on configuring the theme.
If you would like to help modify or translate the theme, you'll find more information on contributing in our contributing guide.