conf.py 6.0 KB

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