xref: /openbmc/qemu/docs/conf.py (revision ed5abf46)
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 VersionRequirementError
33
34# Make Sphinx fail cleanly if using an old Python, rather than obscurely
35# failing because some code in one of our extensions doesn't work there.
36# Unfortunately this doesn't display very neatly (there's an unavoidable
37# Python backtrace) but at least the information gets printed...
38if sys.version_info < (3,5):
39    raise VersionRequirementError(
40        "QEMU requires a Sphinx that uses Python 3.5 or better\n")
41
42# The per-manual conf.py will set qemu_docdir for a single-manual build;
43# otherwise set it here if this is an entire-manual-set build.
44# This is always the absolute path of the docs/ directory in the source tree.
45try:
46    qemu_docdir
47except NameError:
48    qemu_docdir = os.path.abspath(".")
49
50# If extensions (or modules to document with autodoc) are in another directory,
51# add these directories to sys.path here. If the directory is relative to the
52# documentation root, use an absolute path starting from qemu_docdir.
53#
54sys.path.insert(0, os.path.join(qemu_docdir, "sphinx"))
55
56
57# -- General configuration ------------------------------------------------
58
59# If your documentation needs a minimal Sphinx version, state it here.
60#
61# 1.3 is where the 'alabaster' theme was shipped with Sphinx.
62needs_sphinx = '1.3'
63
64# Add any Sphinx extension module names here, as strings. They can be
65# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
66# ones.
67extensions = ['kerneldoc', 'qmp_lexer', 'hxtool']
68
69# Add any paths that contain templates here, relative to this directory.
70templates_path = ['_templates']
71
72# The suffix(es) of source filenames.
73# You can specify multiple suffix as a list of string:
74#
75# source_suffix = ['.rst', '.md']
76source_suffix = '.rst'
77
78# The master toctree document.
79master_doc = 'index'
80
81# General information about the project.
82project = u'QEMU'
83copyright = u'2019, The QEMU Project Developers'
84author = u'The QEMU Project Developers'
85
86# The version info for the project you're documenting, acts as replacement for
87# |version| and |release|, also used in various other places throughout the
88# built documents.
89
90# Extract this information from the VERSION file, for the benefit of
91# standalone Sphinx runs as used by readthedocs.org. Builds run from
92# the Makefile will pass version and release on the sphinx-build
93# command line, which override this.
94try:
95    extracted_version = None
96    with open(os.path.join(qemu_docdir, '../VERSION')) as f:
97        extracted_version = f.readline().strip()
98except:
99    pass
100finally:
101    if extracted_version:
102        version = release = extracted_version
103    else:
104        version = release = "unknown version"
105
106# The language for content autogenerated by Sphinx. Refer to documentation
107# for a list of supported languages.
108#
109# This is also used if you do content translation via gettext catalogs.
110# Usually you set "language" from the command line for these cases.
111language = None
112
113# List of patterns, relative to source directory, that match files and
114# directories to ignore when looking for source files.
115# This patterns also effect to html_static_path and html_extra_path
116exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
117
118# The name of the Pygments (syntax highlighting) style to use.
119pygments_style = 'sphinx'
120
121# If true, `todo` and `todoList` produce output, else they produce nothing.
122todo_include_todos = False
123
124# Sphinx defaults to warning about use of :option: for options not defined
125# with "option::" in the document being processed. Turn that off.
126suppress_warnings = ["ref.option"]
127
128# The rst_epilog fragment is effectively included in every rST file.
129# We use it to define substitutions based on build config that
130# can then be used in the documentation. The fallback if the
131# environment variable is not set is for the benefit of readthedocs
132# style document building; our Makefile always sets the variable.
133confdir = os.getenv('CONFDIR', "/etc/qemu")
134rst_epilog = ".. |CONFDIR| replace:: ``" + confdir + "``\n"
135# We slurp in the defs.rst.inc and literally include it into rst_epilog,
136# because Sphinx's include:: directive doesn't work with absolute paths
137# and there isn't any one single relative path that will work for all
138# documents and for both via-make and direct sphinx-build invocation.
139with open(os.path.join(qemu_docdir, 'defs.rst.inc')) as f:
140    rst_epilog += f.read()
141
142# -- Options for HTML output ----------------------------------------------
143
144# The theme to use for HTML and HTML Help pages.  See the documentation for
145# a list of builtin themes.
146#
147html_theme = 'alabaster'
148
149# Theme options are theme-specific and customize the look and feel of a theme
150# further.  For a list of options available for each theme, see the
151# documentation.
152# We initialize this to empty here, so the per-manual conf.py can just
153# add individual key/value entries.
154html_theme_options = {
155}
156
157# Add any paths that contain custom static files (such as style sheets) here,
158# relative to this directory. They are copied after the builtin static files,
159# so a file named "default.css" will overwrite the builtin "default.css".
160# QEMU doesn't yet have any static files, so comment this out so we don't
161# get a warning about a missing directory.
162# If we do ever add this then it would probably be better to call the
163# subdirectory sphinx_static, as the Linux kernel does.
164# html_static_path = ['_static']
165
166# Custom sidebar templates, must be a dictionary that maps document names
167# to template names.
168#
169# This is required for the alabaster theme
170# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
171html_sidebars = {
172    '**': [
173        'about.html',
174        'navigation.html',
175        'searchbox.html',
176    ]
177}
178
179# Don't copy the rST source files to the HTML output directory,
180# and don't put links to the sources into the output HTML.
181html_copy_source = False
182
183# -- Options for HTMLHelp output ------------------------------------------
184
185# Output file base name for HTML help builder.
186htmlhelp_basename = 'QEMUdoc'
187
188
189# -- Options for LaTeX output ---------------------------------------------
190
191latex_elements = {
192    # The paper size ('letterpaper' or 'a4paper').
193    #
194    # 'papersize': 'letterpaper',
195
196    # The font size ('10pt', '11pt' or '12pt').
197    #
198    # 'pointsize': '10pt',
199
200    # Additional stuff for the LaTeX preamble.
201    #
202    # 'preamble': '',
203
204    # Latex figure (float) alignment
205    #
206    # 'figure_align': 'htbp',
207}
208
209# Grouping the document tree into LaTeX files. List of tuples
210# (source start file, target name, title,
211#  author, documentclass [howto, manual, or own class]).
212latex_documents = [
213    (master_doc, 'QEMU.tex', u'QEMU Documentation',
214     u'The QEMU Project Developers', 'manual'),
215]
216
217
218# -- Options for manual page output ---------------------------------------
219# Individual manual/conf.py can override this to create man pages
220man_pages = []
221
222# -- Options for Texinfo output -------------------------------------------
223
224# Grouping the document tree into Texinfo files. List of tuples
225# (source start file, target name, title, author,
226#  dir menu entry, description, category)
227texinfo_documents = [
228    (master_doc, 'QEMU', u'QEMU Documentation',
229     author, 'QEMU', 'One line description of project.',
230     'Miscellaneous'),
231]
232
233
234
235# We use paths starting from qemu_docdir here so that you can run
236# sphinx-build from anywhere and the kerneldoc extension can still
237# find everything.
238kerneldoc_bin = os.path.join(qemu_docdir, '../scripts/kernel-doc')
239kerneldoc_srctree = os.path.join(qemu_docdir, '..')
240hxtool_srctree = os.path.join(qemu_docdir, '..')
241