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.
19 from subprocess
import check_output
22 major
, minor
, patch
= sphinx
.version_info
[:3]
25 # If extensions (or modules to document with autodoc) are in another directory,
26 # add these directories to sys.path here. If the directory is relative to the
27 # documentation root, use os.path.abspath to make it absolute, like shown here.
28 sys
.path
.insert(0, os
.path
.abspath('sphinx'))
29 from load_config
import loadConfig
31 # -- General configuration ------------------------------------------------
33 # If your documentation needs a minimal Sphinx version, state it here.
36 # Add any Sphinx extension module names here, as strings. They can be
37 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
39 extensions
= ['kerneldoc', 'rstFlatTable', 'kernel_include',
40 'kfigure', 'sphinx.ext.ifconfig', 'automarkup',
41 'maintainers_include', 'sphinx.ext.autosectionlabel',
42 'kernel_abi', 'kernel_feat']
45 # cdomain is badly broken in Sphinx 3+. Leaving it out generates *most*
46 # of the docs correctly, but not all. Scream bloody murder but allow
47 # the process to proceed; hopefully somebody will fix this properly soon.
50 sys
.stderr
.write('''WARNING: The kernel documentation build process
51 support for Sphinx v3.0 and above is brand new. Be prepared for
52 possible issues in the generated output.
54 if (major
> 3) or (minor
> 0 or patch
>= 2):
55 # Sphinx c function parser is more pedantic with regards to type
56 # checking. Due to that, having macros at c:function cause problems.
57 # Those needed to be scaped by using c_id_attributes[] array
59 # GCC Compiler types not parsed by Sphinx:
62 # include/linux/compiler_types.h:
71 # include/linux/compiler_attributes.h:
78 "__attribute_const__",
88 "__no_caller_saved_registers",
101 # include/linux/memblock.h:
105 # include/linux/init.h:
109 # include/linux/linkage.h:
114 extensions
.append('cdomain')
115 if major
== 1 and minor
< 7:
116 sys
.stderr
.write('WARNING: Sphinx 1.7 or greater will be required as of '
117 'the 5.12 release\n')
119 # Ensure that autosectionlabel will produce unique names
120 autosectionlabel_prefix_document
= True
121 autosectionlabel_maxdepth
= 2
123 # The name of the math extension changed on Sphinx 1.4
124 if (major
== 1 and minor
> 3) or (major
> 1):
125 extensions
.append("sphinx.ext.imgmath")
127 extensions
.append("sphinx.ext.pngmath")
129 # Add any paths that contain templates here, relative to this directory.
130 templates_path
= ['_templates']
132 # The suffix(es) of source filenames.
133 # You can specify multiple suffix as a list of string:
134 # source_suffix = ['.rst', '.md']
135 source_suffix
= '.rst'
137 # The encoding of source files.
138 #source_encoding = 'utf-8-sig'
140 # The master toctree document.
143 # General information about the project.
144 project
= 'The Linux Kernel'
145 copyright
= 'The kernel development community'
146 author
= 'The kernel development community'
148 # The version info for the project you're documenting, acts as replacement for
149 # |version| and |release|, also used in various other places throughout the
152 # In a normal build, version and release are are set to KERNELVERSION and
153 # KERNELRELEASE, respectively, from the Makefile via Sphinx command line
156 # The following code tries to extract the information by reading the Makefile,
157 # when Sphinx is run directly (e.g. by Read the Docs).
159 makefile_version
= None
160 makefile_patchlevel
= None
161 for line
in open('../Makefile'):
162 key
, val
= [x
.strip() for x
in line
.split('=', 2)]
164 makefile_version
= val
165 elif key
== 'PATCHLEVEL':
166 makefile_patchlevel
= val
167 if makefile_version
and makefile_patchlevel
:
172 if makefile_version
and makefile_patchlevel
:
173 version
= release
= makefile_version
+ '.' + makefile_patchlevel
175 version
= release
= "unknown version"
177 # The language for content autogenerated by Sphinx. Refer to documentation
178 # for a list of supported languages.
180 # This is also used if you do content translation via gettext catalogs.
181 # Usually you set "language" from the command line for these cases.
184 # There are two options for replacing |today|: either, you set today to some
185 # non-false value, then it is used:
187 # Else, today_fmt is used as the format for a strftime call.
188 #today_fmt = '%B %d, %Y'
190 # List of patterns, relative to source directory, that match files and
191 # directories to ignore when looking for source files.
192 exclude_patterns
= ['output']
194 # The reST default role (used for this markup: `text`) to use for all
198 # If true, '()' will be appended to :func: etc. cross-reference text.
199 #add_function_parentheses = True
201 # If true, the current module name will be prepended to all description
202 # unit titles (such as .. function::).
203 #add_module_names = True
205 # If true, sectionauthor and moduleauthor directives will be shown in the
206 # output. They are ignored by default.
207 #show_authors = False
209 # The name of the Pygments (syntax highlighting) style to use.
210 pygments_style
= 'sphinx'
212 # A list of ignored prefixes for module index sorting.
213 #modindex_common_prefix = []
215 # If true, keep warnings as "system message" paragraphs in the built documents.
216 #keep_warnings = False
218 # If true, `todo` and `todoList` produce output, else they produce nothing.
219 todo_include_todos
= False
222 highlight_language
= 'none'
224 # -- Options for HTML output ----------------------------------------------
226 # The theme to use for HTML and HTML Help pages. See the documentation for
227 # a list of builtin themes.
229 # The Read the Docs theme is available from
230 # - https://github.com/snide/sphinx_rtd_theme
231 # - https://pypi.python.org/pypi/sphinx_rtd_theme
232 # - python-sphinx-rtd-theme package (on Debian)
234 import sphinx_rtd_theme
235 html_theme
= 'sphinx_rtd_theme'
236 html_theme_path
= [sphinx_rtd_theme
.get_html_theme_path()]
238 sys
.stderr
.write('Warning: The Sphinx \'sphinx_rtd_theme\' HTML theme was not found. Make sure you have the theme installed to produce pretty HTML output. Falling back to the default theme.\n')
240 # Theme options are theme-specific and customize the look and feel of a theme
241 # further. For a list of options available for each theme, see the
243 #html_theme_options = {}
245 # Add any paths that contain custom themes here, relative to this directory.
246 #html_theme_path = []
248 # The name for this set of Sphinx documents. If None, it defaults to
249 # "<project> v<release> documentation".
252 # A shorter title for the navigation bar. Default is the same as html_title.
253 #html_short_title = None
255 # The name of an image file (relative to this directory) to place at the top
259 # The name of an image file (within the static path) to use as favicon of the
260 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
264 # Add any paths that contain custom static files (such as style sheets) here,
265 # relative to this directory. They are copied after the builtin static files,
266 # so a file named "default.css" will overwrite the builtin "default.css".
268 html_static_path
= ['sphinx-static']
272 '_static/theme_overrides.css',
276 # Add any extra paths that contain custom files (such as robots.txt or
277 # .htaccess) here, relative to this directory. These files are copied
278 # directly to the root of the documentation.
279 #html_extra_path = []
281 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
282 # using the given strftime format.
283 #html_last_updated_fmt = '%b %d, %Y'
285 # If true, SmartyPants will be used to convert quotes and dashes to
286 # typographically correct entities.
287 html_use_smartypants
= False
289 # Custom sidebar templates, maps document names to template names.
292 # Additional templates that should be rendered to pages, maps page names to
294 #html_additional_pages = {}
296 # If false, no module index is generated.
297 #html_domain_indices = True
299 # If false, no index is generated.
300 #html_use_index = True
302 # If true, the index is split into individual pages for each letter.
303 #html_split_index = False
305 # If true, links to the reST sources are added to the pages.
306 #html_show_sourcelink = True
308 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
309 #html_show_sphinx = True
311 # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
312 #html_show_copyright = True
314 # If true, an OpenSearch description file will be output, and all pages will
315 # contain a <link> tag referring to it. The value of this option must be the
316 # base URL from which the finished HTML is served.
317 #html_use_opensearch = ''
319 # This is the file name suffix for HTML files (e.g. ".xhtml").
320 #html_file_suffix = None
322 # Language to be used for generating the HTML full-text search index.
323 # Sphinx supports the following languages:
324 # 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
325 # 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
326 #html_search_language = 'en'
328 # A dictionary with options for the search language support, empty by default.
329 # Now only 'ja' uses this config value
330 #html_search_options = {'type': 'default'}
332 # The name of a javascript file (relative to the configuration directory) that
333 # implements a search results scorer. If empty, the default will be used.
334 #html_search_scorer = 'scorer.js'
336 # Output file base name for HTML help builder.
337 htmlhelp_basename
= 'TheLinuxKerneldoc'
339 # -- Options for LaTeX output ---------------------------------------------
342 # The paper size ('letterpaper' or 'a4paper').
343 'papersize': 'a4paper',
345 # The font size ('10pt', '11pt' or '12pt').
348 # Latex figure (float) alignment
349 #'figure_align': 'htbp',
351 # Don't mangle with UTF-8 chars
355 # Additional stuff for the LaTeX preamble.
357 % Use some font with UTF-8 support with XeLaTeX
358 \\usepackage{fontspec}
359 \\setsansfont{DejaVu Sans}
360 \\setromanfont{DejaVu Serif}
361 \\setmonofont{DejaVu Sans Mono}
365 # At least one book (translations) may have Asian characters
366 # with are only displayed if xeCJK is used
368 cjk_cmd
= check_output(['fc-list', '--format="%{family[0]}\n"']).decode('utf-8', 'ignore')
369 if cjk_cmd
.find("Noto Sans CJK SC") >= 0:
370 print ("enabling CJK for LaTeX builder")
371 latex_elements
['preamble'] += '''
372 % This is needed for translations
374 \\setCJKmainfont{Noto Sans CJK SC}
377 # Fix reference escape troubles with Sphinx 1.4.x
378 if major
== 1 and minor
> 3:
379 latex_elements
['preamble'] += '\\renewcommand*{\\DUrole}[2]{ #2 }\n'
381 if major
== 1 and minor
<= 4:
382 latex_elements
['preamble'] += '\\usepackage[margin=0.5in, top=1in, bottom=1in]{geometry}'
383 elif major
== 1 and (minor
> 5 or (minor
== 5 and patch
>= 3)):
384 latex_elements
['sphinxsetup'] = 'hmargin=0.5in, vmargin=1in'
385 latex_elements
['preamble'] += '\\fvset{fontsize=auto}\n'
387 # Customize notice background colors on Sphinx < 1.6:
388 if major
== 1 and minor
< 6:
389 latex_elements
['preamble'] += '''
392 % Put notes in color and let them be inside a table
393 \\definecolor{NoteColor}{RGB}{204,255,255}
394 \\definecolor{WarningColor}{RGB}{255,204,204}
395 \\definecolor{AttentionColor}{RGB}{255,255,204}
396 \\definecolor{ImportantColor}{RGB}{192,255,204}
397 \\definecolor{OtherColor}{RGB}{204,204,204}
398 \\newlength{\\mynoticelength}
399 \\makeatletter\\newenvironment{coloredbox}[1]{%
400 \\setlength{\\fboxrule}{1pt}
401 \\setlength{\\fboxsep}{7pt}
402 \\setlength{\\mynoticelength}{\\linewidth}
403 \\addtolength{\\mynoticelength}{-2\\fboxsep}
404 \\addtolength{\\mynoticelength}{-2\\fboxrule}
405 \\begin{lrbox}{\\@tempboxa}\\begin{minipage}{\\mynoticelength}}{\\end{minipage}\\end{lrbox}%
407 {\\equal{\\py@noticetype}{note}}%
408 {\\colorbox{NoteColor}{\\usebox{\\@tempboxa}}}%
411 {\\equal{\\py@noticetype}{warning}}%
412 {\\colorbox{WarningColor}{\\usebox{\\@tempboxa}}}%
415 {\\equal{\\py@noticetype}{attention}}%
416 {\\colorbox{AttentionColor}{\\usebox{\\@tempboxa}}}%
419 {\\equal{\\py@noticetype}{important}}%
420 {\\colorbox{ImportantColor}{\\usebox{\\@tempboxa}}}%
421 {\\colorbox{OtherColor}{\\usebox{\\@tempboxa}}}%
428 \\renewenvironment{notice}[2]{%
429 \\def\\py@noticetype{#1}
430 \\begin{coloredbox}{#1}
433 \\csname py@noticestart@#1\\endcsname
436 \\csname py@noticeend@\\py@noticetype\\endcsname
443 # With Sphinx 1.6, it is possible to change the Bg color directly
445 # \definecolor{sphinxnoteBgColor}{RGB}{204,255,255}
446 # \definecolor{sphinxwarningBgColor}{RGB}{255,204,204}
447 # \definecolor{sphinxattentionBgColor}{RGB}{255,255,204}
448 # \definecolor{sphinximportantBgColor}{RGB}{192,255,204}
450 # However, it require to use sphinx heavy box with:
452 # \renewenvironment{sphinxlightbox} {%
453 # \\begin{sphinxheavybox}
455 # \\end{sphinxheavybox}
458 # Unfortunately, the implementation is buggy: if a note is inside a
459 # table, it isn't displayed well. So, for now, let's use boring
460 # black and white notes.
462 # Grouping the document tree into LaTeX files. List of tuples
463 # (source start file, target name, title,
464 # author, documentclass [howto, manual, or own class]).
465 # Sorted in alphabetical order
469 # Add all other index files from Documentation/ subdirectories
470 for fn
in os
.listdir('.'):
471 doc
= os
.path
.join(fn
, "index")
472 if os
.path
.exists(doc
+ ".rst"):
474 for l
in latex_documents
:
479 latex_documents
.append((doc
, fn
+ '.tex',
480 'Linux %s Documentation' % fn
.capitalize(),
481 'The kernel development community',
484 # The name of an image file (relative to this directory) to place at the top of
488 # For "manual" documents, if this is true, then toplevel headings are parts,
490 #latex_use_parts = False
492 # If true, show page references after internal links.
493 #latex_show_pagerefs = False
495 # If true, show URL addresses after external links.
496 #latex_show_urls = False
498 # Documents to append as an appendix to all manuals.
499 #latex_appendices = []
501 # If false, no module index is generated.
502 #latex_domain_indices = True
505 # -- Options for manual page output ---------------------------------------
507 # One entry per manual page. List of tuples
508 # (source start file, name, description, authors, manual section).
510 (master_doc
, 'thelinuxkernel', 'The Linux Kernel Documentation',
514 # If true, show URL addresses after external links.
515 #man_show_urls = False
518 # -- Options for Texinfo output -------------------------------------------
520 # Grouping the document tree into Texinfo files. List of tuples
521 # (source start file, target name, title, author,
522 # dir menu entry, description, category)
523 texinfo_documents
= [
524 (master_doc
, 'TheLinuxKernel', 'The Linux Kernel Documentation',
525 author
, 'TheLinuxKernel', 'One line description of project.',
529 # Documents to append as an appendix to all manuals.
530 #texinfo_appendices = []
532 # If false, no module index is generated.
533 #texinfo_domain_indices = True
535 # How to display URL addresses: 'footnote', 'no', or 'inline'.
536 #texinfo_show_urls = 'footnote'
538 # If true, do not generate a @detailmenu in the "Top" node's menu.
539 #texinfo_no_detailmenu = False
542 # -- Options for Epub output ----------------------------------------------
544 # Bibliographic Dublin Core info.
547 epub_publisher
= author
548 epub_copyright
= copyright
550 # The basename for the epub file. It defaults to the project name.
551 #epub_basename = project
553 # The HTML theme for the epub output. Since the default themes are not
554 # optimized for small screen space, using the same theme for HTML and epub
555 # output is usually not wise. This defaults to 'epub', a theme designed to save
559 # The language of the text. It defaults to the language option
560 # or 'en' if the language is not set.
563 # The scheme of the identifier. Typical schemes are ISBN or URL.
566 # The unique identifier of the text. This can be a ISBN number
567 # or the project homepage.
568 #epub_identifier = ''
570 # A unique identification for the text.
573 # A tuple containing the cover image and cover page html template filenames.
576 # A sequence of (type, uri, title) tuples for the guide element of content.opf.
579 # HTML files that should be inserted before the pages created by sphinx.
580 # The format is a list of tuples containing the path and title.
583 # HTML files that should be inserted after the pages created by sphinx.
584 # The format is a list of tuples containing the path and title.
585 #epub_post_files = []
587 # A list of files that should not be packed into the epub file.
588 epub_exclude_files
= ['search.html']
590 # The depth of the table of contents in toc.ncx.
593 # Allow duplicate toc entries.
596 # Choose between 'default' and 'includehidden'.
597 #epub_tocscope = 'default'
599 # Fix unsupported image types using the Pillow.
600 #epub_fix_images = False
602 # Scale large images.
603 #epub_max_image_width = 0
605 # How to display URL addresses: 'footnote', 'no', or 'inline'.
606 #epub_show_urls = 'inline'
608 # If false, no index is generated.
609 #epub_use_index = True
614 # Grouping the document tree into PDF files. List of tuples
615 # (source start file, target name, title, author, options).
617 # See the Sphinx chapter of https://ralsina.me/static/manual.pdf
619 # FIXME: Do not add the index file here; the result will be too big. Adding
620 # multiple PDF files here actually tries to get the cross-referencing right
621 # *between* PDF files.
623 ('kernel-documentation', u
'Kernel', u
'Kernel', u
'J. Random Bozo'),
626 # kernel-doc extension configuration for running Sphinx directly (e.g. by Read
627 # the Docs). In a normal build, these are supplied from the Makefile via command
629 kerneldoc_bin
= '../scripts/kernel-doc'
630 kerneldoc_srctree
= '..'
632 # ------------------------------------------------------------------------------
633 # Since loadConfig overwrites settings from the global namespace, it has to be
634 # the last statement in the conf.py file
635 # ------------------------------------------------------------------------------
636 loadConfig(globals())