diff mbox series

[3/3] conf.py: reorganize options

Message ID 20260828-cleanup-conf-py-v1-3-c8925e5fe1ac@bootlin.com
State New
Headers show
Series conf.py cleanups | expand

Commit Message

Antonin Godard Aug. 28, 2026, 9:49 a.m. UTC
This patch does not modify the configuration, but only moves them around
to categorize them better - per category and extension. The only "mixed"
section is the "General configuration" section but only contains native
Sphinx modification (nothing related to extensions).

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 documentation/conf.py | 238 ++++++++++++++++++++++++++------------------------
 1 file changed, 124 insertions(+), 114 deletions(-)
diff mbox series

Patch

diff --git a/documentation/conf.py b/documentation/conf.py
index bd3a4e5bc..48d28a686 100644
--- a/documentation/conf.py
+++ b/documentation/conf.py
@@ -6,12 +6,6 @@ 
 # list see the documentation:
 # https://www.sphinx-doc.org/en/master/usage/configuration.html
 
-# -- Path setup --------------------------------------------------------------
-
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-
 import datetime
 import importlib.util
 import os
@@ -29,42 +23,25 @@  except ImportError:
     \nPlease make sure to install pyyaml Python package.\n")
     sys.exit(1)
 
-# current_version = "dev"
-# bitbake_version = "" # Leave empty for development branch
-# Obtain versions from poky.yaml instead
-with open("poky.yaml") as data:
-    buff = data.read()
-    subst_vars = yaml.safe_load(buff)
-    if "DOCCONF_VERSION" not in subst_vars:
-        sys.stderr.write("Please set DOCCONF_VERSION in poky.yaml")
-        sys.exit(1)
-    current_version = subst_vars["DOCCONF_VERSION"]
-    if "BITBAKE_SERIES" not in subst_vars:
-        sys.stderr.write("Please set BITBAKE_SERIES in poky.yaml")
-        sys.exit(1)
-    bitbake_version = subst_vars["BITBAKE_SERIES"]
-
-# String used in sidebar
-version = 'Version: ' + current_version
-if current_version == 'dev':
-    version = 'Version: Current Development'
-# Version seen in documentation_options.js and hence in js switchers code
-release = current_version
-
-
 # -- Project information -----------------------------------------------------
+
 project = 'The Yocto Project \xae'
 copyright = '2010-%s, The Linux Foundation, CC-BY-SA-2.0-UK license' % datetime.datetime.now().year
 author = 'The Linux Foundation'
 
+# -- Path setup --------------------------------------------------------------
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+
+sys.path.insert(0, os.path.abspath('sphinx'))
+
 # -- General configuration ---------------------------------------------------
 
 # Prevent building with an outdated version of sphinx
 needs_sphinx = "4.0"
 
-# to load local extension from the folder 'sphinx'
-sys.path.insert(0, os.path.abspath('sphinx'))
-
 # Add any Sphinx extension module names here, as strings. They can be
 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
 # ones.
@@ -76,7 +53,28 @@  extensions = [
     'sphinxcontrib.rsvgconverter',
     'yocto-vars'
 ]
-autosectionlabel_prefix_document = True
+
+# current_version = "dev"
+# bitbake_version = "" # Leave empty for development branch
+# Obtain versions from poky.yaml instead
+with open("poky.yaml") as data:
+    buff = data.read()
+    subst_vars = yaml.safe_load(buff)
+    if "DOCCONF_VERSION" not in subst_vars:
+        sys.stderr.write("Please set DOCCONF_VERSION in poky.yaml")
+        sys.exit(1)
+    current_version = subst_vars["DOCCONF_VERSION"]
+    if "BITBAKE_SERIES" not in subst_vars:
+        sys.stderr.write("Please set BITBAKE_SERIES in poky.yaml")
+        sys.exit(1)
+    bitbake_version = subst_vars["BITBAKE_SERIES"]
+
+# String used in sidebar
+version = 'Version: ' + current_version
+if current_version == 'dev':
+    version = 'Version: Current Development'
+# Version seen in documentation_options.js and hence in js switchers code
+release = current_version
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
@@ -97,74 +95,39 @@  rst_prolog = """
 .. |author| replace:: %s
 """ % (project, copyright, author)
 
