docs: conf.py: drop backward support for old Sphinx versions

Since commit 5e25b972a2 ("docs: changes: update Python minimal version"),
the minimal Sphinx version is 3.4.3.

Drop support for older versions from the config file.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <20250507121117.317810-1-mchehab+huawei@kernel.org>
This commit is contained in:
Mauro Carvalho Chehab 2025-05-07 14:11:17 +02:00 committed by Jonathan Corbet
parent 1884847909
commit b26717852d

View File

@ -28,16 +28,6 @@ def have_command(cmd):
""" """
return shutil.which(cmd) is not None return shutil.which(cmd) is not None
# Get Sphinx version
major, minor, patch = sphinx.version_info[:3]
#
# Warn about older versions that we don't want to support for much
# longer.
#
if (major < 2) or (major == 2 and minor < 4):
print('WARNING: support for Sphinx < 2.4 will be removed soon.')
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
@ -57,76 +47,71 @@ extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
'maintainers_include', 'sphinx.ext.autosectionlabel', 'maintainers_include', 'sphinx.ext.autosectionlabel',
'kernel_abi', 'kernel_feat', 'translations'] 'kernel_abi', 'kernel_feat', 'translations']
if major >= 3: # Since Sphinx version 3, the C function parser is more pedantic with regards
if (major > 3) or (minor > 0 or patch >= 2): # to type checking. Due to that, having macros at c:function cause problems.
# Sphinx c function parser is more pedantic with regards to type # Those needed to be escaped by using c_id_attributes[] array
# checking. Due to that, having macros at c:function cause problems. c_id_attributes = [
# Those needed to be scaped by using c_id_attributes[] array # GCC Compiler types not parsed by Sphinx:
c_id_attributes = [ "__restrict__",
# GCC Compiler types not parsed by Sphinx:
"__restrict__",
# include/linux/compiler_types.h: # include/linux/compiler_types.h:
"__iomem", "__iomem",
"__kernel", "__kernel",
"noinstr", "noinstr",
"notrace", "notrace",
"__percpu", "__percpu",
"__rcu", "__rcu",
"__user", "__user",
"__force", "__force",
"__counted_by_le", "__counted_by_le",
"__counted_by_be", "__counted_by_be",
# include/linux/compiler_attributes.h: # include/linux/compiler_attributes.h:
"__alias", "__alias",
"__aligned", "__aligned",
"__aligned_largest", "__aligned_largest",
"__always_inline", "__always_inline",
"__assume_aligned", "__assume_aligned",
"__cold", "__cold",
"__attribute_const__", "__attribute_const__",
"__copy", "__copy",
"__pure", "__pure",
"__designated_init", "__designated_init",
"__visible", "__visible",
"__printf", "__printf",
"__scanf", "__scanf",
"__gnu_inline", "__gnu_inline",
"__malloc", "__malloc",
"__mode", "__mode",
"__no_caller_saved_registers", "__no_caller_saved_registers",
"__noclone", "__noclone",
"__nonstring", "__nonstring",
"__noreturn", "__noreturn",
"__packed", "__packed",
"__pure", "__pure",
"__section", "__section",
"__always_unused", "__always_unused",
"__maybe_unused", "__maybe_unused",
"__used", "__used",
"__weak", "__weak",
"noinline", "noinline",
"__fix_address", "__fix_address",
"__counted_by", "__counted_by",
# include/linux/memblock.h: # include/linux/memblock.h:
"__init_memblock", "__init_memblock",
"__meminit", "__meminit",
# include/linux/init.h: # include/linux/init.h:
"__init", "__init",
"__ref", "__ref",
# include/linux/linkage.h: # include/linux/linkage.h:
"asmlinkage", "asmlinkage",
# include/linux/btf.h # include/linux/btf.h
"__bpf_kfunc", "__bpf_kfunc",
] ]
else:
extensions.append('cdomain')
# Ensure that autosectionlabel will produce unique names # Ensure that autosectionlabel will produce unique names
autosectionlabel_prefix_document = True autosectionlabel_prefix_document = True
@ -149,10 +134,6 @@ if 'SPHINX_IMGMATH' in os.environ:
else: else:
sys.stderr.write("Unknown env SPHINX_IMGMATH=%s ignored.\n" % env_sphinx_imgmath) sys.stderr.write("Unknown env SPHINX_IMGMATH=%s ignored.\n" % env_sphinx_imgmath)
# Always load imgmath for Sphinx <1.8 or for epub docs
load_imgmath = (load_imgmath or (major == 1 and minor < 8)
or 'epub' in sys.argv)
if load_imgmath: if load_imgmath:
extensions.append("sphinx.ext.imgmath") extensions.append("sphinx.ext.imgmath")
math_renderer = 'imgmath' math_renderer = 'imgmath'
@ -322,14 +303,6 @@ if "DOCS_CSS" in os.environ:
for l in css: for l in css:
html_css_files.append(l) html_css_files.append(l)
if major <= 1 and minor < 8:
html_context = {
'css_files': [],
}
for l in html_css_files:
html_context['css_files'].append('_static/' + l)
if html_theme == 'alabaster': if html_theme == 'alabaster':
html_theme_options = { html_theme_options = {
'description': get_cline_version(), 'description': get_cline_version(),
@ -409,11 +382,6 @@ latex_elements = {
''', ''',
} }
# Fix reference escape troubles with Sphinx 1.4.x
if major == 1:
latex_elements['preamble'] += '\\renewcommand*{\\DUrole}[2]{ #2 }\n'
# Load kerneldoc specific LaTeX settings # Load kerneldoc specific LaTeX settings
latex_elements['preamble'] += ''' latex_elements['preamble'] += '''
% Load kerneldoc specific LaTeX settings % Load kerneldoc specific LaTeX settings