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