Commit | Line | Data |
---|---|---|
22cba31b JN |
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 | ||
15 | import sys | |
16 | import os | |
d4fe7e14 | 17 | import sphinx |
6b0d3e7c AY |
18 | import shutil |
19 | ||
20 | # helper | |
21 | # ------ | |
22 | ||
23 | def 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 | |
d4fe7e14 MCC |
30 | |
31 | # Get Sphinx version | |
c46988ae | 32 | major, minor, patch = sphinx.version_info[:3] |
d4fe7e14 | 33 | |
31abfdda JC |
34 | # |
35 | # Warn about older versions that we don't want to support for much | |
36 | # longer. | |
37 | # | |
38 | if (major < 2) or (major == 2 and minor < 4): | |
39 | print('WARNING: support for Sphinx < 2.4 will be removed soon.') | |
22cba31b JN |
40 | |
41 | # If extensions (or modules to document with autodoc) are in another directory, | |
42 | # add these directories to sys.path here. If the directory is relative to the | |
43 | # documentation root, use os.path.abspath to make it absolute, like shown here. | |
24dcdeb2 | 44 | sys.path.insert(0, os.path.abspath('sphinx')) |
606b9ac8 | 45 | from load_config import loadConfig |
22cba31b JN |
46 | |
47 | # -- General configuration ------------------------------------------------ | |
48 | ||
49 | # If your documentation needs a minimal Sphinx version, state it here. | |
3e893e16 | 50 | needs_sphinx = '2.4.4' |
22cba31b JN |
51 | |
52 | # Add any Sphinx extension module names here, as strings. They can be | |
53 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | |
54 | # ones. | |
afde706a | 55 | extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', |
aa204855 | 56 | 'kfigure', 'sphinx.ext.ifconfig', 'automarkup', |
a7ee04b3 | 57 | 'maintainers_include', 'sphinx.ext.autosectionlabel', |
63fdc462 | 58 | 'kernel_abi', 'kernel_feat'] |
22cba31b | 59 | |
afde706a | 60 | if major >= 3: |
d29f34c0 | 61 | if (major > 3) or (minor > 0 or patch >= 2): |
b34b86d7 MCC |
62 | # Sphinx c function parser is more pedantic with regards to type |
63 | # checking. Due to that, having macros at c:function cause problems. | |
64 | # Those needed to be scaped by using c_id_attributes[] array | |
65 | c_id_attributes = [ | |
66 | # GCC Compiler types not parsed by Sphinx: | |
67 | "__restrict__", | |
68 | ||
69 | # include/linux/compiler_types.h: | |
70 | "__iomem", | |
71 | "__kernel", | |
72 | "noinstr", | |
73 | "notrace", | |
74 | "__percpu", | |
75 | "__rcu", | |
76 | "__user", | |
34d9f62e | 77 | "__force", |
b34b86d7 MCC |
78 | |
79 | # include/linux/compiler_attributes.h: | |
80 | "__alias", | |
81 | "__aligned", | |
82 | "__aligned_largest", | |
83 | "__always_inline", | |
84 | "__assume_aligned", | |
85 | "__cold", | |
86 | "__attribute_const__", | |
87 | "__copy", | |
88 | "__pure", | |
89 | "__designated_init", | |
90 | "__visible", | |
91 | "__printf", | |
92 | "__scanf", | |
93 | "__gnu_inline", | |
94 | "__malloc", | |
95 | "__mode", | |
96 | "__no_caller_saved_registers", | |
97 | "__noclone", | |
98 | "__nonstring", | |
99 | "__noreturn", | |
100 | "__packed", | |
101 | "__pure", | |
102 | "__section", | |
103 | "__always_unused", | |
104 | "__maybe_unused", | |
105 | "__used", | |
106 | "__weak", | |
107 | "noinline", | |
5479d6d4 | 108 | "__fix_address", |
b34b86d7 MCC |
109 | |
110 | # include/linux/memblock.h: | |
111 | "__init_memblock", | |
112 | "__meminit", | |
113 | ||
114 | # include/linux/init.h: | |
115 | "__init", | |
116 | "__ref", | |
117 | ||
118 | # include/linux/linkage.h: | |
119 | "asmlinkage", | |
98e6ab7a DV |
120 | |
121 | # include/linux/btf.h | |
122 | "__bpf_kfunc", | |
b34b86d7 MCC |
123 | ] |
124 | ||
afde706a JC |
125 | else: |
126 | extensions.append('cdomain') | |
127 | ||
4658b0eb MCC |
128 | # Ensure that autosectionlabel will produce unique names |
129 | autosectionlabel_prefix_document = True | |
130 | autosectionlabel_maxdepth = 2 | |
131 | ||
6b0d3e7c AY |
132 | # Load math renderer: |
133 | # For html builder, load imgmath only when its dependencies are met. | |
134 | # mathjax is the default math renderer since Sphinx 1.8. | |
135 | have_latex = have_command('latex') | |
136 | have_dvipng = have_command('dvipng') | |
3b384e95 AY |
137 | load_imgmath = have_latex and have_dvipng |
138 | ||
139 | # Respect SPHINX_IMGMATH (for html docs only) | |
140 | if 'SPHINX_IMGMATH' in os.environ: | |
141 | env_sphinx_imgmath = os.environ['SPHINX_IMGMATH'] | |
142 | if 'yes' in env_sphinx_imgmath: | |
143 | load_imgmath = True | |
144 | elif 'no' in env_sphinx_imgmath: | |
145 | load_imgmath = False | |
146 | else: | |
147 | sys.stderr.write("Unknown env SPHINX_IMGMATH=%s ignored.\n" % env_sphinx_imgmath) | |
148 | ||
149 | # Always load imgmath for Sphinx <1.8 or for epub docs | |
150 | load_imgmath = (load_imgmath or (major == 1 and minor < 8) | |
6b0d3e7c AY |
151 | or 'epub' in sys.argv) |
152 | ||
153 | if load_imgmath: | |
154 | extensions.append("sphinx.ext.imgmath") | |
155 | math_renderer = 'imgmath' | |
156 | else: | |
157 | math_renderer = 'mathjax' | |
22cba31b JN |
158 | |
159 | # Add any paths that contain templates here, relative to this directory. | |
c404f5d4 | 160 | templates_path = ['sphinx/templates'] |
22cba31b JN |
161 | |
162 | # The suffix(es) of source filenames. | |
163 | # You can specify multiple suffix as a list of string: | |
164 | # source_suffix = ['.rst', '.md'] | |
165 | source_suffix = '.rst' | |
166 | ||
167 | # The encoding of source files. | |
168 | #source_encoding = 'utf-8-sig' | |
169 | ||
170 | # The master toctree document. | |
171 | master_doc = 'index' | |
172 | ||
173 | # General information about the project. | |
174 | project = 'The Linux Kernel' | |
dc36143f | 175 | copyright = 'The kernel development community' |
22cba31b JN |
176 | author = 'The kernel development community' |
177 | ||
178 | # The version info for the project you're documenting, acts as replacement for | |
179 | # |version| and |release|, also used in various other places throughout the | |
180 | # built documents. | |
181 | # | |
c13ce448 JN |
182 | # In a normal build, version and release are are set to KERNELVERSION and |
183 | # KERNELRELEASE, respectively, from the Makefile via Sphinx command line | |
184 | # arguments. | |
185 | # | |
186 | # The following code tries to extract the information by reading the Makefile, | |
187 | # when Sphinx is run directly (e.g. by Read the Docs). | |
188 | try: | |
189 | makefile_version = None | |
190 | makefile_patchlevel = None | |
191 | for line in open('../Makefile'): | |
192 | key, val = [x.strip() for x in line.split('=', 2)] | |
193 | if key == 'VERSION': | |
194 | makefile_version = val | |
195 | elif key == 'PATCHLEVEL': | |
196 | makefile_patchlevel = val | |
197 | if makefile_version and makefile_patchlevel: | |
198 | break | |
199 | except: | |
200 | pass | |
201 | finally: | |
202 | if makefile_version and makefile_patchlevel: | |
203 | version = release = makefile_version + '.' + makefile_patchlevel | |
204 | else: | |
c13ce448 | 205 | version = release = "unknown version" |
22cba31b | 206 | |
d5389d31 JC |
207 | # |
208 | # HACK: there seems to be no easy way for us to get at the version and | |
209 | # release information passed in from the makefile...so go pawing through the | |
210 | # command-line options and find it for ourselves. | |
211 | # | |
212 | def get_cline_version(): | |
213 | c_version = c_release = '' | |
214 | for arg in sys.argv: | |
215 | if arg.startswith('version='): | |
216 | c_version = arg[8:] | |
217 | elif arg.startswith('release='): | |
218 | c_release = arg[8:] | |
219 | if c_version: | |
220 | if c_release: | |
221 | return c_version + '-' + c_release | |
222 | return c_version | |
223 | return version # Whatever we came up with before | |
224 | ||
22cba31b JN |
225 | # The language for content autogenerated by Sphinx. Refer to documentation |
226 | # for a list of supported languages. | |
227 | # | |
228 | # This is also used if you do content translation via gettext catalogs. | |
229 | # Usually you set "language" from the command line for these cases. | |
627f01ea | 230 | language = 'en' |
22cba31b JN |
231 | |
232 | # There are two options for replacing |today|: either, you set today to some | |
233 | # non-false value, then it is used: | |
234 | #today = '' | |
235 | # Else, today_fmt is used as the format for a strftime call. | |
236 | #today_fmt = '%B %d, %Y' | |
237 | ||
238 | # List of patterns, relative to source directory, that match files and | |
239 | # directories to ignore when looking for source files. | |
240 | exclude_patterns = ['output'] | |
241 | ||
242 | # The reST default role (used for this markup: `text`) to use for all | |
243 | # documents. | |
244 | #default_role = None | |
245 | ||
246 | # If true, '()' will be appended to :func: etc. cross-reference text. | |
247 | #add_function_parentheses = True | |
248 | ||
249 | # If true, the current module name will be prepended to all description | |
250 | # unit titles (such as .. function::). | |
251 | #add_module_names = True | |
252 | ||
253 | # If true, sectionauthor and moduleauthor directives will be shown in the | |
254 | # output. They are ignored by default. | |
255 | #show_authors = False | |
256 | ||
257 | # The name of the Pygments (syntax highlighting) style to use. | |
258 | pygments_style = 'sphinx' | |
259 | ||
260 | # A list of ignored prefixes for module index sorting. | |
261 | #modindex_common_prefix = [] | |
262 | ||
263 | # If true, keep warnings as "system message" paragraphs in the built documents. | |
264 | #keep_warnings = False | |
265 | ||
266 | # If true, `todo` and `todoList` produce output, else they produce nothing. | |
267 | todo_include_todos = False | |
268 | ||
fd5d6669 | 269 | primary_domain = 'c' |
b459106e | 270 | highlight_language = 'none' |
22cba31b JN |
271 | |
272 | # -- Options for HTML output ---------------------------------------------- | |
273 | ||
274 | # The theme to use for HTML and HTML Help pages. See the documentation for | |
275 | # a list of builtin themes. | |
276 | ||
fca7216b | 277 | # Default theme |
d5389d31 | 278 | html_theme = 'alabaster' |
135707d3 | 279 | html_css_files = [] |
fca7216b MCC |
280 | |
281 | if "DOCS_THEME" in os.environ: | |
282 | html_theme = os.environ["DOCS_THEME"] | |
283 | ||
a6fb8b5a | 284 | if html_theme == 'sphinx_rtd_theme' or html_theme == 'sphinx_rtd_dark_mode': |
fca7216b MCC |
285 | # Read the Docs theme |
286 | try: | |
287 | import sphinx_rtd_theme | |
288 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] | |
289 | ||
290 | # Add any paths that contain custom static files (such as style sheets) here, | |
291 | # relative to this directory. They are copied after the builtin static files, | |
292 | # so a file named "default.css" will overwrite the builtin "default.css". | |
293 | html_css_files = [ | |
294 | 'theme_overrides.css', | |
295 | ] | |
a6fb8b5a MCC |
296 | |
297 | # Read the Docs dark mode override theme | |
298 | if html_theme == 'sphinx_rtd_dark_mode': | |
299 | try: | |
300 | import sphinx_rtd_dark_mode | |
301 | extensions.append('sphinx_rtd_dark_mode') | |
302 | except ImportError: | |
303 | html_theme == 'sphinx_rtd_theme' | |
304 | ||
305 | if html_theme == 'sphinx_rtd_theme': | |
306 | # Add color-specific RTD normal mode | |
307 | html_css_files.append('theme_rtd_colors.css') | |
308 | ||
e17f2260 DV |
309 | html_theme_options = { |
310 | 'navigation_depth': -1, | |
311 | } | |
312 | ||
fca7216b | 313 | except ImportError: |
02d33e86 | 314 | html_theme = 'alabaster' |
fca7216b | 315 | |
135707d3 MCC |
316 | if "DOCS_CSS" in os.environ: |
317 | css = os.environ["DOCS_CSS"].split(" ") | |
318 | ||
319 | for l in css: | |
320 | html_css_files.append(l) | |
321 | ||
fca7216b MCC |
322 | if major <= 1 and minor < 8: |
323 | html_context = { | |
324 | 'css_files': [], | |
325 | } | |
326 | ||
327 | for l in html_css_files: | |
328 | html_context['css_files'].append('_static/' + l) | |
329 | ||
02d33e86 | 330 | if html_theme == 'alabaster': |
d5389d31 JC |
331 | html_theme_options = { |
332 | 'description': get_cline_version(), | |
2056b920 JC |
333 | 'page_width': '65em', |
334 | 'sidebar_width': '15em', | |
c404f5d4 | 335 | 'fixed_sidebar': 'true', |
bd5d1cc8 JC |
336 | 'font_size': 'inherit', |
337 | 'font_family': 'serif', | |
d5389d31 | 338 | } |
ffc901b4 | 339 | |
fca7216b | 340 | sys.stderr.write("Using %s theme\n" % html_theme) |
22cba31b | 341 | |
22cba31b JN |
342 | # Add any paths that contain custom static files (such as style sheets) here, |
343 | # relative to this directory. They are copied after the builtin static files, | |
344 | # so a file named "default.css" will overwrite the builtin "default.css". | |
bc214671 MH |
345 | html_static_path = ['sphinx-static'] |
346 | ||
eaae7575 JC |
347 | # If true, Docutils "smart quotes" will be used to convert quotes and dashes |
348 | # to typographically correct entities. This will convert "--" to "—", | |
349 | # which is not always what we want, so disable it. | |
350 | smartquotes = False | |
22cba31b JN |
351 | |
352 | # Custom sidebar templates, maps document names to template names. | |
d5389d31 | 353 | # Note that the RTD theme ignores this |
c404f5d4 | 354 | html_sidebars = { '**': ['searchbox.html', 'kernel-toc.html', 'sourcelink.html']} |
a33ae832 AY |
355 | |
356 | # about.html is available for alabaster theme. Add it at the front. | |
357 | if html_theme == 'alabaster': | |
358 | html_sidebars['**'].insert(0, 'about.html') | |
22cba31b | 359 | |
d49af114 VN |
360 | # The name of an image file (relative to this directory) to place at the top |
361 | # of the sidebar. | |
362 | html_logo = 'images/logo.svg' | |
363 | ||
22cba31b JN |
364 | # Output file base name for HTML help builder. |
365 | htmlhelp_basename = 'TheLinuxKerneldoc' | |
366 | ||
367 | # -- Options for LaTeX output --------------------------------------------- | |
368 | ||
369 | latex_elements = { | |
3b4c9632 MCC |
370 | # The paper size ('letterpaper' or 'a4paper'). |
371 | 'papersize': 'a4paper', | |
22cba31b | 372 | |
3b4c9632 MCC |
373 | # The font size ('10pt', '11pt' or '12pt'). |
374 | 'pointsize': '11pt', | |
22cba31b | 375 | |
3b4c9632 MCC |
376 | # Latex figure (float) alignment |
377 | #'figure_align': 'htbp', | |
caee5cde | 378 | |
3b4c9632 MCC |
379 | # Don't mangle with UTF-8 chars |
380 | 'inputenc': '', | |
381 | 'utf8extra': '', | |
a682ec4b | 382 | |
3b4c9632 MCC |
383 | # Set document margins |
384 | 'sphinxsetup': ''' | |
385 | hmargin=0.5in, vmargin=1in, | |
386 | parsedliteralwraps=true, | |
387 | verbatimhintsturnover=false, | |
388 | ''', | |
389 | ||
77abc2c2 AY |
390 | # For CJK One-half spacing, need to be in front of hyperref |
391 | 'extrapackages': r'\usepackage{setspace}', | |
392 | ||
3b4c9632 | 393 | # Additional stuff for the LaTeX preamble. |
caee5cde | 394 | 'preamble': ''' |
3b4c9632 | 395 | % Use some font with UTF-8 support with XeLaTeX |
9fdcd6af | 396 | \\usepackage{fontspec} |
44ba0bb4 DW |
397 | \\setsansfont{DejaVu Sans} |
398 | \\setromanfont{DejaVu Serif} | |
9fdcd6af | 399 | \\setmonofont{DejaVu Sans Mono} |
398f7abd | 400 | ''', |
e0de2b59 | 401 | } |
9fdcd6af | 402 | |
9fdcd6af | 403 | # Fix reference escape troubles with Sphinx 1.4.x |
f546ff0c | 404 | if major == 1: |
9fdcd6af MCC |
405 | latex_elements['preamble'] += '\\renewcommand*{\\DUrole}[2]{ #2 }\n' |
406 | ||
398f7abd AY |
407 | |
408 | # Load kerneldoc specific LaTeX settings | |
409 | latex_elements['preamble'] += ''' | |
410 | % Load kerneldoc specific LaTeX settings | |
411 | \\input{kerneldoc-preamble.sty} | |
412 | ''' | |
413 | ||
9fdcd6af MCC |
414 | # With Sphinx 1.6, it is possible to change the Bg color directly |
415 | # by using: | |
416 | # \definecolor{sphinxnoteBgColor}{RGB}{204,255,255} | |
417 | # \definecolor{sphinxwarningBgColor}{RGB}{255,204,204} | |
418 | # \definecolor{sphinxattentionBgColor}{RGB}{255,255,204} | |
419 | # \definecolor{sphinximportantBgColor}{RGB}{192,255,204} | |
420 | # | |
421 | # However, it require to use sphinx heavy box with: | |
422 | # | |
423 | # \renewenvironment{sphinxlightbox} {% | |
424 | # \\begin{sphinxheavybox} | |
425 | # } | |
426 | # \\end{sphinxheavybox} | |
427 | # } | |
428 | # | |
429 | # Unfortunately, the implementation is buggy: if a note is inside a | |
430 | # table, it isn't displayed well. So, for now, let's use boring | |
431 | # black and white notes. | |
633d612b | 432 | |
22cba31b JN |
433 | # Grouping the document tree into LaTeX files. List of tuples |
434 | # (source start file, target name, title, | |
435 | # author, documentclass [howto, manual, or own class]). | |
c2b563d8 | 436 | # Sorted in alphabetical order |
22cba31b | 437 | latex_documents = [ |
22cba31b JN |
438 | ] |
439 | ||
9d42afbe MCC |
440 | # Add all other index files from Documentation/ subdirectories |
441 | for fn in os.listdir('.'): | |
442 | doc = os.path.join(fn, "index") | |
443 | if os.path.exists(doc + ".rst"): | |
444 | has = False | |
445 | for l in latex_documents: | |
446 | if l[0] == doc: | |
447 | has = True | |
448 | break | |
449 | if not has: | |
450 | latex_documents.append((doc, fn + '.tex', | |
451 | 'Linux %s Documentation' % fn.capitalize(), | |
452 | 'The kernel development community', | |
453 | 'manual')) | |
454 | ||
22cba31b JN |
455 | # The name of an image file (relative to this directory) to place at the top of |
456 | # the title page. | |
457 | #latex_logo = None | |
458 | ||
459 | # For "manual" documents, if this is true, then toplevel headings are parts, | |
460 | # not chapters. | |
461 | #latex_use_parts = False | |
462 | ||
463 | # If true, show page references after internal links. | |
464 | #latex_show_pagerefs = False | |
465 | ||
466 | # If true, show URL addresses after external links. | |
467 | #latex_show_urls = False | |
468 | ||
469 | # Documents to append as an appendix to all manuals. | |
470 | #latex_appendices = [] | |
471 | ||
472 | # If false, no module index is generated. | |
473 | #latex_domain_indices = True | |
474 | ||
398f7abd AY |
475 | # Additional LaTeX stuff to be copied to build directory |
476 | latex_additional_files = [ | |
477 | 'sphinx/kerneldoc-preamble.sty', | |
478 | ] | |
479 | ||
22cba31b JN |
480 | |
481 | # -- Options for manual page output --------------------------------------- | |
482 | ||
483 | # One entry per manual page. List of tuples | |
484 | # (source start file, name, description, authors, manual section). | |
485 | man_pages = [ | |
486 | (master_doc, 'thelinuxkernel', 'The Linux Kernel Documentation', | |
487 | [author], 1) | |
488 | ] | |
489 | ||
490 | # If true, show URL addresses after external links. | |
491 | #man_show_urls = False | |
492 | ||
493 | ||
494 | # -- Options for Texinfo output ------------------------------------------- | |
495 | ||
496 | # Grouping the document tree into Texinfo files. List of tuples | |
497 | # (source start file, target name, title, author, | |
498 | # dir menu entry, description, category) | |
499 | texinfo_documents = [ | |
500 | (master_doc, 'TheLinuxKernel', 'The Linux Kernel Documentation', | |
501 | author, 'TheLinuxKernel', 'One line description of project.', | |
502 | 'Miscellaneous'), | |
503 | ] | |
504 | ||
22cba31b JN |
505 | # -- Options for Epub output ---------------------------------------------- |
506 | ||
507 | # Bibliographic Dublin Core info. | |
508 | epub_title = project | |
509 | epub_author = author | |
510 | epub_publisher = author | |
511 | epub_copyright = copyright | |
512 | ||
22cba31b JN |
513 | # A list of files that should not be packed into the epub file. |
514 | epub_exclude_files = ['search.html'] | |
515 | ||
22cba31b JN |
516 | #======= |
517 | # rst2pdf | |
518 | # | |
519 | # Grouping the document tree into PDF files. List of tuples | |
520 | # (source start file, target name, title, author, options). | |
521 | # | |
93431e06 | 522 | # See the Sphinx chapter of https://ralsina.me/static/manual.pdf |
22cba31b JN |
523 | # |
524 | # FIXME: Do not add the index file here; the result will be too big. Adding | |
525 | # multiple PDF files here actually tries to get the cross-referencing right | |
526 | # *between* PDF files. | |
527 | pdf_documents = [ | |
520a2477 | 528 | ('kernel-documentation', u'Kernel', u'Kernel', u'J. Random Bozo'), |
22cba31b | 529 | ] |
24dcdeb2 JN |
530 | |
531 | # kernel-doc extension configuration for running Sphinx directly (e.g. by Read | |
532 | # the Docs). In a normal build, these are supplied from the Makefile via command | |
533 | # line arguments. | |
534 | kerneldoc_bin = '../scripts/kernel-doc' | |
535 | kerneldoc_srctree = '..' | |
606b9ac8 MH |
536 | |
537 | # ------------------------------------------------------------------------------ | |
538 | # Since loadConfig overwrites settings from the global namespace, it has to be | |
539 | # the last statement in the conf.py file | |
540 | # ------------------------------------------------------------------------------ | |
541 | loadConfig(globals()) |