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-07-20 14:25:27 +02:00
|
|
|
from sphinx.cmd.build import get_parser
|
2021-03-30 12:22:20 +02:00
|
|
|
import sphinx_rtd_theme
|
|
|
|
|
|
|
|
|
2021-07-20 14:25:27 +02:00
|
|
|
args = get_parser().parse_args()
|
|
|
|
ZEPHYR_BASE = Path(__file__).resolve().parents[1]
|
|
|
|
ZEPHYR_BUILD = Path(args.outputdir).resolve()
|
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 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"
|
2022-02-19 00:08:42 +01:00
|
|
|
copyright = "2015-2022 Zephyr Project members and individual contributors"
|
2021-07-22 16:14:51 +02:00
|
|
|
author = "The Zephyr Project Contributors"
|
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-07-22 16:14:51 +02:00
|
|
|
release = version
|
|
|
|
|
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",
|
2021-07-20 16:12:23 +02:00
|
|
|
"sphinx.ext.graphviz",
|
2021-03-30 14:50:25 +02:00
|
|
|
"zephyr.application",
|
|
|
|
"zephyr.html_redirects",
|
2022-01-12 13:41:15 +01:00
|
|
|
"zephyr.kconfig",
|
2021-03-30 14:50:25 +02:00
|
|
|
"zephyr.dtcompatible-role",
|
|
|
|
"zephyr.link-roles",
|
|
|
|
"sphinx_tabs.tabs",
|
2021-04-06 00:02:03 +02:00
|
|
|
"zephyr.warnings_filter",
|
2021-04-16 10:47:43 +02:00
|
|
|
"zephyr.doxyrunner",
|
2021-06-28 20:08:13 +02:00
|
|
|
"zephyr.vcs_link",
|
2021-05-19 16:04:20 +02:00
|
|
|
"notfound.extension",
|
2022-03-25 13:29:37 +01:00
|
|
|
"sphinx_copybutton",
|
2021-05-10 19:11:14 +02:00
|
|
|
"zephyr.external_content",
|
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
|
|
|
|
2021-03-30 14:50:25 +02:00
|
|
|
pygments_style = "sphinx"
|
2015-05-13 20:05:30 +02:00
|
|
|
|
2015-08-07 19:22:27 +02:00
|
|
|
todo_include_todos = False
|
2015-06-12 19:51:09 +02:00
|
|
|
|
2021-09-22 22:44:00 +02:00
|
|
|
numfig = True
|
|
|
|
|
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-05-17 19:22:17 +02:00
|
|
|
html_theme_options = {
|
|
|
|
"logo_only": True,
|
|
|
|
"prev_next_buttons_location": None
|
|
|
|
}
|
2015-06-29 21:33:28 +02:00
|
|
|
html_title = "Zephyr Project Documentation"
|
2021-05-19 12:25:16 +02:00
|
|
|
html_logo = str(ZEPHYR_BASE / "doc" / "_static" / "images" / "logo.svg")
|
2021-06-30 15:03:11 +02:00
|
|
|
html_favicon = str(ZEPHYR_BASE / "doc" / "_static" / "images" / "favicon.png")
|
2021-03-30 14:50:25 +02:00
|
|
|
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-05-19 12:25:16 +02:00
|
|
|
html_search_scorer = str(ZEPHYR_BASE / "doc" / "_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
|
2021-10-28 18:57:20 +02:00
|
|
|
reference_prefix = ""
|
|
|
|
if tags.has("publish"): # pylint: disable=undefined-variable
|
|
|
|
reference_prefix = f"/{version}" if is_release else "/latest"
|
2021-03-30 14:50:25 +02:00
|
|
|
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,
|
|
|
|
"current_version": version,
|
|
|
|
"versions": (
|
|
|
|
("latest", "/"),
|
2022-06-04 00:33:24 +02:00
|
|
|
("3.1.0", "/3.1.0/"),
|
2022-02-19 00:17:00 +01:00
|
|
|
("3.0.0", "/3.0.0/"),
|
2021-10-19 17:21:38 +02:00
|
|
|
("2.7.0", "/2.7.0/"),
|
2021-06-02 04:10:08 +02:00
|
|
|
("2.6.0", "/2.6.0/"),
|
2021-03-30 14:50:25 +02:00
|
|
|
("2.5.0", "/2.5.0/"),
|
|
|
|
("2.4.0", "/2.4.0/"),
|
|
|
|
("2.3.0", "/2.3.0/"),
|
|
|
|
("1.14.1", "/1.14.1/"),
|
|
|
|
),
|
2021-06-28 20:08:13 +02:00
|
|
|
"display_vcs_link": True,
|
2021-10-28 18:57:20 +02:00
|
|
|
"reference_links": {
|
|
|
|
"API": f"{reference_prefix}/doxygen/html/index.html",
|
2022-01-12 13:41:15 +01:00
|
|
|
"Kconfig Options": f"{reference_prefix}/kconfig.html",
|
2022-04-05 16:17:26 +02:00
|
|
|
"Devicetree Bindings": f"{reference_prefix}/build/dts/api/bindings.html",
|
2021-10-28 18:57:20 +02:00
|
|
|
}
|
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-07-22 16:14:51 +02:00
|
|
|
"papersize": "a4paper",
|
|
|
|
"maketitle": open(ZEPHYR_BASE / "doc" / "_static" / "latex" / "title.tex").read(),
|
|
|
|
"preamble": open(ZEPHYR_BASE / "doc" / "_static" / "latex" / "preamble.tex").read(),
|
|
|
|
"fontpkg": r"\usepackage{charter}",
|
|
|
|
"sphinxsetup": ",".join(
|
|
|
|
(
|
|
|
|
# NOTE: colors match those found in light.css stylesheet
|
|
|
|
"verbatimwithframe=false",
|
|
|
|
"VerbatimColor={HTML}{f0f2f4}",
|
|
|
|
"InnerLinkColor={HTML}{2980b9}",
|
|
|
|
"warningBgColor={HTML}{e9a499}",
|
|
|
|
"warningborder=0pt",
|
|
|
|
r"HeaderFamily=\rmfamily\bfseries",
|
|
|
|
)
|
|
|
|
),
|
2015-05-13 20:05:30 +02:00
|
|
|
}
|
2021-07-22 16:14:51 +02:00
|
|
|
latex_logo = str(ZEPHYR_BASE / "doc" / "_static" / "images" / "logo-latex.pdf")
|
2015-05-13 20:05:30 +02:00
|
|
|
latex_documents = [
|
2021-07-22 16:14:51 +02:00
|
|
|
("index-tex", "zephyr.tex", "Zephyr Project Documentation", author, "manual"),
|
2015-05-13 20:05:30 +02:00
|
|
|
]
|
|
|
|
|
2021-04-16 10:47:43 +02:00
|
|
|
# -- Options for zephyr.doxyrunner plugin ---------------------------------
|
|
|
|
|
|
|
|
doxyrunner_doxygen = os.environ.get("DOXYGEN_EXECUTABLE", "doxygen")
|
|
|
|
doxyrunner_doxyfile = ZEPHYR_BASE / "doc" / "zephyr.doxyfile.in"
|
|
|
|
doxyrunner_outdir = ZEPHYR_BUILD / "doxygen"
|
|
|
|
doxyrunner_fmt = True
|
2021-10-03 19:32:42 +02:00
|
|
|
doxyrunner_fmt_vars = {"ZEPHYR_BASE": str(ZEPHYR_BASE), "ZEPHYR_VERSION": version}
|
2022-01-10 12:35:31 +01:00
|
|
|
doxyrunner_outdir_var = "DOXY_OUT"
|
2021-04-16 10:47:43 +02:00
|
|
|
|
2021-03-30 13:09:11 +02:00
|
|
|
# -- Options for Breathe plugin -------------------------------------------
|
|
|
|
|
2021-05-19 13:11:51 +02:00
|
|
|
breathe_projects = {"Zephyr": str(doxyrunner_outdir / "xml")}
|
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-10-23 12:40:49 +02:00
|
|
|
breathe_show_enumvalue_initializer = True
|
2021-05-17 12:57:15 +02:00
|
|
|
breathe_default_members = ("members", )
|
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",
|
2022-02-01 21:30:19 +01:00
|
|
|
"ALWAYS_INLINE",
|
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")
|
|
|
|
|
2021-05-19 16:04:20 +02:00
|
|
|
# -- Options for notfound.extension ---------------------------------------
|
|
|
|
|
2021-06-22 11:16:25 +02:00
|
|
|
notfound_urls_prefix = f"/{version}/" if is_release else "/latest/"
|
2021-05-19 16:04:20 +02:00
|
|
|
|
2021-06-28 20:08:13 +02:00
|
|
|
# -- Options for zephyr.vcs_link ------------------------------------------
|
|
|
|
|
|
|
|
vcs_link_version = f"v{version}" if is_release else "main"
|
|
|
|
vcs_link_base_url = f"https://github.com/zephyrproject-rtos/zephyr/blob/{vcs_link_version}"
|
|
|
|
vcs_link_prefixes = {
|
|
|
|
"samples/.*": "",
|
|
|
|
"boards/.*": "",
|
|
|
|
".*": "doc",
|
|
|
|
}
|
|
|
|
vcs_link_exclude = [
|
|
|
|
"reference/kconfig.*",
|
2022-04-05 16:17:26 +02:00
|
|
|
"build/dts/api/bindings.*",
|
|
|
|
"build/dts/api/compatibles.*",
|
2021-06-28 20:08:13 +02:00
|
|
|
]
|
|
|
|
|
2022-01-12 13:41:15 +01:00
|
|
|
# -- Options for zephyr.kconfig -------------------------------------------
|
|
|
|
|
|
|
|
kconfig_generate_db = True
|
|
|
|
kconfig_ext_paths = [ZEPHYR_BASE]
|
|
|
|
|
2021-05-10 19:11:14 +02:00
|
|
|
# -- Options for zephyr.external_content ----------------------------------
|
|
|
|
|
|
|
|
external_content_contents = [
|
|
|
|
(ZEPHYR_BASE / "doc", "[!_]*"),
|
|
|
|
(ZEPHYR_BASE, "boards/**/*.rst"),
|
|
|
|
(ZEPHYR_BASE, "boards/**/doc"),
|
|
|
|
(ZEPHYR_BASE, "samples/**/*.rst"),
|
|
|
|
(ZEPHYR_BASE, "samples/**/doc"),
|
|
|
|
]
|
|
|
|
external_content_keep = [
|
|
|
|
"reference/kconfig/*",
|
2022-04-05 16:17:26 +02:00
|
|
|
"build/dts/api/bindings.rst",
|
|
|
|
"build/dts/api/bindings/**/*",
|
|
|
|
"build/dts/api/compatibles/**/*",
|
2021-05-10 19:11:14 +02:00
|
|
|
]
|
|
|
|
|
2021-07-20 16:12:23 +02:00
|
|
|
# -- Options for sphinx.ext.graphviz --------------------------------------
|
|
|
|
|
|
|
|
graphviz_dot = os.environ.get("DOT_EXECUTABLE", "dot")
|
|
|
|
graphviz_output_format = "svg"
|
|
|
|
graphviz_dot_args = [
|
|
|
|
"-Gbgcolor=transparent",
|
|
|
|
"-Nstyle=filled",
|
|
|
|
"-Nfillcolor=white",
|
|
|
|
"-Ncolor=gray60",
|
|
|
|
"-Nfontcolor=gray25",
|
|
|
|
"-Ecolor=gray60",
|
|
|
|
]
|
|
|
|
|
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-12 14:33:16 +01:00
|
|
|
# theme customizations
|
|
|
|
app.add_css_file("css/custom.css")
|
|
|
|
app.add_js_file("js/dark-mode-toggle.min.mjs", type="module")
|
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")
|