conf.py 21 KB

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