1*4882a593Smuzhiyun# Configuration file for the Sphinx documentation builder. 2*4882a593Smuzhiyun# 3*4882a593Smuzhiyun# SPDX-License-Identifier: CC-BY-SA-2.0-UK 4*4882a593Smuzhiyun# 5*4882a593Smuzhiyun# This file only contains a selection of the most common options. For a full 6*4882a593Smuzhiyun# list see the documentation: 7*4882a593Smuzhiyun# https://www.sphinx-doc.org/en/master/usage/configuration.html 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun# -- Path setup -------------------------------------------------------------- 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun# If extensions (or modules to document with autodoc) are in another directory, 12*4882a593Smuzhiyun# add these directories to sys.path here. If the directory is relative to the 13*4882a593Smuzhiyun# documentation root, use os.path.abspath to make it absolute, like shown here. 14*4882a593Smuzhiyun# 15*4882a593Smuzhiyunimport os 16*4882a593Smuzhiyunimport sys 17*4882a593Smuzhiyunimport datetime 18*4882a593Smuzhiyuntry: 19*4882a593Smuzhiyun import yaml 20*4882a593Smuzhiyunexcept ImportError: 21*4882a593Smuzhiyun sys.stderr.write("The Yocto Project Sphinx documentation requires PyYAML.\ 22*4882a593Smuzhiyun \nPlease make sure to install pyyaml python package.\n") 23*4882a593Smuzhiyun sys.exit(1) 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun# current_version = "dev" 26*4882a593Smuzhiyun# bitbake_version = "" # Leave empty for development branch 27*4882a593Smuzhiyun# Obtain versions from poky.yaml instead 28*4882a593Smuzhiyunwith open("poky.yaml") as data: 29*4882a593Smuzhiyun buff = data.read() 30*4882a593Smuzhiyun subst_vars = yaml.safe_load(buff) 31*4882a593Smuzhiyun if "DOCCONF_VERSION" not in subst_vars: 32*4882a593Smuzhiyun sys.stderr.write("Please set DOCCONF_VERSION in poky.yaml") 33*4882a593Smuzhiyun sys.exit(1) 34*4882a593Smuzhiyun current_version = subst_vars["DOCCONF_VERSION"] 35*4882a593Smuzhiyun if "BITBAKE_SERIES" not in subst_vars: 36*4882a593Smuzhiyun sys.stderr.write("Please set BITBAKE_SERIES in poky.yaml") 37*4882a593Smuzhiyun sys.exit(1) 38*4882a593Smuzhiyun bitbake_version = subst_vars["BITBAKE_SERIES"] 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun# String used in sidebar 41*4882a593Smuzhiyunversion = 'Version: ' + current_version 42*4882a593Smuzhiyunif current_version == 'dev': 43*4882a593Smuzhiyun version = 'Version: Current Development' 44*4882a593Smuzhiyun# Version seen in documentation_options.js and hence in js switchers code 45*4882a593Smuzhiyunrelease = current_version 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun# -- Project information ----------------------------------------------------- 49*4882a593Smuzhiyunproject = 'The Yocto Project \xae' 50*4882a593Smuzhiyuncopyright = '2010-%s, The Linux Foundation, CC-BY-SA-2.0-UK license' % datetime.datetime.now().year 51*4882a593Smuzhiyunauthor = 'The Linux Foundation' 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun# -- General configuration --------------------------------------------------- 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun# Prevent building with an outdated version of sphinx 56*4882a593Smuzhiyunneeds_sphinx = "3.1" 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun# to load local extension from the folder 'sphinx' 59*4882a593Smuzhiyunsys.path.insert(0, os.path.abspath('sphinx')) 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun# Add any Sphinx extension module names here, as strings. They can be 62*4882a593Smuzhiyun# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 63*4882a593Smuzhiyun# ones. 64*4882a593Smuzhiyunextensions = [ 65*4882a593Smuzhiyun 'sphinx.ext.autosectionlabel', 66*4882a593Smuzhiyun 'sphinx.ext.extlinks', 67*4882a593Smuzhiyun 'sphinx.ext.intersphinx', 68*4882a593Smuzhiyun 'yocto-vars' 69*4882a593Smuzhiyun] 70*4882a593Smuzhiyunautosectionlabel_prefix_document = True 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun# Add any paths that contain templates here, relative to this directory. 73*4882a593Smuzhiyuntemplates_path = ['_templates'] 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun# List of patterns, relative to source directory, that match files and 76*4882a593Smuzhiyun# directories to ignore when looking for source files. 77*4882a593Smuzhiyun# This pattern also affects html_static_path and html_extra_path. 78*4882a593Smuzhiyunexclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'boilerplate.rst'] 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun# master document name. The default changed from contents to index. so better 81*4882a593Smuzhiyun# set it ourselves. 82*4882a593Smuzhiyunmaster_doc = 'index' 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun# create substitution for project configuration variables 85*4882a593Smuzhiyunrst_prolog = """ 86*4882a593Smuzhiyun.. |project_name| replace:: %s 87*4882a593Smuzhiyun.. |copyright| replace:: %s 88*4882a593Smuzhiyun.. |author| replace:: %s 89*4882a593Smuzhiyun""" % (project, copyright, author) 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun# external links and substitutions 92*4882a593Smuzhiyunextlinks = { 93*4882a593Smuzhiyun 'cve': ('https://nvd.nist.gov/vuln/detail/CVE-%s', 'CVE-'), 94*4882a593Smuzhiyun 'yocto_home': ('https://www.yoctoproject.org%s', None), 95*4882a593Smuzhiyun 'yocto_wiki': ('https://wiki.yoctoproject.org/wiki%s', None), 96*4882a593Smuzhiyun 'yocto_dl': ('https://downloads.yoctoproject.org%s', None), 97*4882a593Smuzhiyun 'yocto_lists': ('https://lists.yoctoproject.org%s', None), 98*4882a593Smuzhiyun 'yocto_bugs': ('https://bugzilla.yoctoproject.org%s', None), 99*4882a593Smuzhiyun 'yocto_ab': ('https://autobuilder.yoctoproject.org%s', None), 100*4882a593Smuzhiyun 'yocto_docs': ('https://docs.yoctoproject.org%s', None), 101*4882a593Smuzhiyun 'yocto_git': ('https://git.yoctoproject.org/cgit/cgit.cgi%s', None), 102*4882a593Smuzhiyun 'yocto_sstate': ('http://sstate.yoctoproject.org%s', None), 103*4882a593Smuzhiyun 'oe_home': ('https://www.openembedded.org%s', None), 104*4882a593Smuzhiyun 'oe_lists': ('https://lists.openembedded.org%s', None), 105*4882a593Smuzhiyun 'oe_git': ('https://git.openembedded.org%s', None), 106*4882a593Smuzhiyun 'oe_wiki': ('https://www.openembedded.org/wiki%s', None), 107*4882a593Smuzhiyun 'oe_layerindex': ('https://layers.openembedded.org%s', None), 108*4882a593Smuzhiyun 'oe_layer': ('https://layers.openembedded.org/layerindex/branch/master/layer%s', None), 109*4882a593Smuzhiyun 'wikipedia': ('https://en.wikipedia.org/wiki/%s', None), 110*4882a593Smuzhiyun} 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun# Intersphinx config to use cross reference with Bitbake user manual 113*4882a593Smuzhiyunintersphinx_mapping = { 114*4882a593Smuzhiyun 'bitbake': ('https://docs.yoctoproject.org/bitbake/' + bitbake_version, None) 115*4882a593Smuzhiyun} 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun# Suppress "WARNING: unknown mimetype for ..." 118*4882a593Smuzhiyunsuppress_warnings = ['epub.unknown_project_files'] 119*4882a593Smuzhiyun 120*4882a593Smuzhiyun# -- Options for HTML output ------------------------------------------------- 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun# The theme to use for HTML and HTML Help pages. See the documentation for 123*4882a593Smuzhiyun# a list of builtin themes. 124*4882a593Smuzhiyun# 125*4882a593Smuzhiyuntry: 126*4882a593Smuzhiyun import sphinx_rtd_theme 127*4882a593Smuzhiyun html_theme = 'sphinx_rtd_theme' 128*4882a593Smuzhiyun html_theme_options = { 129*4882a593Smuzhiyun 'sticky_navigation': False, 130*4882a593Smuzhiyun } 131*4882a593Smuzhiyunexcept ImportError: 132*4882a593Smuzhiyun sys.stderr.write("The Sphinx sphinx_rtd_theme HTML theme was not found.\ 133*4882a593Smuzhiyun \nPlease make sure to install the sphinx_rtd_theme python package.\n") 134*4882a593Smuzhiyun sys.exit(1) 135*4882a593Smuzhiyun 136*4882a593Smuzhiyunhtml_logo = 'sphinx-static/YoctoProject_Logo_RGB.jpg' 137*4882a593Smuzhiyun 138*4882a593Smuzhiyun# Add any paths that contain custom static files (such as style sheets) here, 139*4882a593Smuzhiyun# relative to this directory. They are copied after the builtin static files, 140*4882a593Smuzhiyun# so a file named "default.css" will overwrite the builtin "default.css". 141*4882a593Smuzhiyunhtml_static_path = ['sphinx-static'] 142*4882a593Smuzhiyun 143*4882a593Smuzhiyunhtml_context = { 144*4882a593Smuzhiyun 'current_version': current_version, 145*4882a593Smuzhiyun} 146*4882a593Smuzhiyun 147*4882a593Smuzhiyun# Add customm CSS and JS files 148*4882a593Smuzhiyunhtml_css_files = ['theme_overrides.css'] 149*4882a593Smuzhiyunhtml_js_files = ['switchers.js'] 150*4882a593Smuzhiyun 151*4882a593Smuzhiyun# Hide 'Created using Sphinx' text 152*4882a593Smuzhiyunhtml_show_sphinx = False 153*4882a593Smuzhiyun 154*4882a593Smuzhiyun# Add 'Last updated' on each page 155*4882a593Smuzhiyunhtml_last_updated_fmt = '%b %d, %Y' 156*4882a593Smuzhiyun 157*4882a593Smuzhiyun# Remove the trailing 'dot' in section numbers 158*4882a593Smuzhiyunhtml_secnumber_suffix = " " 159*4882a593Smuzhiyun 160*4882a593Smuzhiyunlatex_elements = { 161*4882a593Smuzhiyun 'passoptionstopackages': '\PassOptionsToPackage{bookmarksdepth=5}{hyperref}', 162*4882a593Smuzhiyun 'preamble': '\setcounter{tocdepth}{2}', 163*4882a593Smuzhiyun} 164*4882a593Smuzhiyun 165*4882a593Smuzhiyun# Make the EPUB builder prefer PNG to SVG because of issues rendering Inkscape SVG 166*4882a593Smuzhiyunfrom sphinx.builders.epub3 import Epub3Builder 167*4882a593SmuzhiyunEpub3Builder.supported_image_types = ['image/png', 'image/gif', 'image/jpeg'] 168