2021-03-30 12:10:31 +02:00
|
|
|
# Zephyr documentation build configuration file.
|
|
|
|
# Reference: https://www.sphinx-doc.org/en/master/usage/configuration.html
|
2015-05-13 20:05:30 +02:00
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
2021-03-30 14:38:59 +02:00
|
|
|
from pathlib import Path
|
2021-03-30 14:31:52 +02:00
|
|
|
import re
|
2015-05-13 20:05:30 +02:00
|
|
|
|
2021-03-30 12:22:20 +02:00
|
|
|
from sphinx.highlighting import lexers
|
|
|
|
import sphinx_rtd_theme
|
|
|
|
|
|
|
|
|
2021-03-30 14:38:59 +02:00
|
|
|
ZEPHYR_BASE = os.environ.get("ZEPHYR_BASE")
|
|
|
|
if not ZEPHYR_BASE:
|
|
|
|
raise ValueError("ZEPHYR_BASE environment variable undefined")
|
|
|
|
ZEPHYR_BASE = Path(ZEPHYR_BASE)
|
2018-07-16 19:05:05 +02:00
|
|
|
|
2021-03-30 14:38:59 +02:00
|
|
|
ZEPHYR_BUILD = os.environ.get("ZEPHYR_BUILD")
|
|
|
|
if not ZEPHYR_BUILD:
|
|
|
|
raise ValueError("ZEPHYR_BUILD environment variable undefined")
|
|
|
|
ZEPHYR_BUILD = Path(ZEPHYR_BUILD)
|
2018-06-08 03:45:55 +02:00
|
|
|
|
2021-03-30 14:50:25 +02:00
|
|
|
# Add the '_extensions' directory to sys.path, to enable finding Sphinx
|
doc: add zephyr-app-commands directive
Add extensions/zephyr to the documentation. This is where Sphinx
extensions customized for Zephyr will live.
Within, add application.py. This provides a directive,
zephyr-app-commands, which generates commands in the docs to build,
flash, debug, etc. an application. For now, these are Unix shell
specific. Later on, they can be customized to generate additional
formats, perhaps with extra options.
After this is used throughout the tree, doing this with an extension
enables global changes with changes to the directive implementation
only.
Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-11-03 21:46:33 +01:00
|
|
|
# extensions within.
|
2021-03-30 14:50:25 +02:00
|
|
|
sys.path.insert(0, str(ZEPHYR_BASE / "doc" / "_extensions"))
|
2018-11-12 16:14:51 +01:00
|
|
|
|
2021-03-30 10:55:43 +02:00
|
|
|
# Add the '_scripts' directory to sys.path, to enable finding utility
|
|
|
|
# modules.
|
2021-03-30 14:50:25 +02:00
|
|
|
sys.path.insert(0, str(ZEPHYR_BASE / "doc" / "_scripts"))
|
2021-03-30 10:55:43 +02:00
|
|
|
|
2019-01-23 16:31:06 +01:00
|
|
|
# Add the directory which contains the runners package as well,
|
|
|
|
# for autodoc directives on runners.xyz.
|
2021-03-30 14:50:25 +02:00
|
|
|
sys.path.insert(0, str(ZEPHYR_BASE / "scripts" / "west_commands"))
|
2019-01-23 16:31:06 +01:00
|
|
|
|
2021-03-30 12:22:20 +02:00
|
|
|
from lexer.DtsLexer import DtsLexer
|
2021-03-30 10:55:43 +02:00
|
|
|
import redirects
|
|
|
|
|
2018-11-12 16:14:51 +01:00
|
|
|
try:
|
2019-07-22 19:00:59 +02:00
|
|
|
import west as west_found
|
|
|
|
except ImportError:
|
|
|
|
west_found = False
|
2015-05-13 20:05:30 +02:00
|
|
|
|
2021-03-30 13:09:11 +02:00
|
|
|
# -- Project --------------------------------------------------------------
|
2015-05-13 20:05:30 +02:00
|
|
|
|
2021-03-30 14:50:25 +02:00
|
|
|
project = "Zephyr Project"
|
|
|
|
copyright = "2015-2021 Zephyr Project members and individual contributors"
|
|
|
|
author = "The Zephyr Project"
|
2015-05-13 20:05:30 +02:00
|
|
|
|
2021-03-30 14:31:52 +02:00
|
|
|
# parse version from 'VERSION' file
|
2021-03-30 14:50:25 +02:00
|
|
|
with open(ZEPHYR_BASE / "VERSION") as f:
|
2021-03-30 14:31:52 +02:00
|
|
|
m = re.match(
|
|
|
|
(
|
|
|
|
r"^VERSION_MAJOR\s*=\s*(\d+)$\n"
|
|
|
|
+ r"^VERSION_MINOR\s*=\s*(\d+)$\n"
|
|
|
|
+ r"^PATCHLEVEL\s*=\s*(\d+)$\n"
|
|
|
|
+ r"^VERSION_TWEAK\s*=\s*\d+$\n"
|
|
|
|
+ r"^EXTRAVERSION\s*=\s*(.*)$"
|
|
|
|
),
|
|
|
|
f.read(),
|
|
|
|
re.MULTILINE,
|
|
|
|
)
|
|
|
|
|
|
|
|
if not m:
|
2021-03-30 14:50:25 +02:00
|
|
|
sys.stderr.write("Warning: Could not extract kernel version\n")
|
2021-03-30 14:31:52 +02:00
|
|
|
version = "Unknown"
|
|
|
|
else:
|
|
|
|
major, minor, patch, extra = m.groups(1)
|
|
|
|
version = ".".join((major, minor, patch))
|
|
|
|
if extra:
|
|
|
|
version += "-" + extra
|
2015-05-13 20:05:30 +02:00
|
|
|
|
2021-03-30 13:09:11 +02:00
|
|
|
# -- General configuration ------------------------------------------------
|
|
|
|
|
|
|
|
extensions = [
|
2021-03-30 14:50:25 +02:00
|
|
|
"breathe",
|
|
|
|
"sphinx.ext.todo",
|
|
|
|
"sphinx.ext.extlinks",
|
|
|
|
"sphinx.ext.autodoc",
|
|
|
|
"zephyr.application",
|
|
|
|
"zephyr.html_redirects",
|
|
|
|
"only.eager_only",
|
|
|
|
"zephyr.dtcompatible-role",
|
|
|
|
"zephyr.link-roles",
|
|
|
|
"sphinx_tabs.tabs",
|
2021-04-06 00:02:03 +02:00
|
|
|
"zephyr.warnings_filter",
|
2021-03-30 13:09:11 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
# Only use SVG converter when it is really needed, e.g. LaTeX.
|
|
|
|
if tags.has("svgconvert"): # pylint: disable=undefined-variable
|
2021-03-30 14:50:25 +02:00
|
|
|
extensions.append("sphinxcontrib.rsvgconverter")
|
2021-03-30 13:09:11 +02:00
|
|
|
|
2021-03-30 14:50:25 +02:00
|
|
|
templates_path = ["_templates"]
|
2021-03-30 13:09:11 +02:00
|
|
|
|
2021-03-30 14:50:25 +02:00
|
|
|
exclude_patterns = ["_build"]
|
2015-05-13 20:05:30 +02:00
|
|
|
|
2018-11-12 16:14:51 +01:00
|
|
|
if not west_found:
|
2021-03-30 14:50:25 +02:00
|
|
|
exclude_patterns.append("**/*west-apis*")
|
2018-11-12 16:14:51 +01:00
|
|
|
else:
|
2021-03-30 14:50:25 +02:00
|
|
|
exclude_patterns.append("**/*west-not-found*")
|
2015-05-13 20:05:30 +02:00
|
|
|
|
2019-03-12 23:39:09 +01:00
|
|
|
# This change will allow us to use bare back-tick notation to let
|
|
|
|
# Sphinx hunt for a reference, starting with normal "document"
|
|
|
|
# references such as :ref:, but also including :c: and :cpp: domains
|
|
|
|
# (potentially) helping with API (doxygen) references simply by using
|
|
|
|
# `name`
|
2021-03-30 14:50:25 +02:00
|
|
|
default_role = "any"
|
2015-05-13 20:05:30 +02:00
|
|
|
|
2021-03-30 14:50:25 +02:00
|
|
|
pygments_style = "sphinx"
|
2015-05-13 20:05:30 +02:00
|
|
|
|
2021-03-30 14:50:25 +02:00
|
|
|
lexers["DTS"] = DtsLexer()
|
2018-02-08 10:48:01 +01:00
|
|
|
|
2015-08-07 19:22:27 +02:00
|
|
|
todo_include_todos = False
|
2015-06-12 19:51:09 +02:00
|
|
|
|
|
|
|
rst_epilog = """
|
2018-05-05 01:31:05 +02:00
|
|
|
.. include:: /substitutions.txt
|
2015-06-12 19:51:09 +02:00
|
|
|
"""
|
2015-05-13 20:05:30 +02:00
|
|
|
|
|
|
|
# -- Options for HTML output ----------------------------------------------
|
|
|
|
|
2018-08-04 01:12:03 +02:00
|
|
|
html_theme = "sphinx_rtd_theme"
|
|
|
|
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
2021-03-30 14:50:25 +02:00
|
|
|
html_theme_options = {"prev_next_buttons_location": None}
|
2015-06-29 21:33:28 +02:00
|
|
|
html_title = "Zephyr Project Documentation"
|
2021-03-30 14:50:25 +02:00
|
|
|
html_logo = "images/Zephyr-Kite-logo.png"
|
|
|
|
html_favicon = "images/zp_favicon.png"
|
|
|
|
html_static_path = [str(ZEPHYR_BASE / "doc" / "_static")]
|
|
|
|
html_last_updated_fmt = "%b %d, %Y"
|
2015-08-07 19:22:27 +02:00
|
|
|
html_domain_indices = False
|
|
|
|
html_split_index = True
|
2018-07-31 22:47:10 +02:00
|
|
|
html_show_sourcelink = False
|
2015-10-16 16:30:15 +02:00
|
|
|
html_show_sphinx = False
|
2021-03-30 14:50:25 +02:00
|
|
|
html_search_scorer = "_static/js/scorer.js"
|
2015-05-13 20:05:30 +02:00
|
|
|
|
2021-03-30 14:50:25 +02:00
|
|
|
is_release = tags.has("release") # pylint: disable=undefined-variable
|
|
|
|
docs_title = "Docs / {}".format(version if is_release else "Latest")
|
2021-03-30 13:09:11 +02:00
|
|
|
html_context = {
|
2021-03-30 14:50:25 +02:00
|
|
|
"show_license": True,
|
|
|
|
"docs_title": docs_title,
|
|
|
|
"is_release": is_release,
|
|
|
|
"theme_logo_only": False,
|
|
|
|
"current_version": version,
|
|
|
|
"versions": (
|
|
|
|
("latest", "/"),
|
|
|
|
("2.5.0", "/2.5.0/"),
|
|
|
|
("2.4.0", "/2.4.0/"),
|
|
|
|
("2.3.0", "/2.3.0/"),
|
|
|
|
("2.2.0", "/2.2.0/"),
|
|
|
|
("1.14.1", "/1.14.1/"),
|
|
|
|
),
|
2021-03-30 13:09:11 +02:00
|
|
|
}
|
2019-01-20 14:56:48 +01:00
|
|
|
|
2015-05-13 20:05:30 +02:00
|
|
|
# -- Options for LaTeX output ---------------------------------------------
|
|
|
|
|
|
|
|
latex_elements = {
|
2021-03-30 14:50:25 +02:00
|
|
|
"preamble": r"\setcounter{tocdepth}{2}",
|
2015-05-13 20:05:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
latex_documents = [
|
2021-03-30 14:50:25 +02:00
|
|
|
("index", "zephyr.tex", "Zephyr Project Documentation", "many", "manual"),
|
2015-05-13 20:05:30 +02:00
|
|
|
]
|
|
|
|
|
2021-03-30 13:09:11 +02:00
|
|
|
# -- Options for Breathe plugin -------------------------------------------
|
|
|
|
|
2015-05-15 18:35:25 +02:00
|
|
|
breathe_projects = {
|
2021-03-30 14:38:59 +02:00
|
|
|
"Zephyr": str(ZEPHYR_BUILD / "doxygen" / "xml"),
|
2021-03-30 14:50:25 +02:00
|
|
|
"doc-examples": str(ZEPHYR_BUILD / "doxygen" / "xml"),
|
2015-05-13 20:05:30 +02:00
|
|
|
}
|
2015-06-12 19:51:09 +02:00
|
|
|
breathe_default_project = "Zephyr"
|
2020-05-18 22:46:26 +02:00
|
|
|
breathe_domain_by_extension = {
|
|
|
|
"h": "c",
|
|
|
|
"c": "c",
|
|
|
|
}
|
2020-09-05 01:23:04 +02:00
|
|
|
breathe_separate_member_pages = True
|
2020-10-23 12:40:49 +02:00
|
|
|
breathe_show_enumvalue_initializer = True
|
2019-03-12 23:39:09 +01:00
|
|
|
|
2020-06-01 13:57:27 +02:00
|
|
|
cpp_id_attributes = [
|
2021-03-30 14:50:25 +02:00
|
|
|
"__syscall",
|
|
|
|
"__deprecated",
|
|
|
|
"__may_alias",
|
|
|
|
"__used",
|
|
|
|
"__unused",
|
|
|
|
"__weak",
|
2021-04-09 06:40:41 +02:00
|
|
|
"__attribute_const__",
|
2021-03-30 14:50:25 +02:00
|
|
|
"__DEPRECATED_MACRO",
|
|
|
|
"FUNC_NORETURN",
|
|
|
|
"__subsystem",
|
2020-06-01 13:57:27 +02:00
|
|
|
]
|
|
|
|
c_id_attributes = cpp_id_attributes
|
2017-09-29 20:31:46 +02:00
|
|
|
|
2021-03-30 13:09:11 +02:00
|
|
|
# -- Options for html_redirect plugin -------------------------------------
|
2021-03-30 12:18:02 +02:00
|
|
|
|
2021-03-30 13:09:11 +02:00
|
|
|
html_redirect_pages = redirects.REDIRECTS
|
2017-01-03 20:43:02 +01:00
|
|
|
|
2021-04-06 00:02:03 +02:00
|
|
|
# -- Options for zephyr.warnings_filter -----------------------------------
|
|
|
|
|
|
|
|
warnings_filter_config = str(ZEPHYR_BASE / "doc" / "known-warnings.txt")
|
|
|
|
warnings_filter_silent = False
|
|
|
|
|
2021-03-30 13:09:11 +02:00
|
|
|
# -- Linkcheck options ----------------------------------------------------
|
2019-01-20 14:56:48 +01:00
|
|
|
|
2021-03-30 14:50:25 +02:00
|
|
|
extlinks = {
|
|
|
|
"jira": ("https://jira.zephyrproject.org/browse/%s", ""),
|
|
|
|
"github": ("https://github.com/zephyrproject-rtos/zephyr/issues/%s", ""),
|
|
|
|
}
|
2017-04-27 23:59:04 +02:00
|
|
|
|
|
|
|
linkcheck_timeout = 30
|
|
|
|
linkcheck_workers = 10
|
|
|
|
linkcheck_anchors = False
|
|
|
|
|
2021-03-30 14:50:25 +02:00
|
|
|
|
2017-01-28 01:20:21 +01:00
|
|
|
def setup(app):
|
2021-03-29 23:48:48 +02:00
|
|
|
app.add_css_file("css/zephyr-custom.css")
|
2021-03-30 14:50:25 +02:00
|
|
|
app.add_js_file("js/zephyr-custom.js")
|
2019-06-06 23:13:56 +02:00
|
|
|
|
2020-05-18 22:42:20 +02:00
|
|
|
app.add_js_file("https://www.googletagmanager.com/gtag/js?id=UA-831873-47")
|
2021-03-29 23:47:39 +02:00
|
|
|
app.add_js_file("js/ga-tracker.js")
|