xref: /openbmc/qemu/docs/conf.py (revision 3becc939)
1# -*- coding: utf-8 -*-
2#
3# QEMU documentation build configuration file, created by
4# sphinx-quickstart on Thu Jan 31 16:40:14 2019.
5#
6# This config file can be used in one of two ways:
7# (1) as a common config file which is included by the conf.py
8# for each of QEMU's manuals: in this case sphinx-build is run multiple
9# times, once per subdirectory.
10# (2) as a top level conf file which will result in building all
11# the manuals into a single document: in this case sphinx-build is
12# run once, on the top-level docs directory.
13#
14# QEMU's makefiles take option (1), which allows us to install
15# only the ones the user cares about (in particular we don't want
16# to ship the 'devel' manual to end-users).
17# Third-party sites such as readthedocs.org will take option (2).
18#
19#
20# This file is execfile()d with the current directory set to its
21# containing dir.
22#
23# Note that not all possible configuration values are present in this
24# autogenerated file.
25#
26# All configuration values have a default; values that are commented out
27# serve to show the default.
28
29import os
30import sys
31import sphinx
32from sphinx.errors import ConfigError
33
34# The per-manual conf.py will set qemu_docdir for a single-manual build;
35# otherwise set it here if this is an entire-manual-set build.
36# This is always the absolute path of the docs/ directory in the source tree.
37try:
38    qemu_docdir
39except NameError:
40    qemu_docdir = os.path.abspath(".")
41
42# If extensions (or modules to document with autodoc) are in another directory,
43# add these directories to sys.path here. If the directory is relative to the
44# documentation root, use an absolute path starting from qemu_docdir.
45#
46# Our extensions are in docs/sphinx; the qapidoc extension requires
47# the QAPI modules from scripts/.
48sys.path.insert(0, os.path.join(qemu_docdir, "sphinx"))
49sys.path.insert(0, os.path.join(qemu_docdir, "../scripts"))
50
51
52# -- General configuration ------------------------------------------------
53
54# If your documentation needs a minimal Sphinx version, state it here.
55#
56# 3.4.3 is the oldest version of Sphinx that ships on a platform we
57# pledge build support for.
58needs_sphinx = '3.4.3'
59
60# Add any Sphinx extension module names here, as strings. They can be
61# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
62# ones.
63extensions = ['kerneldoc', 'qmp_lexer', 'hxtool', 'depfile', 'qapidoc']
64
65if sphinx.version_info[:3] > (4, 0, 0):
66    tags.add('sphinx4')
67    extensions += ['dbusdoc']
68else:
69    extensions += ['fakedbusdoc']
70
71# Add any paths that contain templates here, relative to this directory.
72templates_path = [os.path.join(qemu_docdir, '_templates')]
73
74# The suffix(es) of source filenames.
75# You can specify multiple suffix as a list of string:
76#
77# source_suffix = ['.rst', '.md']
78source_suffix = '.rst'
79
80# The master toctree document.
81master_doc = 'index'
82
83# Interpret `single-backticks` to be a cross-reference to any kind of
84# referenceable object. Unresolvable or ambiguous references will emit a
85# warning at build time.
86default_role = 'any'
87
88# General information about the project.
89project = u'QEMU'
90copyright = u'2024, The QEMU Project Developers'
91author = u'The QEMU Project Developers'
92
93# The version info for the project you're documenting, acts as replacement for
94# |version| and |release|, also used in various other places throughout the
95# built documents.
96
97# Extract this information from the VERSION file, for the benefit of
98# standalone Sphinx runs as used by readthedocs.org. Builds run from
99# the Makefile will pass version and release on the sphinx-build
100# command line, which override this.
101try:
102    extracted_version = None
103    with open(os.path.join(qemu_docdir, '../VERSION')) as f:
104        extracted_version = f.readline().strip()
105except:
106    pass
107finally:
108    if extracted_version:
109        version = release = extracted_version
110    else:
111        version = release = "unknown version"
112
113# The language for content autogenerated by Sphinx. Refer to documentation
114# for a list of supported languages.
115#
116# This is also used if you do content translation via gettext catalogs.
117# Usually you set "language" from the command line for these cases.
118language = 'en'
119
120# List of patterns, relative to source directory, that match files and
121# directories to ignore when looking for source files.
122# This patterns also effect to html_static_path and html_extra_path
123exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
124
125# The name of the Pygments (syntax highlighting) style to use.
126pygments_style = 'sphinx'
127
128# If true, `todo` and `todoList` produce output, else they produce nothing.
129todo_include_todos = False
130
131# Sphinx defaults to warning about use of :option: for options not defined
132# with "option::" in the document being processed. Turn that off.
133suppress_warnings = ["ref.option"]
134
135# The rst_epilog fragment is effectively included in every rST file.
136# We use it to define substitutions based on build config that
137# can then be used in the documentation. The fallback if the
138# environment variable is not set is for the benefit of readthedocs
139# style document building; our Makefile always sets the variable.
140confdir = os.getenv('CONFDIR', "/etc/qemu")
141rst_epilog = ".. |CONFDIR| replace:: ``" + confdir + "``\n"
142# We slurp in the defs.rst.inc and literally include it into rst_epilog,
143# because Sphinx's include:: directive doesn't work with absolute paths
144# and there isn't any one single relative path that will work for all
145# documents and for both via-make and direct sphinx-build invocation.
146with open(os.path.join(qemu_docdir, 'defs.rst.inc')) as f:
147    rst_epilog += f.read()
148
149# -- Options for HTML output ----------------------------------------------
150
151# The theme to use for HTML and HTML Help pages.  See the documentation for
152# a list of builtin themes.
153#
154try:
155    import sphinx_rtd_theme
156except ImportError:
157    raise ConfigError(
158        'The Sphinx \'sphinx_rtd_theme\' HTML theme was not found.\n'
159    )
160
161html_theme = 'sphinx_rtd_theme'
162
163# Theme options are theme-specific and customize the look and feel of a theme
164# further.  For a list of options available for each theme, see the
165# documentation.
166html_theme_options = {
167    "style_nav_header_background": "#802400",
168    "navigation_with_keys": True,
169}
170
171html_logo = os.path.join(qemu_docdir, "../ui/icons/qemu_128x128.png")
172
173html_favicon = os.path.join(qemu_docdir, "../ui/icons/qemu_32x32.png")
174
175# Add any paths that contain custom static files (such as style sheets) here,
176# relative to this directory. They are copied after the builtin static files,
177# so a file named "default.css" will overwrite the builtin "default.css".
178html_static_path = [os.path.join(qemu_docdir, "sphinx-static")]
179
180html_css_files = [
181    'theme_overrides.css',
182]
183
184html_js_files = [
185    'custom.js',
186]
187
188html_context = {
189    "display_gitlab": True,
190    "gitlab_user": "qemu-project",
191    "gitlab_repo": "qemu",
192    "gitlab_version": "master",
193    "conf_py_path": "/docs/", # Path in the checkout to the docs root
194}
195
196# Custom sidebar templates, must be a dictionary that maps document names
197# to template names.
198#html_sidebars = {}
199
200# Don't copy the rST source files to the HTML output directory,
201# and don't put links to the sources into the output HTML.
202html_copy_source = False
203
204# -- Options for HTMLHelp output ------------------------------------------
205
206# Output file base name for HTML help builder.
207htmlhelp_basename = 'QEMUdoc'
208
209
210# -- Options for LaTeX output ---------------------------------------------
211
212latex_elements = {
213    # The paper size ('letterpaper' or 'a4paper').
214    #
215    # 'papersize': 'letterpaper',
216
217    # The font size ('10pt', '11pt' or '12pt').
218    #
219    # 'pointsize': '10pt',
220
221    # Additional stuff for the LaTeX preamble.
222    #
223    # 'preamble': '',
224
225    # Latex figure (float) alignment
226    #
227    # 'figure_align': 'htbp',
228}
229
230# Grouping the document tree into LaTeX files. List of tuples
231# (source start file, target name, title,
232#  author, documentclass [howto, manual, or own class]).
233latex_documents = [
234    (master_doc, 'QEMU.tex', u'QEMU Documentation',
235     u'The QEMU Project Developers', 'manual'),
236]
237
238
239# -- Options for manual page output ---------------------------------------
240# Individual manual/conf.py can override this to create man pages
241man_pages = [
242    ('interop/qemu-ga', 'qemu-ga',
243     'QEMU Guest Agent',
244     ['Michael Roth <mdroth@linux.vnet.ibm.com>'], 8),
245    ('interop/qemu-ga-ref', 'qemu-ga-ref',
246     'QEMU Guest Agent Protocol Reference',
247     [], 7),
248    ('interop/qemu-qmp-ref', 'qemu-qmp-ref',
249     'QEMU QMP Reference Manual',
250     [], 7),
251    ('interop/qemu-storage-daemon-qmp-ref', 'qemu-storage-daemon-qmp-ref',
252     'QEMU Storage Daemon QMP Reference Manual',
253     [], 7),
254    ('system/qemu-manpage', 'qemu',
255     'QEMU User Documentation',
256     ['Fabrice Bellard'], 1),
257    ('system/qemu-block-drivers', 'qemu-block-drivers',
258     'QEMU block drivers reference',
259     ['Fabrice Bellard and the QEMU Project developers'], 7),
260    ('system/qemu-cpu-models', 'qemu-cpu-models',
261     'QEMU CPU Models',
262     ['The QEMU Project developers'], 7),
263    ('tools/qemu-img', 'qemu-img',
264     'QEMU disk image utility',
265     ['Fabrice Bellard'], 1),
266    ('tools/qemu-nbd', 'qemu-nbd',
267     'QEMU Disk Network Block Device Server',
268     ['Anthony Liguori <anthony@codemonkey.ws>'], 8),
269    ('tools/qemu-pr-helper', 'qemu-pr-helper',
270     'QEMU persistent reservation helper',
271     [], 8),
272    ('tools/qemu-storage-daemon', 'qemu-storage-daemon',
273     'QEMU storage daemon',
274     [], 1),
275    ('tools/qemu-trace-stap', 'qemu-trace-stap',
276     'QEMU SystemTap trace tool',
277     [], 1),
278    ('tools/virtfs-proxy-helper', 'virtfs-proxy-helper',
279     'QEMU 9p virtfs proxy filesystem helper',
280     ['M. Mohan Kumar'], 1),
281]
282man_make_section_directory = False
283
284# We use paths starting from qemu_docdir here so that you can run
285# sphinx-build from anywhere and the kerneldoc extension can still
286# find everything.
287kerneldoc_bin = ['perl', os.path.join(qemu_docdir, '../scripts/kernel-doc')]
288kerneldoc_srctree = os.path.join(qemu_docdir, '..')
289hxtool_srctree = os.path.join(qemu_docdir, '..')
290qapidoc_srctree = os.path.join(qemu_docdir, '..')
291dbusdoc_srctree = os.path.join(qemu_docdir, '..')
292dbus_index_common_prefix = ["org.qemu."]
293