-# base url definitions
-oe_git_server = "https://git.openembedded.org"
-oecore_git = f"{oe_git_server}/openembedded-core"
-bitbake_git = f"{oe_git_server}/bitbake"
-yocto_git_server = "https://git.yoctoproject.org"
-meta_yocto_git = f"{yocto_git_server}/meta-yocto"
-bugzilla_server = "https://bugzilla.yoctoproject.org"
-
-# external links and substitutions
-extlinks = {
-    'bitbake_git': (f'{bitbake_git}%s', None),
-    'bitbake_path': (f'{bitbake_git}/tree/%s', '%s'),
-    'bitbake_rev': (f'{bitbake_git}/commit/?id=%s', '%.7s'),
-    'cve_mitre': ('https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s', 'CVE-%s'),
-    'cve_nist': ('https://nvd.nist.gov/vuln/detail/CVE-%s', 'CVE-%s'),
-    'yocto_home': ('https://www.yoctoproject.org%s', None),
-    'yocto_wiki': ('https://wiki.yoctoproject.org/wiki%s', None),
-    'yocto_dl': ('https://downloads.yoctoproject.org%s', None),
-    'yocto_lists': ('https://lists.yoctoproject.org%s', None),
-    'yocto_bugs': (f'{bugzilla_server}%s', None),
-    'yocto_bug': (f'{bugzilla_server}/show_bug.cgi?id=%s', '%s'),
-    'yocto_ab': ('https://autobuilder.yoctoproject.org%s', None),
-    'yocto_docs': ('https://docs.yoctoproject.org%s', None),
-    'yocto_git': (f'{yocto_git_server}%s', None),
-    'meta_yocto_path': (f'{meta_yocto_git}/tree/%s', '%s'),
-    'meta_yocto_rev': (f'{meta_yocto_git}/commit/?id=%s', '%.7s'),
-    'yocto_sstate': ('http://sstate.yoctoproject.org%s', None),
-    'oe_home': ('https://www.openembedded.org%s', None),
-    'oe_lists': ('https://lists.openembedded.org%s', None),
-    'oe_git': (f'{oe_git_server}%s', None),
-    'oecore_path': (f'{oecore_git}/tree/%s', '%s'),
-    'oecore_rev': (f'{oecore_git}/commit/?id=%s', '%.7s'),
-    'oe_wiki': ('https://www.openembedded.org/wiki%s', None),
-    'oe_layerindex': ('https://layers.openembedded.org%s', None),
-    'oe_layer': ('https://layers.openembedded.org/layerindex/branch/master/layer%s', None),
-    'wikipedia': ('https://en.wikipedia.org/wiki/%s', None),
-}
-
 # To be able to use :manpage:`<something>` in the docs.
 manpages_url = 'https://manpages.debian.org/{path}'
 
-# Intersphinx config to use cross reference with BitBake user manual
-intersphinx_mapping = {
-    'bitbake': ('https://docs.yoctoproject.org/bitbake/' + bitbake_version, None)
-}
-
 # Suppress "WARNING: unknown mimetype for ..."
 suppress_warnings = ['epub.unknown_project_files']
 
-# sphinx-copybutton configuration
-copybutton_prompt_text = "$ "
+# We need XeTeX to process special unicode character, sometimes the contributor
+# list from the release note contains those.
+# See https://docs.readthedocs.io/en/stable/guides/pdf-non-ascii-languages.html.
+latex_engine = 'xelatex'
+latex_use_xindy = False
+latex_elements = {
+    'passoptionstopackages': '\\PassOptionsToPackage{bookmarksdepth=5}{hyperref}',
+    'preamble': '\\usepackage[UTF8]{ctex}\n\\setcounter{tocdepth}{2}',
+}
 
-# Don't check self-references to yocto-docs since they are already
-# checked when building.
-linkcheck_ignore = [r'https?://docs\.yoctoproject\.org.*']
+class DashFriendlySearchEnglish(SearchEnglish):
 
-# When using the linkcheck builder, ignore the following links which are too
-# frequent in the docs, unless the LINKCHECK_NOT_NICE environment variable is set
-# to 1.
-if os.environ.get('LINKCHECK_NOT_NICE') != "1":
-    linkcheck_ignore.extend([
-        r'https?://nvd\.nist\.gov.*',
-        r'https?://git\.yoctoproject\.org.*',
-        r'https?://git\.openembedded\.org.*',
-        r'https?://downloads\.yoctoproject\.org.*',
-        r'https?://mirrors\.kernel\.org.*',
-        r'https?://mirrors\.edge\.kernel\.org.*',
-    ])
+    # Accept words that can include 'inner' hyphens or dots
+    _word_re = re.compile(r'[\w]+(?:[\.\-][\w]+)*')
+
+    js_splitter_code = r"""
+function splitQuery(query) {
+    return query
+        .split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}\-\.]+/gu)
+        .filter(term => term.length > 0);
+}
+"""
+
+languages['en'] = DashFriendlySearchEnglish
+
+# Make the EPUB builder prefer PNG to SVG because of issues rendering Inkscape SVG
+Epub3Builder.supported_image_types = ['image/png', 'image/gif', 'image/jpeg']
 
 # -- Options for HTML output -------------------------------------------------
 
@@ -206,30 +169,77 @@  html_last_updated_fmt = '%b %d, %Y'
 # Remove the trailing 'dot' in section numbers
 html_secnumber_suffix = " "
 
-# We need XeTeX to process special unicode character, sometimes the contributor
-# list from the release note contains those.
-# See https://docs.readthedocs.io/en/stable/guides/pdf-non-ascii-languages.html.
-latex_engine = 'xelatex'
-latex_use_xindy = False
-latex_elements = {
-    'passoptionstopackages': '\\PassOptionsToPackage{bookmarksdepth=5}{hyperref}',
-    'preamble': '\\usepackage[UTF8]{ctex}\n\\setcounter{tocdepth}{2}',
-}
+# -- linkcheck configuration -------------------------------------------------
 
