conf.py 17 KB

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