1 # -*- coding: utf-8 -*-
3 # The Linux Kernel documentation build configuration file, created by
4 # sphinx-quickstart on Fri Feb 12 13:51:46 2016.
6 # This file is execfile()d with the current directory set to its
9 # Note that not all possible configuration values are present in this
12 # All configuration values have a default; values that are commented out
13 # serve to show the default.
23 def have_command(cmd):
24 """Search ``cmd`` in the ``PATH`` environment.
26 If found, return True.
27 If not found, return False.
29 return shutil.which(cmd) is not None
32 major, minor, patch = sphinx.version_info[:3]
35 # Warn about older versions that we don't want to support for much
38 if (major < 2) or (major == 2 and minor < 4):
39 print('WARNING: support for Sphinx < 2.4 will be removed soon.')
41 # If extensions (or modules to document with autodoc) are in another directory,
42 # add these directories to sys.path here. If the directory is relative to the
43 # documentation root, use os.path.abspath to make it absolute, like shown here.
44 sys.path.insert(0, os.path.abspath('sphinx'))
45 from load_config import loadConfig
47 # -- General configuration ------------------------------------------------
49 # If your documentation needs a minimal Sphinx version, state it here.
52 # Add any Sphinx extension module names here, as strings. They can be
53 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
55 extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
56 'kfigure', 'sphinx.ext.ifconfig', 'automarkup',
57 'maintainers_include', 'sphinx.ext.autosectionlabel',
58 'kernel_abi', 'kernel_feat']
61 if (major > 3) or (minor > 0 or patch >= 2):
62 # Sphinx c function parser is more pedantic with regards to type
63 # checking. Due to that, having macros at c:function cause problems.
64 # Those needed to be scaped by using c_id_attributes[] array
66 # GCC Compiler types not parsed by Sphinx:
69 # include/linux/compiler_types.h:
79 # include/linux/compiler_attributes.h:
86 "__attribute_const__",
96 "__no_caller_saved_registers",
110 # include/linux/memblock.h:
114 # include/linux/init.h:
118 # include/linux/linkage.h:
121 # include/linux/btf.h
126 extensions.append('cdomain')
128 # Ensure that autosectionlabel will produce unique names
129 autosectionlabel_prefix_document = True
130 autosectionlabel_maxdepth = 2
132 # Load math renderer:
133 # For html builder, load imgmath only when its dependencies are met.
134 # mathjax is the default math renderer since Sphinx 1.8.
135 have_latex = have_command('latex')
136 have_dvipng = have_command('dvipng')
137 load_imgmath = have_latex and have_dvipng
139 # Respect SPHINX_IMGMATH (for html docs only)
140 if 'SPHINX_IMGMATH' in os.environ:
141 env_sphinx_imgmath = os.environ['SPHINX_IMGMATH']
142 if 'yes' in env_sphinx_imgmath:
144 elif 'no' in env_sphinx_imgmath:
147 sys.stderr.write("Unknown env SPHINX_IMGMATH=%s ignored.\n" % env_sphinx_imgmath)
149 # Always load imgmath for Sphinx <1.8 or for epub docs
150 load_imgmath = (load_imgmath or (major == 1 and minor < 8)
151 or 'epub' in sys.argv)
154 extensions.append("sphinx.ext.imgmath")
155 math_renderer = 'imgmath'
157 math_renderer = 'mathjax'
159 # Add any paths that contain templates here, relative to this directory.
160 templates_path = ['sphinx/templates']
162 # The suffix(es) of source filenames.
163 # You can specify multiple suffix as a list of string:
164 # source_suffix = ['.rst', '.md']
165 source_suffix = '.rst'
167 # The encoding of source files.
168 #source_encoding = 'utf-8-sig'
170 # The master toctree document.
173 # General information about the project.
174 project = 'The Linux Kernel'
175 copyright = 'The kernel development community'
176 author = 'The kernel development community'
178 # The version info for the project you're documenting, acts as replacement for
179 # |version| and |release|, also used in various other places throughout the
182 # In a normal build, version and release are are set to KERNELVERSION and
183 # KERNELRELEASE, respectively, from the Makefile via Sphinx command line
186 # The following code tries to extract the information by reading the Makefile,
187 # when Sphinx is run directly (e.g. by Read the Docs).
189 makefile_version = None
190 makefile_patchlevel = None
191 for line in open('../Makefile'):
192 key, val = [x.strip() for x in line.split('=', 2)]
194 makefile_version = val
195 elif key == 'PATCHLEVEL':
196 makefile_patchlevel = val
197 if makefile_version and makefile_patchlevel:
202 if makefile_version and makefile_patchlevel:
203 version = release = makefile_version + '.' + makefile_patchlevel
205 version = release = "unknown version"
208 # HACK: there seems to be no easy way for us to get at the version and
209 # release information passed in from the makefile...so go pawing through the
210 # command-line options and find it for ourselves.
212 def get_cline_version():
213 c_version = c_release = ''
215 if arg.startswith('version='):
217 elif arg.startswith('release='):
221 return c_version + '-' + c_release
223 return version # Whatever we came up with before
225 # The language for content autogenerated by Sphinx. Refer to documentation
226 # for a list of supported languages.
228 # This is also used if you do content translation via gettext catalogs.
229 # Usually you set "language" from the command line for these cases.
232 # There are two options for replacing |today|: either, you set today to some
233 # non-false value, then it is used:
235 # Else, today_fmt is used as the format for a strftime call.
236 #today_fmt = '%B %d, %Y'
238 # List of patterns, relative to source directory, that match files and
239 # directories to ignore when looking for source files.
240 exclude_patterns = ['output']
242 # The reST default role (used for this markup: `text`) to use for all
246 # If true, '()' will be appended to :func: etc. cross-reference text.
247 #add_function_parentheses = True
249 # If true, the current module name will be prepended to all description
250 # unit titles (such as .. function::).
251 #add_module_names = True
253 # If true, sectionauthor and moduleauthor directives will be shown in the
254 # output. They are ignored by default.
255 #show_authors = False
257 # The name of the Pygments (syntax highlighting) style to use.
258 pygments_style = 'sphinx'
260 # A list of ignored prefixes for module index sorting.
261 #modindex_common_prefix = []
263 # If true, keep warnings as "system message" paragraphs in the built documents.
264 #keep_warnings = False
266 # If true, `todo` and `todoList` produce output, else they produce nothing.
267 todo_include_todos = False
270 highlight_language = 'none'
272 # -- Options for HTML output ----------------------------------------------
274 # The theme to use for HTML and HTML Help pages. See the documentation for
275 # a list of builtin themes.
278 html_theme = 'alabaster'
281 if "DOCS_THEME" in os.environ:
282 html_theme = os.environ["DOCS_THEME"]
284 if html_theme == 'sphinx_rtd_theme' or html_theme == 'sphinx_rtd_dark_mode':
285 # Read the Docs theme
287 import sphinx_rtd_theme
288 html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
290 # Add any paths that contain custom static files (such as style sheets) here,
291 # relative to this directory. They are copied after the builtin static files,
292 # so a file named "default.css" will overwrite the builtin "default.css".
294 'theme_overrides.css',
297 # Read the Docs dark mode override theme
298 if html_theme == 'sphinx_rtd_dark_mode':
300 import sphinx_rtd_dark_mode
301 extensions.append('sphinx_rtd_dark_mode')
303 html_theme == 'sphinx_rtd_theme'
305 if html_theme == 'sphinx_rtd_theme':
306 # Add color-specific RTD normal mode
307 html_css_files.append('theme_rtd_colors.css')
309 html_theme_options = {
310 'navigation_depth': -1,
314 html_theme = 'alabaster'
316 if "DOCS_CSS" in os.environ:
317 css = os.environ["DOCS_CSS"].split(" ")
320 html_css_files.append(l)
322 if major <= 1 and minor < 8:
327 for l in html_css_files:
328 html_context['css_files'].append('_static/' + l)
330 if html_theme == 'alabaster':
331 html_theme_options = {
332 'description': get_cline_version(),
333 'page_width': '65em',
334 'sidebar_width': '15em',
335 'fixed_sidebar': 'true',
336 'font_size': 'inherit',
337 'font_family': 'serif',
340 sys.stderr.write("Using %s theme\n" % html_theme)
342 # Add any paths that contain custom static files (such as style sheets) here,
343 # relative to this directory. They are copied after the builtin static files,
344 # so a file named "default.css" will overwrite the builtin "default.css".
345 html_static_path = ['sphinx-static']
347 # If true, Docutils "smart quotes" will be used to convert quotes and dashes
348 # to typographically correct entities. This will convert "--" to "—",
349 # which is not always what we want, so disable it.
352 # Custom sidebar templates, maps document names to template names.
353 # Note that the RTD theme ignores this
354 html_sidebars = { '**': ['searchbox.html', 'kernel-toc.html', 'sourcelink.html']}
356 # about.html is available for alabaster theme. Add it at the front.
357 if html_theme == 'alabaster':
358 html_sidebars['**'].insert(0, 'about.html')
360 # Output file base name for HTML help builder.
361 htmlhelp_basename = 'TheLinuxKerneldoc'
363 # -- Options for LaTeX output ---------------------------------------------
366 # The paper size ('letterpaper' or 'a4paper').
367 'papersize': 'a4paper',
369 # The font size ('10pt', '11pt' or '12pt').
372 # Latex figure (float) alignment
373 #'figure_align': 'htbp',
375 # Don't mangle with UTF-8 chars
379 # Set document margins
381 hmargin=0.5in, vmargin=1in,
382 parsedliteralwraps=true,
383 verbatimhintsturnover=false,
386 # For CJK One-half spacing, need to be in front of hyperref
387 'extrapackages': r'\usepackage{setspace}',
389 # Additional stuff for the LaTeX preamble.
391 % Use some font with UTF-8 support with XeLaTeX
392 \\usepackage{fontspec}
393 \\setsansfont{DejaVu Sans}
394 \\setromanfont{DejaVu Serif}
395 \\setmonofont{DejaVu Sans Mono}
399 # Fix reference escape troubles with Sphinx 1.4.x
401 latex_elements['preamble'] += '\\renewcommand*{\\DUrole}[2]{ #2 }\n'
404 # Load kerneldoc specific LaTeX settings
405 latex_elements['preamble'] += '''
406 % Load kerneldoc specific LaTeX settings
407 \\input{kerneldoc-preamble.sty}
410 # With Sphinx 1.6, it is possible to change the Bg color directly
412 # \definecolor{sphinxnoteBgColor}{RGB}{204,255,255}
413 # \definecolor{sphinxwarningBgColor}{RGB}{255,204,204}
414 # \definecolor{sphinxattentionBgColor}{RGB}{255,255,204}
415 # \definecolor{sphinximportantBgColor}{RGB}{192,255,204}
417 # However, it require to use sphinx heavy box with:
419 # \renewenvironment{sphinxlightbox} {%
420 # \\begin{sphinxheavybox}
422 # \\end{sphinxheavybox}
425 # Unfortunately, the implementation is buggy: if a note is inside a
426 # table, it isn't displayed well. So, for now, let's use boring
427 # black and white notes.
429 # Grouping the document tree into LaTeX files. List of tuples
430 # (source start file, target name, title,
431 # author, documentclass [howto, manual, or own class]).
432 # Sorted in alphabetical order
436 # Add all other index files from Documentation/ subdirectories
437 for fn in os.listdir('.'):
438 doc = os.path.join(fn, "index")
439 if os.path.exists(doc + ".rst"):
441 for l in latex_documents:
446 latex_documents.append((doc, fn + '.tex',
447 'Linux %s Documentation' % fn.capitalize(),
448 'The kernel development community',
451 # The name of an image file (relative to this directory) to place at the top of
455 # For "manual" documents, if this is true, then toplevel headings are parts,
457 #latex_use_parts = False
459 # If true, show page references after internal links.
460 #latex_show_pagerefs = False
462 # If true, show URL addresses after external links.
463 #latex_show_urls = False
465 # Documents to append as an appendix to all manuals.
466 #latex_appendices = []
468 # If false, no module index is generated.
469 #latex_domain_indices = True
471 # Additional LaTeX stuff to be copied to build directory
472 latex_additional_files = [
473 'sphinx/kerneldoc-preamble.sty',
477 # -- Options for manual page output ---------------------------------------
479 # One entry per manual page. List of tuples
480 # (source start file, name, description, authors, manual section).
482 (master_doc, 'thelinuxkernel', 'The Linux Kernel Documentation',
486 # If true, show URL addresses after external links.
487 #man_show_urls = False
490 # -- Options for Texinfo output -------------------------------------------
492 # Grouping the document tree into Texinfo files. List of tuples
493 # (source start file, target name, title, author,
494 # dir menu entry, description, category)
495 texinfo_documents = [
496 (master_doc, 'TheLinuxKernel', 'The Linux Kernel Documentation',
497 author, 'TheLinuxKernel', 'One line description of project.',
501 # -- Options for Epub output ----------------------------------------------
503 # Bibliographic Dublin Core info.
506 epub_publisher = author
507 epub_copyright = copyright
509 # A list of files that should not be packed into the epub file.
510 epub_exclude_files = ['search.html']
515 # Grouping the document tree into PDF files. List of tuples
516 # (source start file, target name, title, author, options).
518 # See the Sphinx chapter of https://ralsina.me/static/manual.pdf
520 # FIXME: Do not add the index file here; the result will be too big. Adding
521 # multiple PDF files here actually tries to get the cross-referencing right
522 # *between* PDF files.
524 ('kernel-documentation', u'Kernel', u'Kernel', u'J. Random Bozo'),
527 # kernel-doc extension configuration for running Sphinx directly (e.g. by Read
528 # the Docs). In a normal build, these are supplied from the Makefile via command
530 kerneldoc_bin = '../scripts/kernel-doc'
531 kerneldoc_srctree = '..'
533 # ------------------------------------------------------------------------------
534 # Since loadConfig overwrites settings from the global namespace, it has to be
535 # the last statement in the conf.py file
536 # ------------------------------------------------------------------------------
537 loadConfig(globals())