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