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