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