Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'mauro' into docs-mw

Mauro says:

This series increases the minimal requirements for Sphinx and Python, and
drop some backward-compatible code from Sphinx extension.

Looking at Sphinx release dates:

Release 2.4.0 (released Feb 09, 2020)
Release 2.4.4 (released Mar 05, 2020) (current minimal requirement)
Release 3.4.0 (released Dec 20, 2020)
Release 3.4.3 (released Jan 08, 2021)

(https://www.sphinx-doc.org/en/master/changes/index.html)

And Python release dates, we have:

Python Release date
3.5 2015-09-13 (current minimal requirement)
3.6 2016-12-23
3.7 2018-06-27
3.8 2019-10-14
3.9 2020-10-05
3.10 2021-10-04

(according with https://en.wikipedia.org/w/index.php?title=History_of_Python)

The new minimal requirements are now compatible with the toolset available on Jan, 2021,
e.g.:
- Sphinx 3.4.3;
- Python 3.9

The new Sphinx minimal requirement allows dropping all backward-compatible code
we have at kernel-doc and at Sphinx extensions.

The new Python minimal requirement also matches the current required level for
almost all scripts (*).

Those matches a 4-years old toolchain, which sounds a reasonable period
of time, as Python/Sphinx aren't required for the Kernel build.

(*) Except for a couple scripts inside tools that require python 3.10:

$ vermin -v $(git ls-files '*.py')|grep 3.10
!2, 3.10 tools/net/sunrpc/xdrgen/generators/__init__.py
!2, 3.10 tools/net/sunrpc/xdrgen/generators/program.py
!2, 3.10 tools/net/sunrpc/xdrgen/subcmds/source.py
!2, 3.10 tools/net/sunrpc/xdrgen/xdr_ast.py
!2, 3.10 tools/perf/scripts/python/mem-phys-addr.py
!2, 3.10 tools/power/cpupower/bindings/python/test_raw_pylibcpupower.py

Such scripts aren't required for Kernel builds, so it should be OK to set minimal
python version to 3.9.

+41 -146
+1 -1
Documentation/conf.py
··· 47 47 # -- General configuration ------------------------------------------------ 48 48 49 49 # If your documentation needs a minimal Sphinx version, state it here. 50 - needs_sphinx = '2.4.4' 50 + needs_sphinx = '3.4.3' 51 51 52 52 # Add any Sphinx extension module names here, as strings. They can be 53 53 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+2 -2
Documentation/process/changes.rst
··· 58 58 iptables 1.4.2 iptables -V 59 59 openssl & libcrypto 1.0.0 openssl version 60 60 bc 1.06.95 bc --version 61 - Sphinx\ [#f1]_ 2.4.4 sphinx-build --version 61 + Sphinx\ [#f1]_ 3.4.3 sphinx-build --version 62 62 GNU tar 1.28 tar --version 63 63 gtags (optional) 6.6.5 gtags --version 64 64 mkimage (optional) 2017.01 mkimage --version 65 - Python (optional) 3.5.x python3 --version 65 + Python (optional) 3.9.x python3 --version 66 66 GNU AWK (optional) 5.1.0 gawk --version 67 67 ====================== =============== ======================================== 68 68
+2 -5
Documentation/sphinx/cdomain.py
··· 1 1 # -*- coding: utf-8; mode: python -*- 2 2 # pylint: disable=W0141,C0113,C0103,C0325 3 - u""" 3 + """ 4 4 cdomain 5 5 ~~~~~~~ 6 6 ··· 44 44 import re 45 45 46 46 __version__ = '1.1' 47 - 48 - # Get Sphinx version 49 - major, minor, patch = sphinx.version_info[:3] 50 47 51 48 # Namespace to be prepended to the full name 52 49 namespace = None ··· 142 145 } 143 146 144 147 def handle_func_like_macro(self, sig, signode): 145 - u"""Handles signatures of function-like macros. 148 + """Handles signatures of function-like macros. 146 149 147 150 If the objtype is 'function' and the signature ``sig`` is a 148 151 function-like macro, the name of the macro is returned. Otherwise
+3 -3
Documentation/sphinx/kernel_abi.py
··· 2 2 # coding=utf-8 3 3 # SPDX-License-Identifier: GPL-2.0 4 4 # 5 - u""" 5 + """ 6 6 kernel-abi 7 7 ~~~~~~~~~~ 8 8 ··· 55 55 _kernel_abi = None 56 56 57 57 def get_kernel_abi(): 58 - u""" 58 + """ 59 59 Initialize kernel_abi global var, if not initialized yet. 60 60 61 61 This is needed to avoid warnings during Sphinx module initialization. ··· 81 81 82 82 83 83 class KernelCmd(Directive): 84 - u"""KernelABI (``kernel-abi``) directive""" 84 + """KernelABI (``kernel-abi``) directive""" 85 85 86 86 required_arguments = 1 87 87 optional_arguments = 3
+2 -2
Documentation/sphinx/kernel_feat.py
··· 1 1 # coding=utf-8 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # 4 - u""" 4 + """ 5 5 kernel-feat 6 6 ~~~~~~~~~~~ 7 7 ··· 56 56 57 57 class KernelFeat(Directive): 58 58 59 - u"""KernelFeat (``kernel-feat``) directive""" 59 + """KernelFeat (``kernel-feat``) directive""" 60 60 61 61 required_arguments = 1 62 62 optional_arguments = 2
+2 -2
Documentation/sphinx/kernel_include.py
··· 2 2 # -*- coding: utf-8; mode: python -*- 3 3 # pylint: disable=R0903, C0330, R0914, R0912, E0401 4 4 5 - u""" 5 + """ 6 6 kernel-include 7 7 ~~~~~~~~~~~~~~ 8 8 ··· 56 56 class KernelInclude(Include): 57 57 # ============================================================================== 58 58 59 - u"""KernelInclude (``kernel-include``) directive""" 59 + """KernelInclude (``kernel-include``) directive""" 60 60 61 61 def run(self): 62 62 env = self.state.document.settings.env
-5
Documentation/sphinx/kerneldoc.py
··· 62 62 env = self.state.document.settings.env 63 63 cmd = [env.config.kerneldoc_bin, '-rst', '-enable-lineno'] 64 64 65 - # Pass the version string to kernel-doc, as it needs to use a different 66 - # dialect, depending what the C domain supports for each specific 67 - # Sphinx versions 68 - cmd += ['-sphinx-version', sphinx.__version__] 69 - 70 65 filename = env.config.kerneldoc_srctree + '/' + self.arguments[0] 71 66 export_file_patterns = [] 72 67
+5 -5
Documentation/sphinx/kfigure.py
··· 1 1 # -*- coding: utf-8; mode: python -*- 2 2 # pylint: disable=C0103, R0903, R0912, R0915 3 - u""" 3 + """ 4 4 scalable figure and image handling 5 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 6 ··· 165 165 166 166 167 167 def setupTools(app): 168 - u""" 168 + """ 169 169 Check available build tools and log some *verbose* messages. 170 170 171 171 This function is called once, when the builder is initiated. ··· 445 445 pass 446 446 447 447 class KernelImage(images.Image): 448 - u"""KernelImage directive 448 + """KernelImage directive 449 449 450 450 Earns everything from ``.. image::`` directive, except *remote URI* and 451 451 *glob* pattern. The KernelImage wraps a image node into a ··· 481 481 """Node for ``kernel-figure`` directive.""" 482 482 483 483 class KernelFigure(Figure): 484 - u"""KernelImage directive 484 + """KernelImage directive 485 485 486 486 Earns everything from ``.. figure::`` directive, except *remote URI* and 487 487 *glob* pattern. The KernelFigure wraps a figure node into a kernel_figure ··· 557 557 pass 558 558 559 559 class KernelRender(Figure): 560 - u"""KernelRender directive 560 + """KernelRender directive 561 561 562 562 Render content by external tool. Has all the options known from the 563 563 *figure* directive, plus option ``caption``. If ``caption`` has a
+1 -1
Documentation/sphinx/load_config.py
··· 9 9 def loadConfig(namespace): 10 10 # ------------------------------------------------------------------------------ 11 11 12 - u"""Load an additional configuration file into *namespace*. 12 + """Load an additional configuration file into *namespace*. 13 13 14 14 The name of the configuration file is taken from the environment 15 15 ``SPHINX_CONF``. The external configuration file extends (or overwrites) the
+2 -2
Documentation/sphinx/maintainers_include.py
··· 3 3 # -*- coding: utf-8; mode: python -*- 4 4 # pylint: disable=R0903, C0330, R0914, R0912, E0401 5 5 6 - u""" 6 + """ 7 7 maintainers-include 8 8 ~~~~~~~~~~~~~~~~~~~ 9 9 ··· 37 37 ) 38 38 39 39 class MaintainersInclude(Include): 40 - u"""MaintainersInclude (``maintainers-include``) directive""" 40 + """MaintainersInclude (``maintainers-include``) directive""" 41 41 required_arguments = 0 42 42 43 43 def parse_maintainers(self, path):
+5 -5
Documentation/sphinx/rstFlatTable.py
··· 2 2 # -*- coding: utf-8; mode: python -*- 3 3 # pylint: disable=C0330, R0903, R0912 4 4 5 - u""" 5 + """ 6 6 flat-table 7 7 ~~~~~~~~~~ 8 8 ··· 99 99 class FlatTable(Table): 100 100 # ============================================================================== 101 101 102 - u"""FlatTable (``flat-table``) directive""" 102 + """FlatTable (``flat-table``) directive""" 103 103 104 104 option_spec = { 105 105 'name': directives.unchanged ··· 135 135 class ListTableBuilder(object): 136 136 # ============================================================================== 137 137 138 - u"""Builds a table from a double-stage list""" 138 + """Builds a table from a double-stage list""" 139 139 140 140 def __init__(self, directive): 141 141 self.directive = directive ··· 212 212 raise SystemMessagePropagation(error) 213 213 214 214 def parseFlatTableNode(self, node): 215 - u"""parses the node from a :py:class:`FlatTable` directive's body""" 215 + """parses the node from a :py:class:`FlatTable` directive's body""" 216 216 217 217 if len(node) != 1 or not isinstance(node[0], nodes.bullet_list): 218 218 self.raiseError( ··· 225 225 self.roundOffTableDefinition() 226 226 227 227 def roundOffTableDefinition(self): 228 - u"""Round off the table definition. 228 + """Round off the table definition. 229 229 230 230 This method rounds off the table definition in :py:member:`rows`. 231 231
+16 -113
scripts/kernel-doc
··· 26 26 27 27 kernel-doc [-h] [-v] [-Werror] [-Wall] [-Wreturn] [-Wshort-desc[ription]] [-Wcontents-before-sections] 28 28 [ -man | 29 - -rst [-sphinx-version VERSION] [-enable-lineno] | 29 + -rst [-enable-lineno] | 30 30 -none 31 31 ] 32 32 [ ··· 130 130 } 131 131 132 132 my $kernelversion; 133 - my ($sphinx_major, $sphinx_minor, $sphinx_patch); 134 133 135 134 my $dohighlight = ""; 136 135 ··· 346 347 $enable_lineno = 1; 347 348 } elsif ($cmd eq 'show-not-found') { 348 349 $show_not_found = 1; # A no-op but don't fail 349 - } elsif ($cmd eq "sphinx-version") { 350 - my $ver_string = shift @ARGV; 351 - if ($ver_string =~ m/^(\d+)(\.\d+)?(\.\d+)?/) { 352 - $sphinx_major = $1; 353 - if (defined($2)) { 354 - $sphinx_minor = substr($2,1); 355 - } else { 356 - $sphinx_minor = 0; 357 - } 358 - if (defined($3)) { 359 - $sphinx_patch = substr($3,1) 360 - } else { 361 - $sphinx_patch = 0; 362 - } 363 - } else { 364 - die "Sphinx version should either major.minor or major.minor.patch format\n"; 365 - } 366 350 } else { 367 351 # Unknown argument 368 352 pod2usage( ··· 369 387 370 388 # continue execution near EOF; 371 389 372 - # The C domain dialect changed on Sphinx 3. So, we need to check the 373 - # version in order to produce the right tags. 374 390 sub findprog($) 375 391 { 376 392 foreach(split(/:/, $ENV{PATH})) { 377 393 return "$_/$_[0]" if(-x "$_/$_[0]"); 378 394 } 379 - } 380 - 381 - sub get_sphinx_version() 382 - { 383 - my $ver; 384 - 385 - my $cmd = "sphinx-build"; 386 - if (!findprog($cmd)) { 387 - my $cmd = "sphinx-build3"; 388 - if (!findprog($cmd)) { 389 - $sphinx_major = 1; 390 - $sphinx_minor = 2; 391 - $sphinx_patch = 0; 392 - printf STDERR "Warning: Sphinx version not found. Using default (Sphinx version %d.%d.%d)\n", 393 - $sphinx_major, $sphinx_minor, $sphinx_patch; 394 - return; 395 - } 396 - } 397 - 398 - open IN, "$cmd --version 2>&1 |"; 399 - while (<IN>) { 400 - if (m/^\s*sphinx-build\s+([\d]+)\.([\d\.]+)(\+\/[\da-f]+)?$/) { 401 - $sphinx_major = $1; 402 - $sphinx_minor = $2; 403 - $sphinx_patch = $3; 404 - last; 405 - } 406 - # Sphinx 1.2.x uses a different format 407 - if (m/^\s*Sphinx.*\s+([\d]+)\.([\d\.]+)$/) { 408 - $sphinx_major = $1; 409 - $sphinx_minor = $2; 410 - $sphinx_patch = $3; 411 - last; 412 - } 413 - } 414 - close IN; 415 395 } 416 396 417 397 # get kernel version from env ··· 803 859 $signature .= ")"; 804 860 } 805 861 806 - if ($sphinx_major < 3) { 862 + if ($args{'typedef'} || $args{'functiontype'} eq "") { 863 + print ".. c:macro:: ". $args{'function'} . "\n\n"; 864 + 807 865 if ($args{'typedef'}) { 808 - print ".. c:type:: ". $args{'function'} . "\n\n"; 809 866 print_lineno($declaration_start_line); 810 867 print " **Typedef**: "; 811 868 $lineprefix = ""; ··· 814 869 print "\n\n**Syntax**\n\n"; 815 870 print " ``$signature``\n\n"; 816 871 } else { 817 - print ".. c:function:: $signature\n\n"; 872 + print "``$signature``\n\n"; 818 873 } 819 874 } else { 820 - if ($args{'typedef'} || $args{'functiontype'} eq "") { 821 - print ".. c:macro:: ". $args{'function'} . "\n\n"; 822 - 823 - if ($args{'typedef'}) { 824 - print_lineno($declaration_start_line); 825 - print " **Typedef**: "; 826 - $lineprefix = ""; 827 - output_highlight_rst($args{'purpose'}); 828 - print "\n\n**Syntax**\n\n"; 829 - print " ``$signature``\n\n"; 830 - } else { 831 - print "``$signature``\n\n"; 832 - } 833 - } else { 834 - print ".. c:function:: $signature\n\n"; 835 - } 875 + print ".. c:function:: $signature\n\n"; 836 876 } 837 877 838 878 if (!$args{'typedef'}) { ··· 885 955 my $count; 886 956 my $outer; 887 957 888 - if ($sphinx_major < 3) { 889 - my $name = "enum " . $args{'enum'}; 890 - print "\n\n.. c:type:: " . $name . "\n\n"; 891 - } else { 892 - my $name = $args{'enum'}; 893 - print "\n\n.. c:enum:: " . $name . "\n\n"; 894 - } 958 + my $name = $args{'enum'}; 959 + print "\n\n.. c:enum:: " . $name . "\n\n"; 960 + 895 961 print_lineno($declaration_start_line); 896 962 $lineprefix = " "; 897 963 output_highlight_rst($args{'purpose'}); ··· 918 992 my $oldprefix = $lineprefix; 919 993 my $name; 920 994 921 - if ($sphinx_major < 3) { 922 - $name = "typedef " . $args{'typedef'}; 923 - } else { 924 - $name = $args{'typedef'}; 925 - } 995 + $name = $args{'typedef'}; 996 + 926 997 print "\n\n.. c:type:: " . $name . "\n\n"; 927 998 print_lineno($declaration_start_line); 928 999 $lineprefix = " "; ··· 935 1012 my ($parameter); 936 1013 my $oldprefix = $lineprefix; 937 1014 938 - if ($sphinx_major < 3) { 939 - my $name = $args{'type'} . " " . $args{'struct'}; 940 - print "\n\n.. c:type:: " . $name . "\n\n"; 1015 + my $name = $args{'struct'}; 1016 + if ($args{'type'} eq 'union') { 1017 + print "\n\n.. c:union:: " . $name . "\n\n"; 941 1018 } else { 942 - my $name = $args{'struct'}; 943 - if ($args{'type'} eq 'union') { 944 - print "\n\n.. c:union:: " . $name . "\n\n"; 945 - } else { 946 - print "\n\n.. c:struct:: " . $name . "\n\n"; 947 - } 1019 + print "\n\n.. c:struct:: " . $name . "\n\n"; 948 1020 } 1021 + 949 1022 print_lineno($declaration_start_line); 950 1023 $lineprefix = " "; 951 1024 output_highlight_rst($args{'purpose'}); ··· 2302 2383 close IN_FILE; 2303 2384 } 2304 2385 2305 - 2306 - if ($output_mode eq "rst") { 2307 - get_sphinx_version() if (!$sphinx_major); 2308 - } 2309 - 2310 2386 $kernelversion = get_kernel_version(); 2311 2387 2312 2388 # generate a sequence of code that will splice in highlighting information ··· 2367 2453 =head2 Output format modifiers 2368 2454 2369 2455 =head3 reStructuredText only 2370 - 2371 - =over 8 2372 - 2373 - =item -sphinx-version VERSION 2374 - 2375 - Use the ReST C domain dialect compatible with a specific Sphinx Version. 2376 - 2377 - If not specified, kernel-doc will auto-detect using the sphinx-build version 2378 - found on PATH. 2379 - 2380 - =back 2381 2456 2382 2457 =head2 Output selection (mutually exclusive): 2383 2458