xref: /linux/Documentation/conf.py (revision 2da68a77)
1# -*- coding: utf-8 -*-
2#
3# The Linux Kernel documentation build configuration file, created by
4# sphinx-quickstart on Fri Feb 12 13:51:46 2016.
5#
6# This file is execfile()d with the current directory set to its
7# containing dir.
8#
9# Note that not all possible configuration values are present in this
10# autogenerated file.
11#
12# All configuration values have a default; values that are commented out
13# serve to show the default.
14
15import sys
16import os
17import sphinx
18import shutil
19
20# helper
21# ------
22
23def have_command(cmd):
24    """Search ``cmd`` in the ``PATH`` environment.
25
26    If found, return True.
27    If not found, return False.
28    """
29    return shutil.which(cmd) is not None
30
31# Get Sphinx version
32major, minor, patch = sphinx.version_info[:3]
33
34
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.
38sys.path.insert(0, os.path.abspath('sphinx'))
39from load_config import loadConfig
40
41# -- General configuration ------------------------------------------------
42
43# If your documentation needs a minimal Sphinx version, state it here.
44needs_sphinx = '1.7'
45
46# Add any Sphinx extension module names here, as strings. They can be
47# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
48# ones.
49extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
50              'kfigure', 'sphinx.ext.ifconfig', 'automarkup',
51              'maintainers_include', 'sphinx.ext.autosectionlabel',
52              'kernel_abi', 'kernel_feat']
53
54if major >= 3:
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
59        c_id_attributes = [
60            # GCC Compiler types not parsed by Sphinx:
61            "__restrict__",
62
63            # include/linux/compiler_types.h:
64            "__iomem",
65            "__kernel",
66            "noinstr",
67            "notrace",
68            "__percpu",
69            "__rcu",
70            "__user",
71
72            # include/linux/compiler_attributes.h:
73            "__alias",
74            "__aligned",
75            "__aligned_largest",
76            "__always_inline",
77            "__assume_aligned",
78            "__cold",
79            "__attribute_const__",
80            "__copy",
81            "__pure",
82            "__designated_init",
83            "__visible",
84            "__printf",
85            "__scanf",
86            "__gnu_inline",
87            "__malloc",
88            "__mode",
89            "__no_caller_saved_registers",
90            "__noclone",
91            "__nonstring",
92            "__noreturn",
93            "__packed",
94            "__pure",
95            "__section",
96            "__always_unused",
97            "__maybe_unused",
98            "__used",
99            "__weak",
100            "noinline",
101            "__fix_address",
102
103            # include/linux/memblock.h:
104            "__init_memblock",
105            "__meminit",
106
107            # include/linux/init.h:
108            "__init",
109            "__ref",
110
111            # include/linux/linkage.h:
112            "asmlinkage",
113        ]
114
115else:
116    extensions.append('cdomain')
117
118# Ensure that autosectionlabel will produce unique names
119autosectionlabel_prefix_document = True
120autosectionlabel_maxdepth = 2
121
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.
125have_latex =  have_command('latex')
126have_dvipng = have_command('dvipng')
127load_imgmath = have_latex and have_dvipng
128
129# Respect SPHINX_IMGMATH (for html docs only)
130if 'SPHINX_IMGMATH' in os.environ:
131    env_sphinx_imgmath = os.environ['SPHINX_IMGMATH']
132    if 'yes' in env_sphinx_imgmath:
133        load_imgmath = True
134    elif 'no' in env_sphinx_imgmath:
135        load_imgmath = False
136    else:
137        sys.stderr.write("Unknown env SPHINX_IMGMATH=%s ignored.\n" % env_sphinx_imgmath)
138
139# Always load imgmath for Sphinx <1.8 or for epub docs
140load_imgmath = (load_imgmath or (major == 1 and minor < 8)
141                or 'epub' in sys.argv)
142
143if load_imgmath:
144    extensions.append("sphinx.ext.imgmath")
145    math_renderer = 'imgmath'
146else:
147    math_renderer = 'mathjax'
148
149# Add any paths that contain templates here, relative to this directory.
150templates_path = ['_templates']
151
152# The suffix(es) of source filenames.
153# You can specify multiple suffix as a list of string:
154# source_suffix = ['.rst', '.md']
155source_suffix = '.rst'
156
157# The encoding of source files.
158#source_encoding = 'utf-8-sig'
159
160# The master toctree document.
161master_doc = 'index'
162
163# General information about the project.
164project = 'The Linux Kernel'
165copyright = 'The kernel development community'
166author = 'The kernel development community'
167
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
170# built documents.
171#
172# In a normal build, version and release are are set to KERNELVERSION and
173# KERNELRELEASE, respectively, from the Makefile via Sphinx command line
174# arguments.
175#
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).
178try:
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)]
183        if key == 'VERSION':
184            makefile_version = val
185        elif key == 'PATCHLEVEL':
186            makefile_patchlevel = val
187        if makefile_version and makefile_patchlevel:
188            break
189except:
190    pass
191finally:
192    if makefile_version and makefile_patchlevel:
193        version = release = makefile_version + '.' + makefile_patchlevel
194    else:
195        version = release = "unknown version"
196
197# The language for content autogenerated by Sphinx. Refer to documentation
198# for a list of supported languages.
199#
200# This is also used if you do content translation via gettext catalogs.
201# Usually you set "language" from the command line for these cases.
202language = 'en'
203
204# There are two options for replacing |today|: either, you set today to some
205# non-false value, then it is used:
206#today = ''
207# Else, today_fmt is used as the format for a strftime call.
208#today_fmt = '%B %d, %Y'
209
210# List of patterns, relative to source directory, that match files and
211# directories to ignore when looking for source files.
212exclude_patterns = ['output']
213
214# The reST default role (used for this markup: `text`) to use for all
215# documents.
216#default_role = None
217
218# If true, '()' will be appended to :func: etc. cross-reference text.
219#add_function_parentheses = True
220
221# If true, the current module name will be prepended to all description
222# unit titles (such as .. function::).
223#add_module_names = True
224
225# If true, sectionauthor and moduleauthor directives will be shown in the
226# output. They are ignored by default.
227#show_authors = False
228
229# The name of the Pygments (syntax highlighting) style to use.
230pygments_style = 'sphinx'
231
232# A list of ignored prefixes for module index sorting.
233#modindex_common_prefix = []
234
235# If true, keep warnings as "system message" paragraphs in the built documents.
236#keep_warnings = False
237
238# If true, `todo` and `todoList` produce output, else they produce nothing.
239todo_include_todos = False
240
241primary_domain = 'c'
242highlight_language = 'none'
243
244# -- Options for HTML output ----------------------------------------------
245
246# The theme to use for HTML and HTML Help pages.  See the documentation for
247# a list of builtin themes.
248
249# Default theme
250html_theme = 'sphinx_rtd_theme'
251html_css_files = []
252
253if "DOCS_THEME" in os.environ:
254    html_theme = os.environ["DOCS_THEME"]
255
256if html_theme == 'sphinx_rtd_theme' or html_theme == 'sphinx_rtd_dark_mode':
257    # Read the Docs theme
258    try:
259        import sphinx_rtd_theme
260        html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
261
262        # Add any paths that contain custom static files (such as style sheets) here,
263        # relative to this directory. They are copied after the builtin static files,
264        # so a file named "default.css" will overwrite the builtin "default.css".
265        html_css_files = [
266            'theme_overrides.css',
267        ]
268
269        # Read the Docs dark mode override theme
270        if html_theme == 'sphinx_rtd_dark_mode':
271            try:
272                import sphinx_rtd_dark_mode
273                extensions.append('sphinx_rtd_dark_mode')
274            except ImportError:
275                html_theme == 'sphinx_rtd_theme'
276
277        if html_theme == 'sphinx_rtd_theme':
278                # Add color-specific RTD normal mode
279                html_css_files.append('theme_rtd_colors.css')
280
281    except ImportError:
282        html_theme = 'classic'
283
284if "DOCS_CSS" in os.environ:
285    css = os.environ["DOCS_CSS"].split(" ")
286
287    for l in css:
288        html_css_files.append(l)
289
290if major <= 1 and minor < 8:
291    html_context = {
292        'css_files': [],
293    }
294
295    for l in html_css_files:
296        html_context['css_files'].append('_static/' + l)
297
298if  html_theme == 'classic':
299    html_theme_options = {
300        'rightsidebar':        False,
301        'stickysidebar':       True,
302        'collapsiblesidebar':  True,
303        'externalrefs':        False,
304
305        'footerbgcolor':       "white",
306        'footertextcolor':     "white",
307        'sidebarbgcolor':      "white",
308        'sidebarbtncolor':     "black",
309        'sidebartextcolor':    "black",
310        'sidebarlinkcolor':    "#686bff",
311        'relbarbgcolor':       "#133f52",
312        'relbartextcolor':     "white",
313        'relbarlinkcolor':     "white",
314        'bgcolor':             "white",
315        'textcolor':           "black",
316        'headbgcolor':         "#f2f2f2",
317        'headtextcolor':       "#20435c",
318        'headlinkcolor':       "#c60f0f",
319        'linkcolor':           "#355f7c",
320        'visitedlinkcolor':    "#355f7c",
321        'codebgcolor':         "#3f3f3f",
322        'codetextcolor':       "white",
323
324        'bodyfont':            "serif",
325        'headfont':            "sans-serif",
326    }
327
328sys.stderr.write("Using %s theme\n" % html_theme)
329
330# Theme options are theme-specific and customize the look and feel of a theme
331# further.  For a list of options available for each theme, see the
332# documentation.
333#html_theme_options = {}
334
335# Add any paths that contain custom themes here, relative to this directory.
336#html_theme_path = []
337
338# The name for this set of Sphinx documents.  If None, it defaults to
339# "<project> v<release> documentation".
340#html_title = None
341
342# A shorter title for the navigation bar.  Default is the same as html_title.
343#html_short_title = None
344
345# The name of an image file (relative to this directory) to place at the top
346# of the sidebar.
347#html_logo = None
348
349# The name of an image file (within the static path) to use as favicon of the
350# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
351# pixels large.
352#html_favicon = None
353
354# Add any paths that contain custom static files (such as style sheets) here,
355# relative to this directory. They are copied after the builtin static files,
356# so a file named "default.css" will overwrite the builtin "default.css".
357html_static_path = ['sphinx-static']
358
359# Add any extra paths that contain custom files (such as robots.txt or
360# .htaccess) here, relative to this directory. These files are copied
361# directly to the root of the documentation.
362#html_extra_path = []
363
364# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
365# using the given strftime format.
366#html_last_updated_fmt = '%b %d, %Y'
367
368# If true, SmartyPants will be used to convert quotes and dashes to
369# typographically correct entities.
370html_use_smartypants = False
371
372# Custom sidebar templates, maps document names to template names.
373# Note that the RTD theme ignores this.
374html_sidebars = { '**': ['searchbox.html', 'localtoc.html', 'sourcelink.html']}
375
376# Additional templates that should be rendered to pages, maps page names to
377# template names.
378#html_additional_pages = {}
379
380# If false, no module index is generated.
381#html_domain_indices = True
382
383# If false, no index is generated.
384#html_use_index = True
385
386# If true, the index is split into individual pages for each letter.
387#html_split_index = False
388
389# If true, links to the reST sources are added to the pages.
390#html_show_sourcelink = True
391
392# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
393#html_show_sphinx = True
394
395# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
396#html_show_copyright = True
397
398# If true, an OpenSearch description file will be output, and all pages will
399# contain a <link> tag referring to it.  The value of this option must be the
400# base URL from which the finished HTML is served.
401#html_use_opensearch = ''
402
403# This is the file name suffix for HTML files (e.g. ".xhtml").
404#html_file_suffix = None
405
406# Language to be used for generating the HTML full-text search index.
407# Sphinx supports the following languages:
408#   'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
409#   'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
410#html_search_language = 'en'
411
412# A dictionary with options for the search language support, empty by default.
413# Now only 'ja' uses this config value
414#html_search_options = {'type': 'default'}
415
416# The name of a javascript file (relative to the configuration directory) that
417# implements a search results scorer. If empty, the default will be used.
418#html_search_scorer = 'scorer.js'
419
420# Output file base name for HTML help builder.
421htmlhelp_basename = 'TheLinuxKerneldoc'
422
423# -- Options for LaTeX output ---------------------------------------------
424
425latex_elements = {
426    # The paper size ('letterpaper' or 'a4paper').
427    'papersize': 'a4paper',
428
429    # The font size ('10pt', '11pt' or '12pt').
430    'pointsize': '11pt',
431
432    # Latex figure (float) alignment
433    #'figure_align': 'htbp',
434
435    # Don't mangle with UTF-8 chars
436    'inputenc': '',
437    'utf8extra': '',
438
439    # Set document margins
440    'sphinxsetup': '''
441        hmargin=0.5in, vmargin=1in,
442        parsedliteralwraps=true,
443        verbatimhintsturnover=false,
444    ''',
445
446    # For CJK One-half spacing, need to be in front of hyperref
447    'extrapackages': r'\usepackage{setspace}',
448
449    # Additional stuff for the LaTeX preamble.
450    'preamble': '''
451        % Use some font with UTF-8 support with XeLaTeX
452        \\usepackage{fontspec}
453        \\setsansfont{DejaVu Sans}
454        \\setromanfont{DejaVu Serif}
455        \\setmonofont{DejaVu Sans Mono}
456    ''',
457}
458
459# Fix reference escape troubles with Sphinx 1.4.x
460if major == 1:
461    latex_elements['preamble']  += '\\renewcommand*{\\DUrole}[2]{ #2 }\n'
462
463
464# Load kerneldoc specific LaTeX settings
465latex_elements['preamble'] += '''
466        % Load kerneldoc specific LaTeX settings
467	\\input{kerneldoc-preamble.sty}
468'''
469
470# With Sphinx 1.6, it is possible to change the Bg color directly
471# by using:
472#	\definecolor{sphinxnoteBgColor}{RGB}{204,255,255}
473#	\definecolor{sphinxwarningBgColor}{RGB}{255,204,204}
474#	\definecolor{sphinxattentionBgColor}{RGB}{255,255,204}
475#	\definecolor{sphinximportantBgColor}{RGB}{192,255,204}
476#
477# However, it require to use sphinx heavy box with:
478#
479#	\renewenvironment{sphinxlightbox} {%
480#		\\begin{sphinxheavybox}
481#	}
482#		\\end{sphinxheavybox}
483#	}
484#
485# Unfortunately, the implementation is buggy: if a note is inside a
486# table, it isn't displayed well. So, for now, let's use boring
487# black and white notes.
488
489# Grouping the document tree into LaTeX files. List of tuples
490# (source start file, target name, title,
491#  author, documentclass [howto, manual, or own class]).
492# Sorted in alphabetical order
493latex_documents = [
494]
495
496# Add all other index files from Documentation/ subdirectories
497for fn in os.listdir('.'):
498    doc = os.path.join(fn, "index")
499    if os.path.exists(doc + ".rst"):
500        has = False
501        for l in latex_documents:
502            if l[0] == doc:
503                has = True
504                break
505        if not has:
506            latex_documents.append((doc, fn + '.tex',
507                                    'Linux %s Documentation' % fn.capitalize(),
508                                    'The kernel development community',
509                                    'manual'))
510
511# The name of an image file (relative to this directory) to place at the top of
512# the title page.
513#latex_logo = None
514
515# For "manual" documents, if this is true, then toplevel headings are parts,
516# not chapters.
517#latex_use_parts = False
518
519# If true, show page references after internal links.
520#latex_show_pagerefs = False
521
522# If true, show URL addresses after external links.
523#latex_show_urls = False
524
525# Documents to append as an appendix to all manuals.
526#latex_appendices = []
527
528# If false, no module index is generated.
529#latex_domain_indices = True
530
531# Additional LaTeX stuff to be copied to build directory
532latex_additional_files = [
533    'sphinx/kerneldoc-preamble.sty',
534]
535
536
537# -- Options for manual page output ---------------------------------------
538
539# One entry per manual page. List of tuples
540# (source start file, name, description, authors, manual section).
541man_pages = [
542    (master_doc, 'thelinuxkernel', 'The Linux Kernel Documentation',
543     [author], 1)
544]
545
546# If true, show URL addresses after external links.
547#man_show_urls = False
548
549
550# -- Options for Texinfo output -------------------------------------------
551
552# Grouping the document tree into Texinfo files. List of tuples
553# (source start file, target name, title, author,
554#  dir menu entry, description, category)
555texinfo_documents = [
556    (master_doc, 'TheLinuxKernel', 'The Linux Kernel Documentation',
557     author, 'TheLinuxKernel', 'One line description of project.',
558     'Miscellaneous'),
559]
560
561# Documents to append as an appendix to all manuals.
562#texinfo_appendices = []
563
564# If false, no module index is generated.
565#texinfo_domain_indices = True
566
567# How to display URL addresses: 'footnote', 'no', or 'inline'.
568#texinfo_show_urls = 'footnote'
569
570# If true, do not generate a @detailmenu in the "Top" node's menu.
571#texinfo_no_detailmenu = False
572
573
574# -- Options for Epub output ----------------------------------------------
575
576# Bibliographic Dublin Core info.
577epub_title = project
578epub_author = author
579epub_publisher = author
580epub_copyright = copyright
581
582# The basename for the epub file. It defaults to the project name.
583#epub_basename = project
584
585# The HTML theme for the epub output. Since the default themes are not
586# optimized for small screen space, using the same theme for HTML and epub
587# output is usually not wise. This defaults to 'epub', a theme designed to save
588# visual space.
589#epub_theme = 'epub'
590
591# The language of the text. It defaults to the language option
592# or 'en' if the language is not set.
593#epub_language = ''
594
595# The scheme of the identifier. Typical schemes are ISBN or URL.
596#epub_scheme = ''
597
598# The unique identifier of the text. This can be a ISBN number
599# or the project homepage.
600#epub_identifier = ''
601
602# A unique identification for the text.
603#epub_uid = ''
604
605# A tuple containing the cover image and cover page html template filenames.
606#epub_cover = ()
607
608# A sequence of (type, uri, title) tuples for the guide element of content.opf.
609#epub_guide = ()
610
611# HTML files that should be inserted before the pages created by sphinx.
612# The format is a list of tuples containing the path and title.
613#epub_pre_files = []
614
615# HTML files that should be inserted after the pages created by sphinx.
616# The format is a list of tuples containing the path and title.
617#epub_post_files = []
618
619# A list of files that should not be packed into the epub file.
620epub_exclude_files = ['search.html']
621
622# The depth of the table of contents in toc.ncx.
623#epub_tocdepth = 3
624
625# Allow duplicate toc entries.
626#epub_tocdup = True
627
628# Choose between 'default' and 'includehidden'.
629#epub_tocscope = 'default'
630
631# Fix unsupported image types using the Pillow.
632#epub_fix_images = False
633
634# Scale large images.
635#epub_max_image_width = 0
636
637# How to display URL addresses: 'footnote', 'no', or 'inline'.
638#epub_show_urls = 'inline'
639
640# If false, no index is generated.
641#epub_use_index = True
642
643#=======
644# rst2pdf
645#
646# Grouping the document tree into PDF files. List of tuples
647# (source start file, target name, title, author, options).
648#
649# See the Sphinx chapter of https://ralsina.me/static/manual.pdf
650#
651# FIXME: Do not add the index file here; the result will be too big. Adding
652# multiple PDF files here actually tries to get the cross-referencing right
653# *between* PDF files.
654pdf_documents = [
655    ('kernel-documentation', u'Kernel', u'Kernel', u'J. Random Bozo'),
656]
657
658# kernel-doc extension configuration for running Sphinx directly (e.g. by Read
659# the Docs). In a normal build, these are supplied from the Makefile via command
660# line arguments.
661kerneldoc_bin = '../scripts/kernel-doc'
662kerneldoc_srctree = '..'
663
664# ------------------------------------------------------------------------------
665# Since loadConfig overwrites settings from the global namespace, it has to be
666# the last statement in the conf.py file
667# ------------------------------------------------------------------------------
668loadConfig(globals())
669