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 # If extensions (or modules to document with autodoc) are in another directory,
36 # add these directories to sys.path here. If the directory is relative to the
37 # documentation root, use os.path.abspath to make it absolute, like shown here.
38 sys.path.insert(0, os.path.abspath('sphinx'))
39 from load_config import loadConfig
41 # -- General configuration ------------------------------------------------
43 # If your documentation needs a minimal Sphinx version, state it here.
46 # Add any Sphinx extension module names here, as strings. They can be
47 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
49 extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
50 'kfigure', 'sphinx.ext.ifconfig', 'automarkup',
51 'maintainers_include', 'sphinx.ext.autosectionlabel',
52 'kernel_abi', 'kernel_feat']
55 if (major > 3) or (minor > 0 or patch >= 2):
56 # Sphinx c function parser is more pedantic with regards to type
57 # checking. Due to that, having macros at c:function cause problems.
58 # Those needed to be scaped by using c_id_attributes[] array
60 # GCC Compiler types not parsed by Sphinx:
63 # include/linux/compiler_types.h:
72 # include/linux/compiler_attributes.h:
79 "__attribute_const__",
89 "__no_caller_saved_registers",
103 # include/linux/memblock.h:
107 # include/linux/init.h:
111 # include/linux/linkage.h:
116 extensions.append('cdomain')
118 # Ensure that autosectionlabel will produce unique names
119 autosectionlabel_prefix_document = True
120 autosectionlabel_maxdepth = 2
122 # Load math renderer:
123 # For html builder, load imgmath only when its dependencies are met.
124 # mathjax is the default math renderer since Sphinx 1.8.
125 have_latex = have_command('latex')
126 have_dvipng = have_command('dvipng')
127 load_imgmath = have_latex and have_dvipng
129 # Respect SPHINX_IMGMATH (for html docs only)
130 if 'SPHINX_IMGMATH' in os.environ:
131 env_sphinx_imgmath = os.environ['SPHINX_IMGMATH']
132 if 'yes' in env_sphinx_imgmath:
134 elif 'no' in env_sphinx_imgmath:
137 sys.stderr.write("Unknown env SPHINX_IMGMATH=%s ignored.\n" % env_sphinx_imgmath)
139 # Always load imgmath for Sphinx <1.8 or for epub docs
140 load_imgmath = (load_imgmath or (major == 1 and minor < 8)
141 or 'epub' in sys.argv)
144 extensions.append("sphinx.ext.imgmath")
145 math_renderer = 'imgmath'
147 math_renderer = 'mathjax'
149 # Add any paths that contain templates here, relative to this directory.
150 templates_path = ['_templates']
152 # The suffix(es) of source filenames.
153 # You can specify multiple suffix as a list of string:
154 # source_suffix = ['.rst', '.md']
155 source_suffix = '.rst'
157 # The encoding of source files.
158 #source_encoding = 'utf-8-sig'
160 # The master toctree document.
163 # General information about the project.
164 project = 'The Linux Kernel'
165 copyright = 'The kernel development community'
166 author = 'The kernel development community'
168 # The version info for the project you're documenting, acts as replacement for
169 # |version| and |release|, also used in various other places throughout the
172 # In a normal build, version and release are are set to KERNELVERSION and
173 # KERNELRELEASE, respectively, from the Makefile via Sphinx command line
176 # The following code tries to extract the information by reading the Makefile,
177 # when Sphinx is run directly (e.g. by Read the Docs).
179 makefile_version = None
180 makefile_patchlevel = None
181 for line in open('../Makefile'):
182 key, val = [x.strip() for x in line.split('=', 2)]
184 makefile_version = val
185 elif key == 'PATCHLEVEL':
186 makefile_patchlevel = val
187 if makefile_version and makefile_patchlevel:
192 if makefile_version and makefile_patchlevel:
193 version = release = makefile_version + '.' + makefile_patchlevel
195 version = release = "unknown version"
198 # HACK: there seems to be no easy way for us to get at the version and
199 # release information passed in from the makefile...so go pawing through the
200 # command-line options and find it for ourselves.
202 def get_cline_version():
203 c_version = c_release = ''
205 if arg.startswith('version='):
207 elif arg.startswith('release='):
211 return c_version + '-' + c_release
213 return version # Whatever we came up with before
215 # The language for content autogenerated by Sphinx. Refer to documentation
216 # for a list of supported languages.
218 # This is also used if you do content translation via gettext catalogs.
219 # Usually you set "language" from the command line for these cases.
222 # There are two options for replacing |today|: either, you set today to some
223 # non-false value, then it is used:
225 # Else, today_fmt is used as the format for a strftime call.
226 #today_fmt = '%B %d, %Y'
228 # List of patterns, relative to source directory, that match files and
229 # directories to ignore when looking for source files.
230 exclude_patterns = ['output']
232 # The reST default role (used for this markup: `text`) to use for all
236 # If true, '()' will be appended to :func: etc. cross-reference text.
237 #add_function_parentheses = True
239 # If true, the current module name will be prepended to all description
240 # unit titles (such as .. function::).
241 #add_module_names = True
243 # If true, sectionauthor and moduleauthor directives will be shown in the
244 # output. They are ignored by default.
245 #show_authors = False
247 # The name of the Pygments (syntax highlighting) style to use.
248 pygments_style = 'sphinx'
250 # A list of ignored prefixes for module index sorting.
251 #modindex_common_prefix = []
253 # If true, keep warnings as "system message" paragraphs in the built documents.
254 #keep_warnings = False
256 # If true, `todo` and `todoList` produce output, else they produce nothing.
257 todo_include_todos = False
260 highlight_language = 'none'
262 # -- Options for HTML output ----------------------------------------------
264 # The theme to use for HTML and HTML Help pages. See the documentation for
265 # a list of builtin themes.
268 html_theme = 'alabaster'
271 if "DOCS_THEME" in os.environ:
272 html_theme = os.environ["DOCS_THEME"]
274 if html_theme == 'sphinx_rtd_theme' or html_theme == 'sphinx_rtd_dark_mode':
275 # Read the Docs theme
277 import sphinx_rtd_theme
278 html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
280 # Add any paths that contain custom static files (such as style sheets) here,
281 # relative to this directory. They are copied after the builtin static files,
282 # so a file named "default.css" will overwrite the builtin "default.css".
284 'theme_overrides.css',
287 # Read the Docs dark mode override theme
288 if html_theme == 'sphinx_rtd_dark_mode':
290 import sphinx_rtd_dark_mode
291 extensions.append('sphinx_rtd_dark_mode')
293 html_theme == 'sphinx_rtd_theme'
295 if html_theme == 'sphinx_rtd_theme':
296 # Add color-specific RTD normal mode
297 html_css_files.append('theme_rtd_colors.css')
299 html_theme_options = {
300 'navigation_depth': -1,
304 html_theme = 'alabaster'
306 if "DOCS_CSS" in os.environ:
307 css = os.environ["DOCS_CSS"].split(" ")
310 html_css_files.append(l)
312 if major <= 1 and minor < 8:
317 for l in html_css_files:
318 html_context['css_files'].append('_static/' + l)
320 if html_theme == 'alabaster':
321 html_theme_options = {
322 'description': get_cline_version(),
323 'page_width': '65em',
324 'sidebar_width': '15em',
325 'font_size': 'inherit',
326 'font_family': 'serif',
329 sys.stderr.write("Using %s theme\n" % html_theme)
331 # Add any paths that contain custom static files (such as style sheets) here,
332 # relative to this directory. They are copied after the builtin static files,
333 # so a file named "default.css" will overwrite the builtin "default.css".
334 html_static_path = ['sphinx-static']
336 # If true, SmartyPants will be used to convert quotes and dashes to
337 # typographically correct entities.
338 html_use_smartypants = False
340 # Custom sidebar templates, maps document names to template names.
341 # Note that the RTD theme ignores this
342 html_sidebars = { '**': ["about.html", 'searchbox.html', 'localtoc.html', 'sourcelink.html']}
344 # Output file base name for HTML help builder.
345 htmlhelp_basename = 'TheLinuxKerneldoc'
347 # -- Options for LaTeX output ---------------------------------------------
350 # The paper size ('letterpaper' or 'a4paper').
351 'papersize': 'a4paper',
353 # The font size ('10pt', '11pt' or '12pt').
356 # Latex figure (float) alignment
357 #'figure_align': 'htbp',
359 # Don't mangle with UTF-8 chars
363 # Set document margins
365 hmargin=0.5in, vmargin=1in,
366 parsedliteralwraps=true,
367 verbatimhintsturnover=false,
370 # For CJK One-half spacing, need to be in front of hyperref
371 'extrapackages': r'\usepackage{setspace}',
373 # Additional stuff for the LaTeX preamble.
375 % Use some font with UTF-8 support with XeLaTeX
376 \\usepackage{fontspec}
377 \\setsansfont{DejaVu Sans}
378 \\setromanfont{DejaVu Serif}
379 \\setmonofont{DejaVu Sans Mono}
383 # Fix reference escape troubles with Sphinx 1.4.x
385 latex_elements['preamble'] += '\\renewcommand*{\\DUrole}[2]{ #2 }\n'
388 # Load kerneldoc specific LaTeX settings
389 latex_elements['preamble'] += '''
390 % Load kerneldoc specific LaTeX settings
391 \\input{kerneldoc-preamble.sty}
394 # With Sphinx 1.6, it is possible to change the Bg color directly
396 # \definecolor{sphinxnoteBgColor}{RGB}{204,255,255}
397 # \definecolor{sphinxwarningBgColor}{RGB}{255,204,204}
398 # \definecolor{sphinxattentionBgColor}{RGB}{255,255,204}
399 # \definecolor{sphinximportantBgColor}{RGB}{192,255,204}
401 # However, it require to use sphinx heavy box with:
403 # \renewenvironment{sphinxlightbox} {%
404 # \\begin{sphinxheavybox}
406 # \\end{sphinxheavybox}
409 # Unfortunately, the implementation is buggy: if a note is inside a
410 # table, it isn't displayed well. So, for now, let's use boring
411 # black and white notes.
413 # Grouping the document tree into LaTeX files. List of tuples
414 # (source start file, target name, title,
415 # author, documentclass [howto, manual, or own class]).
416 # Sorted in alphabetical order
420 # Add all other index files from Documentation/ subdirectories
421 for fn in os.listdir('.'):
422 doc = os.path.join(fn, "index")
423 if os.path.exists(doc + ".rst"):
425 for l in latex_documents:
430 latex_documents.append((doc, fn + '.tex',
431 'Linux %s Documentation' % fn.capitalize(),
432 'The kernel development community',
435 # The name of an image file (relative to this directory) to place at the top of
439 # For "manual" documents, if this is true, then toplevel headings are parts,
441 #latex_use_parts = False
443 # If true, show page references after internal links.
444 #latex_show_pagerefs = False
446 # If true, show URL addresses after external links.
447 #latex_show_urls = False
449 # Documents to append as an appendix to all manuals.
450 #latex_appendices = []
452 # If false, no module index is generated.
453 #latex_domain_indices = True
455 # Additional LaTeX stuff to be copied to build directory
456 latex_additional_files = [
457 'sphinx/kerneldoc-preamble.sty',
461 # -- Options for manual page output ---------------------------------------
463 # One entry per manual page. List of tuples
464 # (source start file, name, description, authors, manual section).
466 (master_doc, 'thelinuxkernel', 'The Linux Kernel Documentation',
470 # If true, show URL addresses after external links.
471 #man_show_urls = False
474 # -- Options for Texinfo output -------------------------------------------
476 # Grouping the document tree into Texinfo files. List of tuples
477 # (source start file, target name, title, author,
478 # dir menu entry, description, category)
479 texinfo_documents = [
480 (master_doc, 'TheLinuxKernel', 'The Linux Kernel Documentation',
481 author, 'TheLinuxKernel', 'One line description of project.',
485 # -- Options for Epub output ----------------------------------------------
487 # Bibliographic Dublin Core info.
490 epub_publisher = author
491 epub_copyright = copyright
493 # A list of files that should not be packed into the epub file.
494 epub_exclude_files = ['search.html']
499 # Grouping the document tree into PDF files. List of tuples
500 # (source start file, target name, title, author, options).
502 # See the Sphinx chapter of https://ralsina.me/static/manual.pdf
504 # FIXME: Do not add the index file here; the result will be too big. Adding
505 # multiple PDF files here actually tries to get the cross-referencing right
506 # *between* PDF files.
508 ('kernel-documentation', u'Kernel', u'Kernel', u'J. Random Bozo'),
511 # kernel-doc extension configuration for running Sphinx directly (e.g. by Read
512 # the Docs). In a normal build, these are supplied from the Makefile via command
514 kerneldoc_bin = '../scripts/kernel-doc'
515 kerneldoc_srctree = '..'
517 # ------------------------------------------------------------------------------
518 # Since loadConfig overwrites settings from the global namespace, it has to be
519 # the last statement in the conf.py file
520 # ------------------------------------------------------------------------------
521 loadConfig(globals())