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