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