xref: /openbmc/qemu/docs/conf.py (revision d85f7efe1f16c51b9c016ebc79f7c4081486642e)
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 = [
64    'depfile',
65    'hxtool',
66    'kerneldoc',
67    'qapi_domain',
68    'qapidoc',
69    'qmp_lexer',
70]
71
72if sphinx.version_info[:3] > (4, 0, 0):
73    tags.add('sphinx4')
74    extensions += ['dbusdoc']
75else:
76    extensions += ['fakedbusdoc']
77
78# Add any paths that contain templates here, relative to this directory.
79templates_path = [os.path.join(qemu_docdir, '_templates')]
80
81# The suffix(es) of source filenames.
82# You can specify multiple suffix as a list of string:
83#
84# source_suffix = ['.rst', '.md']
85source_suffix = '.rst'
86
87# The master toctree document.
88master_doc = 'index'
89
90# Interpret `single-backticks` to be a cross-reference to any kind of
91# referenceable object. Unresolvable or ambiguous references will emit a
92# warning at build time.
93default_role = 'any'
94
95# General information about the project.
96project = u'QEMU'
97copyright = u'2025, The QEMU Project Developers'
98author = u'The QEMU Project Developers'
99
100# The version info for the project you're documenting, acts as replacement for
101# |version| and |release|, also used in various other places throughout the
102# built documents.
103
104# Extract this information from the VERSION file, for the benefit of
105# standalone Sphinx runs as used by readthedocs.org. Builds run from
106# the Makefile will pass version and release on the sphinx-build
107# command line, which override this.
108try:
109    extracted_version = None
110    with open(os.path.join(qemu_docdir, '../VERSION')) as f:
111        extracted_version = f.readline().strip()
112except:
113    pass
114finally:
115    if extracted_version:
116        version = release = extracted_version
117    else:
118        version = release = "unknown version"
119
120# The language for content autogenerated by Sphinx. Refer to documentation
121# for a list of supported languages.
122#
123# This is also used if you do content translation via gettext catalogs.
124# Usually you set "language" from the command line for these cases.
125language = 'en'
126
127# List of patterns, relative to source directory, that match files and
128# directories to ignore when looking for source files.
129# This patterns also effect to html_static_path and html_extra_path
130exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
131
132# The name of the Pygments (syntax highlighting) style to use.
133pygments_style = 'sphinx'
134
135# If true, `todo` and `todoList` produce output, else they produce nothing.
136todo_include_todos = False
137
138# Sphinx defaults to warning about use of :option: for options not defined
139# with "option::" in the document being processed. Turn that off.
140suppress_warnings = ["ref.option"]
141
142# The rst_epilog fragment is effectively included in every rST file.
143# We use it to define substitutions based on build config that
144# can then be used in the documentation. The fallback if the
145# environment variable is not set is for the benefit of readthedocs
146# style document building; our Makefile always sets the variable.
147confdir = os.getenv('CONFDIR', "/etc/qemu")
148rst_epilog = ".. |CONFDIR| replace:: ``" + confdir + "``\n"
149# We slurp in the defs.rst.inc and literally include it into rst_epilog,
150# because Sphinx's include:: directive doesn't work with absolute paths
151# and there isn't any one single relative path that will work for all
152# documents and for both via-make and direct sphinx-build invocation.
153with open(os.path.join(qemu_docdir, 'defs.rst.inc')) as f:
154    rst_epilog += f.read()
155
156
157# Normally, the QAPI domain is picky about what field lists you use to
158# describe a QAPI entity. If you'd like to use arbitrary additional
159# fields in source documentation, add them here.
160qapi_allowed_fields = {
161    "see also",
162}
163
164# Due to a limitation in Sphinx, we need to know which indices to
165# generate in advance. Adding a namespace here allows that generation.
166qapi_namespaces = {
167    "QMP",
168}
169
170# -- Options for HTML output ----------------------------------------------
171
172# The theme to use for HTML and HTML Help pages.  See the documentation for
173# a list of builtin themes.
174#
175try:
176    import sphinx_rtd_theme
177except ImportError:
178    raise ConfigError(
179        'The Sphinx \'sphinx_rtd_theme\' HTML theme was not found.\n'
180    )
181
182html_theme = 'sphinx_rtd_theme'
183
184# Theme options are theme-specific and customize the look and feel of a theme
185# further.  For a list of options available for each theme, see the
186# documentation.
187html_theme_options = {
188    "style_nav_header_background": "#802400",
189    "navigation_with_keys": True,
190}
191
192html_logo = os.path.join(qemu_docdir, "../ui/icons/qemu_128x128.png")
193
194html_favicon = os.path.join(qemu_docdir, "../ui/icons/qemu_32x32.png")
195
196# Add any paths that contain custom static files (such as style sheets) here,
197# relative to this directory. They are copied after the builtin static files,
198# so a file named "default.css" will overwrite the builtin "default.css".
199html_static_path = [os.path.join(qemu_docdir, "sphinx-static")]
200
201html_css_files = [
202    'theme_overrides.css',
203]
204
205html_js_files = [
206    'custom.js',
207]
208
209html_context = {
210    "source_url_prefix": "https://gitlab.com/qemu-project/qemu/-/blob/master/docs/",
211    "gitlab_user": "qemu-project",
212    "gitlab_repo": "qemu",
213    "gitlab_version": "master",
214    "conf_py_path": "/docs/", # Path in the checkout to the docs root
215}
216
217# Custom sidebar templates, must be a dictionary that maps document names
218# to template names.
219#html_sidebars = {}
220
221# Don't copy the rST source files to the HTML output directory,
222# and don't put links to the sources into the output HTML.
223html_copy_source = False
224
225# -- Options for HTMLHelp output ------------------------------------------
226
227# Output file base name for HTML help builder.
228htmlhelp_basename = 'QEMUdoc'
229
230
231# -- Options for LaTeX output ---------------------------------------------
232
233latex_elements = {
234    # The paper size ('letterpaper' or 'a4paper').
235    #
236    # 'papersize': 'letterpaper',
237
238    # The font size ('10pt', '11pt' or '12pt').
239    #
240    # 'pointsize': '10pt',
241
242    # Additional stuff for the LaTeX preamble.
243    #
244    # 'preamble': '',
245
246    # Latex figure (float) alignment
247    #
248    # 'figure_align': 'htbp',
249}
250
251# Grouping the document tree into LaTeX files. List of tuples
252# (source start file, target name, title,
253#  author, documentclass [howto, manual, or own class]).
254latex_documents = [
255    (master_doc, 'QEMU.tex', u'QEMU Documentation',
256     u'The QEMU Project Developers', 'manual'),
257]
258
259
260# -- Options for manual page output ---------------------------------------
261# Individual manual/conf.py can override this to create man pages
262man_pages = [
263    ('interop/qemu-ga', 'qemu-ga',
264     'QEMU Guest Agent',
265     ['Michael Roth <mdroth@linux.vnet.ibm.com>'], 8),
266    ('interop/qemu-ga-ref', 'qemu-ga-ref',
267     'QEMU Guest Agent Protocol Reference',
268     [], 7),
269    ('interop/qemu-qmp-ref', 'qemu-qmp-ref',
270     'QEMU QMP Reference Manual',
271     [], 7),
272    ('interop/qemu-storage-daemon-qmp-ref', 'qemu-storage-daemon-qmp-ref',
273     'QEMU Storage Daemon QMP Reference Manual',
274     [], 7),
275    ('system/qemu-manpage', 'qemu',
276     'QEMU User Documentation',
277     ['Fabrice Bellard'], 1),
278    ('system/qemu-block-drivers', 'qemu-block-drivers',
279     'QEMU block drivers reference',
280     ['Fabrice Bellard and the QEMU Project developers'], 7),
281    ('system/qemu-cpu-models', 'qemu-cpu-models',
282     'QEMU CPU Models',
283     ['The QEMU Project developers'], 7),
284    ('tools/qemu-img', 'qemu-img',
285     'QEMU disk image utility',
286     ['Fabrice Bellard'], 1),
287    ('tools/qemu-nbd', 'qemu-nbd',
288     'QEMU Disk Network Block Device Server',
289     ['Anthony Liguori <anthony@codemonkey.ws>'], 8),
290    ('tools/qemu-pr-helper', 'qemu-pr-helper',
291     'QEMU persistent reservation helper',
292     [], 8),
293    ('tools/qemu-storage-daemon', 'qemu-storage-daemon',
294     'QEMU storage daemon',
295     [], 1),
296    ('tools/qemu-trace-stap', 'qemu-trace-stap',
297     'QEMU SystemTap trace tool',
298     [], 1),
299]
300man_make_section_directory = False
301
302# We use paths starting from qemu_docdir here so that you can run
303# sphinx-build from anywhere and the kerneldoc extension can still
304# find everything.
305kerneldoc_bin = ['perl', os.path.join(qemu_docdir, '../scripts/kernel-doc')]
306kerneldoc_srctree = os.path.join(qemu_docdir, '..')
307hxtool_srctree = os.path.join(qemu_docdir, '..')
308qapidoc_srctree = os.path.join(qemu_docdir, '..')
309dbusdoc_srctree = os.path.join(qemu_docdir, '..')
310dbus_index_common_prefix = ["org.qemu."]
311