Commit b2671785 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Jonathan Corbet
Browse files

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



Since commit 5e25b972 ("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: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
Message-ID: <20250507121117.317810-1-mchehab+huawei@kernel.org>
parent 18848479
Loading
Loading
Loading
Loading
+65 −97
Original line number Diff line number Diff line
@@ -28,16 +28,6 @@ def have_command(cmd):
    """
    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,
# 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.
@@ -57,11 +47,9 @@ extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
              'maintainers_include', 'sphinx.ext.autosectionlabel',
              'kernel_abi', 'kernel_feat', 'translations']

if major >= 3:
    if (major > 3) or (minor > 0 or patch >= 2):
        # Sphinx c function parser is more pedantic with regards to type
        # checking. Due to that, having macros at c:function cause problems.
        # Those needed to be scaped by using c_id_attributes[] array
# Since Sphinx version 3, the C function parser is more pedantic with regards
# to type checking. Due to that, having macros at c:function cause problems.
# Those needed to be escaped by using c_id_attributes[] array
c_id_attributes = [
    # GCC Compiler types not parsed by Sphinx:
    "__restrict__",
@@ -125,9 +113,6 @@ if major >= 3:
    "__bpf_kfunc",
]

else:
    extensions.append('cdomain')

# Ensure that autosectionlabel will produce unique names
autosectionlabel_prefix_document = True
autosectionlabel_maxdepth = 2
@@ -149,10 +134,6 @@ if 'SPHINX_IMGMATH' in os.environ:
    else:
        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:
    extensions.append("sphinx.ext.imgmath")
    math_renderer = 'imgmath'
@@ -322,14 +303,6 @@ if "DOCS_CSS" in os.environ:
    for l in css:
        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':
    html_theme_options = {
        '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
latex_elements['preamble'] += '''
        % Load kerneldoc specific LaTeX settings