|
16 | 16 | import os |
17 | 17 | import sphinx |
18 | 18 |
|
| 19 | +from subprocess import check_output |
| 20 | + |
19 | 21 | # Get Sphinx version |
20 | 22 | major, minor, patch = sphinx.version_info[:3] |
21 | 23 |
|
|
31 | 33 | # If your documentation needs a minimal Sphinx version, state it here. |
32 | 34 | needs_sphinx = '1.3' |
33 | 35 |
|
34 | | -latex_engine = 'xelatex' |
35 | | - |
36 | 36 | # Add any Sphinx extension module names here, as strings. They can be |
37 | 37 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom |
38 | 38 | # ones. |
39 | | -extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', 'kfigure'] |
| 39 | +extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', |
| 40 | + 'kfigure', 'sphinx.ext.ifconfig', 'automarkup', |
| 41 | + 'maintainers_include', 'sphinx.ext.autosectionlabel', |
| 42 | + 'kernel_abi', 'kernel_feat'] |
40 | 43 |
|
41 | 44 | # |
42 | | -# cdomain is badly broken in Sphinx 3+. Leaving it out generates *most* |
43 | | -# of the docs correctly, but not all. |
| 45 | +# cdomain is badly broken in Sphinx 3+. Leaving it out generates *most* |
| 46 | +# of the docs correctly, but not all. Scream bloody murder but allow |
| 47 | +# the process to proceed; hopefully somebody will fix this properly soon. |
44 | 48 | # |
45 | 49 | if major >= 3: |
| 50 | + sys.stderr.write('''WARNING: The kernel documentation build process |
| 51 | + support for Sphinx v3.0 and above is brand new. Be prepared for |
| 52 | + possible issues in the generated output. |
| 53 | + ''') |
46 | 54 | if (major > 3) or (minor > 0 or patch >= 2): |
47 | | - sys.stderr.write('''The build process with Sphinx 3+ is broken. |
48 | | -You will have to remove -W in doc/Makefile. |
49 | | -''') |
50 | 55 | # Sphinx c function parser is more pedantic with regards to type |
51 | 56 | # checking. Due to that, having macros at c:function cause problems. |
52 | | - # Those needed to be escaped by using c_id_attributes[] array |
| 57 | + # Those needed to be scaped by using c_id_attributes[] array |
53 | 58 | c_id_attributes = [ |
54 | | - |
55 | | - # include/linux/compiler.h |
| 59 | + # GCC Compiler types not parsed by Sphinx: |
| 60 | + "__restrict__", |
| 61 | + |
| 62 | + # include/linux/compiler_types.h: |
| 63 | + "__iomem", |
| 64 | + "__kernel", |
| 65 | + "noinstr", |
| 66 | + "notrace", |
| 67 | + "__percpu", |
| 68 | + "__rcu", |
| 69 | + "__user", |
| 70 | + |
| 71 | + # include/linux/compiler_attributes.h: |
| 72 | + "__alias", |
| 73 | + "__aligned", |
| 74 | + "__aligned_largest", |
| 75 | + "__always_inline", |
| 76 | + "__assume_aligned", |
| 77 | + "__cold", |
| 78 | + "__attribute_const__", |
| 79 | + "__copy", |
| 80 | + "__pure", |
| 81 | + "__designated_init", |
| 82 | + "__visible", |
| 83 | + "__printf", |
| 84 | + "__scanf", |
| 85 | + "__gnu_inline", |
| 86 | + "__malloc", |
| 87 | + "__mode", |
| 88 | + "__no_caller_saved_registers", |
| 89 | + "__noclone", |
| 90 | + "__nonstring", |
| 91 | + "__noreturn", |
| 92 | + "__packed", |
| 93 | + "__pure", |
| 94 | + "__section", |
| 95 | + "__always_unused", |
56 | 96 | "__maybe_unused", |
| 97 | + "__used", |
| 98 | + "__weak", |
| 99 | + "noinline", |
57 | 100 |
|
58 | 101 | # include/efi.h |
59 | 102 | "EFIAPI", |
60 | 103 |
|
61 | 104 | # include/efi_loader.h |
62 | 105 | "__efi_runtime", |
| 106 | + |
| 107 | + # include/linux/memblock.h: |
| 108 | + "__init_memblock", |
| 109 | + "__meminit", |
| 110 | + |
| 111 | + # include/linux/init.h: |
| 112 | + "__init", |
| 113 | + "__ref", |
| 114 | + |
| 115 | + # include/linux/linkage.h: |
| 116 | + "asmlinkage", |
63 | 117 | ] |
64 | 118 |
|
65 | 119 | else: |
66 | 120 | extensions.append('cdomain') |
| 121 | + if major == 1 and minor < 7: |
| 122 | + sys.stderr.write('WARNING: Sphinx 1.7 or greater will be required as of ' |
| 123 | + 'the v2021.04 release\n') |
| 124 | + |
| 125 | +# Ensure that autosectionlabel will produce unique names |
| 126 | +autosectionlabel_prefix_document = True |
| 127 | +autosectionlabel_maxdepth = 2 |
67 | 128 |
|
68 | 129 | # The name of the math extension changed on Sphinx 1.4 |
69 | 130 | if (major == 1 and minor > 3) or (major > 1): |
|
86 | 147 | master_doc = 'index' |
87 | 148 |
|
88 | 149 | # General information about the project. |
89 | | -project = 'Das U-Boot' |
90 | | -copyright = 'The U-Boot development community' |
91 | | -author = 'The U-Boot development community' |
| 150 | +project = 'The Linux Kernel' |
| 151 | +copyright = 'The kernel development community' |
| 152 | +author = 'The kernel development community' |
92 | 153 |
|
93 | 154 | # The version info for the project you're documenting, acts as replacement for |
94 | 155 | # |version| and |release|, also used in various other places throughout the |
|
199 | 260 |
|
200 | 261 | # The name of an image file (relative to this directory) to place at the top |
201 | 262 | # of the sidebar. |
202 | | -html_logo = '../tools/logos/u-boot_logo.svg' |
| 263 | +#html_logo = None |
203 | 264 |
|
204 | 265 | # The name of an image file (within the static path) to use as favicon of the |
205 | 266 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 |
|
229 | 290 |
|
230 | 291 | # If true, SmartyPants will be used to convert quotes and dashes to |
231 | 292 | # typographically correct entities. |
232 | | -#html_use_smartypants = True |
| 293 | +html_use_smartypants = False |
233 | 294 |
|
234 | 295 | # Custom sidebar templates, maps document names to template names. |
235 | 296 | #html_sidebars = {} |
|
279 | 340 | #html_search_scorer = 'scorer.js' |
280 | 341 |
|
281 | 342 | # Output file base name for HTML help builder. |
282 | | -htmlhelp_basename = 'TheUBootdoc' |
| 343 | +htmlhelp_basename = 'TheLinuxKerneldoc' |
283 | 344 |
|
284 | 345 | # -- Options for LaTeX output --------------------------------------------- |
285 | 346 |
|
|
288 | 349 | 'papersize': 'a4paper', |
289 | 350 |
|
290 | 351 | # The font size ('10pt', '11pt' or '12pt'). |
291 | | -'pointsize': '8pt', |
| 352 | +'pointsize': '11pt', |
292 | 353 |
|
293 | 354 | # Latex figure (float) alignment |
294 | 355 | #'figure_align': 'htbp', |
|
301 | 362 | 'preamble': ''' |
302 | 363 | % Use some font with UTF-8 support with XeLaTeX |
303 | 364 | \\usepackage{fontspec} |
304 | | - \\setsansfont{DejaVu Serif} |
305 | | - \\setromanfont{DejaVu Sans} |
| 365 | + \\setsansfont{DejaVu Sans} |
| 366 | + \\setromanfont{DejaVu Serif} |
306 | 367 | \\setmonofont{DejaVu Sans Mono} |
307 | | -
|
308 | 368 | ''' |
309 | 369 | } |
310 | 370 |
|
| 371 | +# At least one book (translations) may have Asian characters |
| 372 | +# with are only displayed if xeCJK is used |
| 373 | + |
| 374 | +cjk_cmd = check_output(['fc-list', '--format="%{family[0]}\n"']).decode('utf-8', 'ignore') |
| 375 | +if cjk_cmd.find("Noto Sans CJK SC") >= 0: |
| 376 | + print ("enabling CJK for LaTeX builder") |
| 377 | + latex_elements['preamble'] += ''' |
| 378 | + % This is needed for translations |
| 379 | + \\usepackage{xeCJK} |
| 380 | + \\setCJKmainfont{Noto Sans CJK SC} |
| 381 | + ''' |
| 382 | + |
311 | 383 | # Fix reference escape troubles with Sphinx 1.4.x |
312 | 384 | if major == 1 and minor > 3: |
313 | 385 | latex_elements['preamble'] += '\\renewcommand*{\\DUrole}[2]{ #2 }\n' |
|
398 | 470 | # author, documentclass [howto, manual, or own class]). |
399 | 471 | # Sorted in alphabetical order |
400 | 472 | latex_documents = [ |
401 | | - ('index', 'u-boot-hacker-manual.tex', 'U-Boot Hacker Manual', |
402 | | - 'The U-Boot development community', 'manual'), |
403 | 473 | ] |
404 | 474 |
|
| 475 | +# Add all other index files from Documentation/ subdirectories |
| 476 | +for fn in os.listdir('.'): |
| 477 | + doc = os.path.join(fn, "index") |
| 478 | + if os.path.exists(doc + ".rst"): |
| 479 | + has = False |
| 480 | + for l in latex_documents: |
| 481 | + if l[0] == doc: |
| 482 | + has = True |
| 483 | + break |
| 484 | + if not has: |
| 485 | + latex_documents.append((doc, fn + '.tex', |
| 486 | + 'Linux %s Documentation' % fn.capitalize(), |
| 487 | + 'The kernel development community', |
| 488 | + 'manual')) |
| 489 | + |
405 | 490 | # The name of an image file (relative to this directory) to place at the top of |
406 | 491 | # the title page. |
407 | 492 | #latex_logo = None |
|
428 | 513 | # One entry per manual page. List of tuples |
429 | 514 | # (source start file, name, description, authors, manual section). |
430 | 515 | man_pages = [ |
431 | | - (master_doc, 'dasuboot', 'The U-Boot Documentation', |
| 516 | + (master_doc, 'thelinuxkernel', 'The Linux Kernel Documentation', |
432 | 517 | [author], 1) |
433 | 518 | ] |
434 | 519 |
|
|
442 | 527 | # (source start file, target name, title, author, |
443 | 528 | # dir menu entry, description, category) |
444 | 529 | texinfo_documents = [ |
445 | | - (master_doc, 'DasUBoot', 'The U-Boot Documentation', |
446 | | - author, 'DasUBoot', 'One line description of project.', |
| 530 | + (master_doc, 'TheLinuxKernel', 'The Linux Kernel Documentation', |
| 531 | + author, 'TheLinuxKernel', 'One line description of project.', |
447 | 532 | 'Miscellaneous'), |
448 | 533 | ] |
449 | 534 |
|
|
535 | 620 | # Grouping the document tree into PDF files. List of tuples |
536 | 621 | # (source start file, target name, title, author, options). |
537 | 622 | # |
538 | | -# See the Sphinx chapter of http://ralsina.me/static/manual.pdf |
| 623 | +# See the Sphinx chapter of https://ralsina.me/static/manual.pdf |
539 | 624 | # |
540 | 625 | # FIXME: Do not add the index file here; the result will be too big. Adding |
541 | 626 | # multiple PDF files here actually tries to get the cross-referencing right |
542 | 627 | # *between* PDF files. |
543 | 628 | pdf_documents = [ |
544 | | - ('uboot-documentation', u'U-Boot', u'U-Boot', u'J. Random Bozo'), |
| 629 | + ('kernel-documentation', u'Kernel', u'Kernel', u'J. Random Bozo'), |
545 | 630 | ] |
546 | 631 |
|
547 | 632 | # kernel-doc extension configuration for running Sphinx directly (e.g. by Read |
|
0 commit comments