1# Configuration file for the Sphinx documentation builder. 2# 3# SPDX-License-Identifier: CC-BY-SA-2.0-UK 4# 5# This file only contains a selection of the most common options. For a full 6# list see the documentation: 7# https://www.sphinx-doc.org/en/master/usage/configuration.html 8 9# -- Path setup -------------------------------------------------------------- 10 11# If extensions (or modules to document with autodoc) are in another directory, 12# add these directories to sys.path here. If the directory is relative to the 13# documentation root, use os.path.abspath to make it absolute, like shown here. 14# 15import os 16import re 17import sys 18import datetime 19try: 20 import yaml 21except ImportError: 22 sys.stderr.write("The Yocto Project Sphinx documentation requires PyYAML.\ 23 \nPlease make sure to install pyyaml Python package.\n") 24 sys.exit(1) 25 26# current_version = "dev" 27# bitbake_version = "" # Leave empty for development branch 28# Obtain versions from poky.yaml instead 29with open("poky.yaml") as data: 30 buff = data.read() 31 subst_vars = yaml.safe_load(buff) 32 if "DOCCONF_VERSION" not in subst_vars: 33 sys.stderr.write("Please set DOCCONF_VERSION in poky.yaml") 34 sys.exit(1) 35 current_version = subst_vars["DOCCONF_VERSION"] 36 if "BITBAKE_SERIES" not in subst_vars: 37 sys.stderr.write("Please set BITBAKE_SERIES in poky.yaml") 38 sys.exit(1) 39 bitbake_version = subst_vars["BITBAKE_SERIES"] 40 41# String used in sidebar 42version = 'Version: ' + current_version 43if current_version == 'dev': 44 version = 'Version: Current Development' 45# Version seen in documentation_options.js and hence in js switchers code 46release = current_version 47 48 49# -- Project information ----------------------------------------------------- 50project = 'The Yocto Project \xae' 51copyright = '2010-%s, The Linux Foundation, CC-BY-SA-2.0-UK license' % datetime.datetime.now().year 52author = 'The Linux Foundation' 53 54# -- General configuration --------------------------------------------------- 55 56# Prevent building with an outdated version of sphinx 57needs_sphinx = "4.0" 58 59# to load local extension from the folder 'sphinx' 60sys.path.insert(0, os.path.abspath('sphinx')) 61 62# Add any Sphinx extension module names here, as strings. They can be 63# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 64# ones. 65extensions = [ 66 'sphinx.ext.autosectionlabel', 67 'sphinx.ext.extlinks', 68 'sphinx.ext.intersphinx', 69 'yocto-vars' 70] 71autosectionlabel_prefix_document = True 72 73# Add any paths that contain templates here, relative to this directory. 74templates_path = ['_templates'] 75 76# List of patterns, relative to source directory, that match files and 77# directories to ignore when looking for source files. 78# This pattern also affects html_static_path and html_extra_path. 79exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'boilerplate.rst'] 80 81# master document name. The default changed from contents to index. so better 82# set it ourselves. 83master_doc = 'index' 84 85# create substitution for project configuration variables 86rst_prolog = """ 87.. |project_name| replace:: %s 88.. |copyright| replace:: %s 89.. |author| replace:: %s 90""" % (project, copyright, author) 91 92# external links and substitutions 93extlinks = { 94 'bitbake_git': ('https://git.openembedded.org/bitbake%s', None), 95 'cve_mitre': ('https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s', 'CVE-%s'), 96 'cve_nist': ('https://nvd.nist.gov/vuln/detail/CVE-%s', 'CVE-%s'), 97 'yocto_home': ('https://www.yoctoproject.org%s', None), 98 'yocto_wiki': ('https://wiki.yoctoproject.org/wiki%s', None), 99 'yocto_dl': ('https://downloads.yoctoproject.org%s', None), 100 'yocto_lists': ('https://lists.yoctoproject.org%s', None), 101 'yocto_bugs': ('https://bugzilla.yoctoproject.org%s', None), 102 'yocto_ab': ('https://autobuilder.yoctoproject.org%s', None), 103 'yocto_docs': ('https://docs.yoctoproject.org%s', None), 104 'yocto_git': ('https://git.yoctoproject.org%s', None), 105 'yocto_sstate': ('http://sstate.yoctoproject.org%s', None), 106 'oe_home': ('https://www.openembedded.org%s', None), 107 'oe_lists': ('https://lists.openembedded.org%s', None), 108 'oe_git': ('https://git.openembedded.org%s', None), 109 'oe_wiki': ('https://www.openembedded.org/wiki%s', None), 110 'oe_layerindex': ('https://layers.openembedded.org%s', None), 111 'oe_layer': ('https://layers.openembedded.org/layerindex/branch/master/layer%s', None), 112 'wikipedia': ('https://en.wikipedia.org/wiki/%s', None), 113} 114 115# To be able to use :manpage:`<something>` in the docs. 116manpages_url = 'https://manpages.debian.org/{path}' 117 118# Intersphinx config to use cross reference with BitBake user manual 119intersphinx_mapping = { 120 'bitbake': ('https://docs.yoctoproject.org/bitbake/' + bitbake_version, None) 121} 122 123# Suppress "WARNING: unknown mimetype for ..." 124suppress_warnings = ['epub.unknown_project_files'] 125 126# -- Options for HTML output ------------------------------------------------- 127 128# The theme to use for HTML and HTML Help pages. See the documentation for 129# a list of builtin themes. 130# 131try: 132 import sphinx_rtd_theme 133 html_theme = 'sphinx_rtd_theme' 134 html_theme_options = { 135 'sticky_navigation': False, 136 } 137except ImportError: 138 sys.stderr.write("The Sphinx sphinx_rtd_theme HTML theme was not found.\ 139 \nPlease make sure to install the sphinx_rtd_theme Python package.\n") 140 sys.exit(1) 141 142html_logo = 'sphinx-static/YoctoProject_Logo_RGB.jpg' 143html_favicon = 'sphinx-static/favicon.ico' 144 145# Add any paths that contain custom static files (such as style sheets) here, 146# relative to this directory. They are copied after the builtin static files, 147# so a file named "default.css" will overwrite the builtin "default.css". 148html_static_path = ['sphinx-static'] 149 150html_context = { 151 'current_version': current_version, 152} 153 154# Add customm CSS and JS files 155html_css_files = ['theme_overrides.css'] 156html_js_files = ['switchers.js'] 157 158# Hide 'Created using Sphinx' text 159html_show_sphinx = False 160 161# Add 'Last updated' on each page 162html_last_updated_fmt = '%b %d, %Y' 163 164# Remove the trailing 'dot' in section numbers 165html_secnumber_suffix = " " 166 167# We need XeTeX to process special unicode character, sometimes the contributor 168# list from the release note contains those. 169# See https://docs.readthedocs.io/en/stable/guides/pdf-non-ascii-languages.html. 170latex_engine = 'xelatex' 171latex_use_xindy = False 172latex_elements = { 173 'passoptionstopackages': '\\PassOptionsToPackage{bookmarksdepth=5}{hyperref}', 174 'preamble': '\\usepackage[UTF8]{ctex}\n\\setcounter{tocdepth}{2}', 175} 176 177 178from sphinx.search import SearchEnglish 179from sphinx.search import languages 180class DashFriendlySearchEnglish(SearchEnglish): 181 182 # Accept words that can include hyphens 183 _word_re = re.compile(r'[\w\-]+') 184 185 js_splitter_code = """ 186function splitQuery(query) { 187 return query 188 .split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}-]+/gu) 189 .filter(term => term.length > 0); 190} 191""" 192 193languages['en'] = DashFriendlySearchEnglish 194 195# Make the EPUB builder prefer PNG to SVG because of issues rendering Inkscape SVG 196from sphinx.builders.epub3 import Epub3Builder 197Epub3Builder.supported_image_types = ['image/png', 'image/gif', 'image/jpeg'] 198