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