-class DashFriendlySearchEnglish(SearchEnglish):
+# Don't check self-references to yocto-docs since they are already
+# checked when building.
+linkcheck_ignore = [r'https?://docs\.yoctoproject\.org.*']
 
-    # Accept words that can include 'inner' hyphens or dots
-    _word_re = re.compile(r'[\w]+(?:[\.\-][\w]+)*')
+# When using the linkcheck builder, ignore the following links which are too
+# frequent in the docs, unless the LINKCHECK_NOT_NICE environment variable is set
+# to 1.
+if os.environ.get('LINKCHECK_NOT_NICE') != "1":
+    linkcheck_ignore.extend([
+        r'https?://nvd\.nist\.gov.*',
+        r'https?://git\.yoctoproject\.org.*',
+        r'https?://git\.openembedded\.org.*',
+        r'https?://downloads\.yoctoproject\.org.*',
+        r'https?://mirrors\.kernel\.org.*',
+        r'https?://mirrors\.edge\.kernel\.org.*',
+    ])
 
-    js_splitter_code = r"""
-function splitQuery(query) {
-    return query
-        .split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}\-\.]+/gu)
-        .filter(term => term.length > 0);
+# -- sphinx.ext.autosectionlabel configuration -------------------------------
+
+autosectionlabel_prefix_document = True
+
+# -- sphinx.ext.extlinks configuration ---------------------------------------
+
+# base url definitions
+oe_git_server = "https://git.openembedded.org"
+oecore_git = f"{oe_git_server}/openembedded-core"
+bitbake_git = f"{oe_git_server}/bitbake"
+yocto_git_server = "https://git.yoctoproject.org"
+meta_yocto_git = f"{yocto_git_server}/meta-yocto"
+bugzilla_server = "https://bugzilla.yoctoproject.org"
+
+# external links and substitutions
+extlinks = {
+    'bitbake_git': (f'{bitbake_git}%s', None),
+    'bitbake_path': (f'{bitbake_git}/tree/%s', '%s'),
+    'bitbake_rev': (f'{bitbake_git}/commit/?id=%s', '%.7s'),
+    'cve_mitre': ('https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s', 'CVE-%s'),
+    'cve_nist': ('https://nvd.nist.gov/vuln/detail/CVE-%s', 'CVE-%s'),
+    'yocto_home': ('https://www.yoctoproject.org%s', None),
+    'yocto_wiki': ('https://wiki.yoctoproject.org/wiki%s', None),
+    'yocto_dl': ('https://downloads.yoctoproject.org%s', None),
+    'yocto_lists': ('https://lists.yoctoproject.org%s', None),
+    'yocto_bugs': (f'{bugzilla_server}%s', None),
+    'yocto_bug': (f'{bugzilla_server}/show_bug.cgi?id=%s', '%s'),
+    'yocto_ab': ('https://autobuilder.yoctoproject.org%s', None),
+    'yocto_docs': ('https://docs.yoctoproject.org%s', None),
+    'yocto_git': (f'{yocto_git_server}%s', None),
+    'meta_yocto_path': (f'{meta_yocto_git}/tree/%s', '%s'),
+    'meta_yocto_rev': (f'{meta_yocto_git}/commit/?id=%s', '%.7s'),
+    'yocto_sstate': ('http://sstate.yoctoproject.org%s', None),
+    'oe_home': ('https://www.openembedded.org%s', None),
+    'oe_lists': ('https://lists.openembedded.org%s', None),
+    'oe_git': (f'{oe_git_server}%s', None),
+    'oecore_path': (f'{oecore_git}/tree/%s', '%s'),
+    'oecore_rev': (f'{oecore_git}/commit/?id=%s', '%.7s'),
+    'oe_wiki': ('https://www.openembedded.org/wiki%s', None),
+    'oe_layerindex': ('https://layers.openembedded.org%s', None),
+    'oe_layer': ('https://layers.openembedded.org/layerindex/branch/master/layer%s', None),
+    'wikipedia': ('https://en.wikipedia.org/wiki/%s', None),
 }
-"""
 
-languages['en'] = DashFriendlySearchEnglish
+# -- sphinx.ext.intersphinx configuration ------------------------------------
 
-# Make the EPUB builder prefer PNG to SVG because of issues rendering Inkscape SVG
-Epub3Builder.supported_image_types = ['image/png', 'image/gif', 'image/jpeg']
+# Intersphinx config to use cross reference with BitBake user manual
+intersphinx_mapping = {
+    'bitbake': ('https://docs.yoctoproject.org/bitbake/' + bitbake_version, None)
+}
+
+# -- sphinx_copybutton configuration -----------------------------------------
+
+# sphinx-copybutton configuration
+copybutton_prompt_text = "$ "