# Suitable versions of Sphinx for building different versions of CMake Docs?

**URL:** https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982
**Category:** Development
**Created:** [April 25, 2023, 5:01pm UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982 "2023-04-25T17:01:33Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)
#### Post date: [April 25, 2023, 5:01pm UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/1 "2023-04-25T17:01:33Z")

</div>

Recently, I tried to configure and build the [`CMakeHelp`](https://github.com/Kitware/CMake/blob/v3.26.3/Utilities/Sphinx/CMakeLists.txt#L19) project directly to generate CMake Docs locally. The following commands are my simple test of using `Sphinx-6.2.1` to build the `CMakeHelp` of `v3.18.6` tag:

```plaintext
sphinx-build --version
git clone --depth 1 --no-single-branch https://github.com/Kitware/CMake.git
cd CMake
git checkout v3.18.6 --quiet
git describe --tag
mkdir build && cd build
cmake ../Utilities/Sphinx -GNinja -DSPHINX_HTML=ON -DSPHINX_FLAGS="-A versionswitch=1"
cmake --build .

```

However, I found that the latest Sphinx version (currently, `6.2.1`) cannot handle some previous versions of CMake Docs. The following error is generated by the above commands:

```auto
Extension error:
Could not import extension cmake (exception: No module named 'sphinx.util.pycompat')
ninja: build stopped: subcommand failed.

```

> **Click to expand the full logs**
>
> ```plaintext
> D:\Repo\tmp>sphinx-build --version
> sphinx-build 6.2.1
> 
> D:\Repo\tmp>git clone --depth 1 --no-single-branch https://github.com/Kitware/CMake.git
> Cloning into 'CMake'...
> remote: Enumerating objects: 79159, done.
> remote: Counting objects: 100% (79159/79159), done.
> remote: Compressing objects: 100% (37657/37657), done.
> remote: Total 79159 (delta 52343), reused 62038 (delta 38466), pack-reused 0
> Receiving objects: 100% (79159/79159), 48.72 MiB | 4.45 MiB/s, done.
> Resolving deltas: 100% (52343/52343), done.
> Updating files: 100% (22981/22981), done.
> 
> D:\Repo\tmp>cd CMake
> 
> D:\Repo\tmp\CMake>git checkout v3.18.6 --quiet
> 
> D:\Repo\tmp\CMake>git describe --tag
> v3.18.6
> 
> D:\Repo\tmp\CMake>mkdir build && cd build
> 
> D:\Repo\tmp\CMake\build>cmake ../Utilities/Sphinx -GNinja -DSPHINX_HTML=ON -DSPHINX_FLAGS="-A versionswitch=1"
> -- Configuring done
> -- Generating done
> -- Build files have been written to: D:/Repo/tmp/CMake/build
> 
> D:\Repo\tmp\CMake\build>cmake --build .
> [1/1] sphinx-build html: see Utilities/Sphinx/build-html.log
> FAILED: doc_format_html D:/Repo/tmp/CMake/build/doc_format_html
> cmd.exe /C "cd /D D:\Repo\tmp\CMake\build && C:\Python\Python310\Scripts\sphinx-build.exe -c D:/Repo/tmp/CMake/build -d D:/Repo/tmp/CMake/build/doctrees -b html -A versionswitch=1 D:/Repo/tmp/CMake/Help D:/Repo/tmp/CMake/build/html > build-html.log"
> 
> Extension error:
> Could not import extension cmake (exception: No module named 'sphinx.util.pycompat')
> ninja: build stopped: subcommand failed.
> 
> ```

Even though I downgraded the Sphinx gradually, I still met some other different errors sometimes, which bothers me a lot.

Can CMake Team tell me which versions of Sphinx are suitable for building different versions of CMake Docs?

cc: @brad.king @craig.scott

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [April 25, 2023, 6:08pm UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/2 "2023-04-25T18:08:35Z")

</div>

For reference, [CMake MR 8324](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8324) removed some compatibility code, so CMake 3.27’s docs will require Sphinx 2.x or higher.

If it still doesn’t build with the newest version of Sphinx, further merge requests are welcome to address that.

We do not maintain a mapping of CMake version to Sphinx version, but old CMake versions cannot be expected to support newer Sphinx versions that have removed compatibility with old Sphinx versions.

---

<div class="post-metadata">

### Author: ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)
#### Post date: [April 25, 2023, 7:55pm UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/3 "2023-04-25T19:55:28Z")

</div>

I noticed that there is an information about the version of Sphinx used to build the CMake Docs in the bottom of page. Maybe I can take it for reference:

![image](https://discourse.cmake.org/uploads/default/original/2X/f/fb7fafea6f68ace0a71e9171dc85029d51b9e3ba.png)

---

<div class="post-metadata">

### Author: ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)
#### Post date: [April 25, 2023, 8:12pm UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/4 "2023-04-25T20:12:55Z")

</div>

cc: @brad.king

I found another problem when building the older version of CMake Docs:

- Sphinx: `2.4.4`
- CMake Docs: `v3.11.4`

The followings are the commands I used to build the CMake Docs:

```plaintext
sphinx-build --version
git clone --depth 1 --no-single-branch https://github.com/Kitware/CMake.git
cd CMake
git checkout v3.11.4 --quiet
git describe --tag
mkdir build && cd build
cmake ../Utilities/Sphinx -GNinja -DSPHINX_HTML=ON -DSPHINX_FLAGS="-A versionswitch=1"
cmake --build .

```

Although there is no error showed up, there is an warning:

```auto
WARNING: while setting up extension sphinx.addnodes: node class 'meta' is already registered, its visitors will be overridden

```

> **Click to expand the full logs**
>
> ```plaintext
> D:\Repo\tmp>sphinx-build --version
> sphinx-build 2.4.4
> 
> D:\Repo\tmp>git clone --depth 1 --no-single-branch https://github.com/Kitware/CMake.git
> Cloning into 'CMake'...
> remote: Enumerating objects: 79159, done.
> remote: Counting objects: 100% (79159/79159), done.
> remote: Compressing objects: 100% (37674/37674), done.
> remote: Total 79159 (delta 52339), reused 62025 (delta 38449), pack-reused 0
> Receiving objects: 100% (79159/79159), 48.72 MiB | 4.07 MiB/s, done.
> Resolving deltas: 100% (52339/52339), done.
> Updating files: 100% (22981/22981), done.
> 
> D:\Repo\tmp>cd CMake
> 
> D:\Repo\tmp\CMake>git checkout v3.11.4 --quiet
> 
> D:\Repo\tmp\CMake>git describe --tag
> v3.11.4
> 
> D:\Repo\tmp\CMake>mkdir build && cd build
> 
> D:\Repo\tmp\CMake\build>cmake ../Utilities/Sphinx -GNinja -DSPHINX_HTML=ON -DSPHINX_FLAGS="-A versionswitch=1"
> -- Configuring done
> -- Generating done
> -- Build files have been written to: D:/Repo/tmp/CMake/build
> 
> D:\Repo\tmp\CMake\build>cmake --build .
> [1/1] sphinx-build html: see Utilities/Sphinx/build-html.log
> WARNING: while setting up extension sphinx.addnodes: node class 'meta' is already registered, its visitors will be overridden
> 
> ```

After opening the HTML files generated, I found that the gray background of **“Content”** disappears for some pages:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/f/f873c33a68f1a989cb805b3c196097baf6c58798.png)

Comapred with the CMake Docs [3.11.4](https://cmake.org/cmake/help/v3.11/manual/cmake-commands.7.html) hosted in the `cmake.org`:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/3/36e9a28b9c3a17fb9fa5aa8092f1e18be813b378.png)

I believe this phenomenon is related to the above-mentioned warning. What happened?

---

<div class="post-metadata">

### Author: ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)
#### Post date: [April 26, 2023, 5:41am UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/5 "2023-04-26T05:41:46Z")

</div>

I think I found the solution to this warning:

```auto
WARNING: while setting up extension sphinx.addnodes: node class 'meta' is already registered, its visitors will be overridden

```

It seems that this warning is caused by the version of docutils, which has to be `<0.18`. After I downgrade the `docutils` from `0.18.1` to `0.17.1`, the warning won’t show up again.

- Sphinx: `2.4.4`
- Docutils: `0.17.1`
- CMake Docs: `v3.11.4`

The followings are my demo commands:

```plaintext
pip install docutils==0.17.1
sphinx-build --version
git clone --depth 1 --no-single-branch https://github.com/Kitware/CMake.git
cd CMake
git checkout v3.11.4 --quiet
git describe --tag
mkdir build && cd build
cmake ../Utilities/Sphinx -GNinja -DSPHINX_HTML=ON -DSPHINX_FLAGS="-A versionswitch=1"
cmake --build .

```

> **Click to expand the full logs**
>
> ```plaintext
> D:\Repo\tmp>pip install docutils==0.17.1
> Collecting docutils==0.17.1
> Using cached docutils-0.17.1-py2.py3-none-any.whl (575 kB)
> Installing collected packages: docutils
> Attempting uninstall: docutils
> Found existing installation: docutils 0.18.1
> Uninstalling docutils-0.18.1:
> Successfully uninstalled docutils-0.18.1
> Successfully installed docutils-0.17.1
> 
> D:\Repo\tmp>sphinx-build --version
> sphinx-build 2.4.4
> 
> D:\Repo\tmp>git clone --depth 1 --no-single-branch https://github.com/Kitware/CMake.git
> Cloning into 'CMake'...
> remote: Enumerating objects: 79159, done.
> remote: Counting objects: 100% (79159/79159), done.
> remote: Compressing objects: 100% (37660/37660), done.
> remote: Total 79159 (delta 52339), reused 62041 (delta 38463), pack-reused 0
> Receiving objects: 100% (79159/79159), 48.72 MiB | 3.63 MiB/s, done.
> Resolving deltas: 100% (52339/52339), done.
> Updating files: 100% (22981/22981), done.
> 
> D:\Repo\tmp>cd CMake
> 
> D:\Repo\tmp\CMake>git checkout v3.11.4 --quiet
> 
> D:\Repo\tmp\CMake>git describe --tag
> v3.11.4
> 
> D:\Repo\tmp\CMake>mkdir build && cd build
> 
> D:\Repo\tmp\CMake\build>cmake ../Utilities/Sphinx -GNinja -DSPHINX_HTML=ON -DSPHINX_FLAGS="-A versionswitch=1"
> -- Configuring done
> -- Generating done
> -- Build files have been written to: D:/Repo/tmp/CMake/build
> 
> D:\Repo\tmp\CMake\build>cmake --build .
> [1/1] sphinx-build html: see Utilities/Sphinx/build-html.log
> 
> ```

Reference:

> <https://github.com/sphinx-doc/sphinx/issues/9841#issuecomment-966452425>
>
> \### Describe the bug
> 
> sphinx-build -W -b html -d /tmp/doctrees docs docs/html 
> …Warning, treated as error:
> \`node class 'meta' is already registered, its visitors will be overridden\`
> 
> 
> \### How to Reproduce
> 
> build documentation
> 
> \### Expected behavior
> 
> No warning
> 
> \### Your project
> 
> source is not available
> 
> \### Screenshots
> 
> \_No response\_
> 
> \### OS
> 
> Centos7
> 
> \### Python version
> 
> Python 3.8
> 
> \### Sphinx version
> 
> sphinx==2.3.1
> 
> \### Sphinx extensions
> 
> \-
> 
> \### Extra tools
> 
> \_No response\_
> 
> \### Additional context
> 
> index.rst:
> 
> 
> Welcome to project's documentation!
> =========================================
> 
> .. toctree::
> :maxdepth: 2
> :caption: Contents:
> 
> syntax\_introduction
> 
> 
> 
> Indices and tables
> ==================
> 
> \* :ref:\`genindex\`
> \* :ref:\`modindex\`
> \* :ref:\`search\`

---

<div class="post-metadata">

### Author: ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)
#### Post date: [April 26, 2023, 6:22am UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/6 "2023-04-26T06:22:19Z")

</div>

As for the Extension Error that I mentioned at the beginning:

```auto
Extension error:
Could not import extension cmake (exception: No module named 'sphinx.util.pycompat')
ninja: build stopped: subcommand failed.

```

It seems that it’s because the `pycompact` module is deprecated at `4.0.0` and removed at `6.0.0`.

Therefore, to remove this error, I just need to install the Sphinx with its version `<6.0.0`.

### Testing with Sphinx-5.3.0 (Another extension error)

- Sphinx: `5.3.0`
- CMake Docs: `v3.18.6`

If I install Sphinx with its versions `>=4.0.0` and `<6.0.0`, there will be another extension error showed up:

```auto
Extension error:
Could not import extension cmake (exception: cannot import name 'htmlescape' from 'sphinx.util.pycompat' (C:\Python\Python310\lib\site-packages\sphinx\util\pycompat.py))

```

> **Click to expand the full logs**
>
> ```cmd
> D:\Repo\tmp>sphinx-build --version
> sphinx-build 5.3.0
> 
> D:\Repo\tmp>git clone --depth 1 --no-single-branch https://github.com/Kitware/CMake.git
> Cloning into 'CMake'...
> remote: Enumerating objects: 79159, done.
> remote: Counting objects: 100% (79159/79159), done.
> remote: Compressing objects: 100% (37660/37660), done.
> remote: Total 79159 (delta 52339), reused 62041 (delta 38463), pack-reused 0
> Receiving objects: 100% (79159/79159), 48.72 MiB | 3.41 MiB/s, done.
> Resolving deltas: 100% (52339/52339), done.
> Updating files: 100% (22981/22981), done.
> 
> D:\Repo\tmp>cd CMake
> 
> D:\Repo\tmp\CMake>git checkout v3.18.6 --quiet
> 
> D:\Repo\tmp\CMake>git describe --tag
> v3.18.6
> 
> D:\Repo\tmp\CMake>mkdir build && cd build
> 
> D:\Repo\tmp\CMake\build>cmake ../Utilities/Sphinx -GNinja -DSPHINX_HTML=ON -DSPHINX_FLAGS="-A versionswitch=1"
> -- Configuring done
> -- Generating done
> -- Build files have been written to: D:/Repo/tmp/CMake/build
> 
> D:\Repo\tmp\CMake\build>cmake --build .
> [1/1] sphinx-build html: see Utilities/Sphinx/build-html.log
> FAILED: doc_format_html D:/Repo/tmp/CMake/build/doc_format_html
> cmd.exe /C "cd /D D:\Repo\tmp\CMake\build && C:\Python\Python310\Scripts\sphinx-build.exe -c D:/Repo/tmp/CMake/build -d D:/Repo/tmp/CMake/build/doctrees -b html -A versionswitch=1 D:/Repo/tmp/CMake/Help D:/Repo/tmp/CMake/build/html > build-html.log"
> 
> Extension error:
> Could not import extension cmake (exception: cannot import name 'htmlescape' from 'sphinx.util.pycompat' (C:\Python\Python310\lib\site-packages\sphinx\util\pycompat.py))
> ninja: build stopped: subcommand failed.
> 
> ```

### Testing with Sphinx-3.5.4 (ImportError)

- Sphinx: `3.5.4`
- CMake Docs: `v3.18.6`

If I install Sphinx with its versions `>=3.0.0` and `<4.0.0` , there will be an ImportError showed up:

```auto
ImportError: cannot import name 'Union' from 'types' (C:\Python\Python310\lib\types.py)

```

> **Click to expand the full logs**
>
> ```cmd
> D:\Repo\tmp>sphinx-build --version
> Traceback (most recent call last):
> File "C:\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
> return _run_code(code, main_globals, None,
> File "C:\Python\Python310\lib\runpy.py", line 86, in _run_code
> exec(code, run_globals)
> File "C:\Python\Python310\Scripts\sphinx-build.exe\ __main__.py", line 4, in <module>
> File "C:\Python\Python310\lib\site-packages\sphinx\cmd\build.py", line 25, in <module>
> from sphinx.application import Sphinx
> File "C:\Python\Python310\lib\site-packages\sphinx\application.py", line 32, in <module>
> from sphinx.config import Config
> File "C:\Python\Python310\lib\site-packages\sphinx\config.py", line 23, in <module>
> from sphinx.util import logging
> File "C:\Python\Python310\lib\site-packages\sphinx\util\ __init__.py", line 35, in <module>
> from sphinx.util import smartypants # noqa
> File "C:\Python\Python310\lib\site-packages\sphinx\util\smartypants.py", line 33, in <module>
> from sphinx.util.docutils import __version_info__ as docutils_version
> File "C:\Python\Python310\lib\site-packages\sphinx\util\docutils.py", line 31, in <module>
> from sphinx.util.typing import RoleFunction
> File "C:\Python\Python310\lib\site-packages\sphinx\util\typing.py", line 34, in <module>
> from types import Union as types_Union
> ImportError: cannot import name 'Union' from 'types' (C:\Python\Python310\lib\types.py)
> 
> ```

### Testing with Sphinx-2.4.5 (No error or warning)

- Sphinx: `2.4.5`
- CMake Docs: `v3.18.6`

If I install Sphinx with its versions `<3.0.0`, there will be no error or warning showed up:

> **Click to expand the full logs**
>
> ```cmd
> D:\Repo\tmp>sphinx-build --version
> sphinx-build 2.4.5
> 
> D:\Repo\tmp>git clone --depth 1 --no-single-branch https://github.com/Kitware/CMake.git
> Cloning into 'CMake'...
> remote: Enumerating objects: 79159, done.
> remote: Counting objects: 100% (79159/79159), done.
> remote: Compressing objects: 100% (37660/37660), done.
> remote: Total 79159 (delta 52339), reused 62041 (delta 38463), pack-reused 0
> Receiving objects: 100% (79159/79159), 48.72 MiB | 4.72 MiB/s, done.
> Resolving deltas: 100% (52339/52339), done.
> Updating files: 100% (22981/22981), done.
> 
> D:\Repo\tmp>cd CMake
> 
> D:\Repo\tmp\CMake>git checkout v3.18.6 --quiet
> 
> D:\Repo\tmp\CMake>git describe --tag
> v3.18.6
> 
> D:\Repo\tmp\CMake>mkdir build && cd build
> 
> D:\Repo\tmp\CMake\build>cmake ../Utilities/Sphinx -GNinja -DSPHINX_HTML=ON -DSPHINX_FLAGS="-A versionswitch=1"
> -- Configuring done
> -- Generating done
> -- Build files have been written to: D:/Repo/tmp/CMake/build
> 
> D:\Repo\tmp\CMake\build>cmake --build .
> [1/1] sphinx-build html: see Utilities/Sphinx/build-html.log
> 
> ```
> 
> Reference:
> 
> > <https://github.com/sphinx-doc/sphinx/issues/11125#issuecomment-1381044274>
> >
> > \### Describe the bug
> > 
> > Running Sphinx v6.1.3
> > 
> > Configuration error:
> > There is …a programmable error in your configuration file:
> > 
> > Traceback (most recent call last):
> > File "/usr/local/lib/python3.11/dist-packages/sphinx/config.py", line 351, in eval\_config\_file
> > exec(code, namespace) # NoQA: S102
> > ^^^^^^^^^^^^^^^^^^^^^
> > File "/usr/src/kernel/linux-6.1.5/debian/build/build-doc/Documentation/conf.py", line 39, in \<module\>
> > from load\_config import loadConfig
> > File "/usr/src/kernel/linux-6.1.5/debian/build/build-doc/Documentation/sphinx/load\_config.py", line 6, in \<module\>
> > from sphinx.util.pycompat import execfile\_
> > ModuleNotFoundError: No module named 'sphinx.util.pycompat'
> > 
> > make\[4\]: \*\*\* \[Documentation/Makefile:129: xmldocs\] Error 2
> > make\[3\]: \*\*\* \[Makefile:1791: xmldocs\] Error 2
> > make\[3\]: Leaving directory '/usr/src/kernel/linux-6.1.5/debian/build/build-doc'
> > make\[2\]: \*\*\* \[debian/rules.real:181: debian/stamps/build-doc\] Error 2
> > make\[2\]: Leaving directory '/usr/src/kernel/linux-6.1.5'
> > make\[1\]: \*\*\* \[debian/rules.gen:2817: build-indep\_real\_doc\] Error 2
> > make\[1\]: Leaving directory '/usr/src/kernel/linux-6.1.5'
> > make: \*\*\* \[debian/rules:50: build-indep\] Error 2
> > dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
> > 
> > 
> > \### How to Reproduce
> > compiling the kernel documentation
> > 
> > \`cat \`/usr/src/kernel/linux-6.1.5/debian/build/build-doc/Documentation/conf.py\`
> > \`\`\`
> > \# -\*- coding: utf-8 -\*-
> > \#
> > \# The Linux Kernel documentation build configuration file, created by
> > \# sphinx-quickstart on Fri Feb 12 13:51:46 2016.
> > \#
> > \# This file is execfile()d with the current directory set to its
> > \# containing dir.
> > \#
> > \# Note that not all possible configuration values are present in this
> > \# autogenerated file.
> > \#
> > \# All configuration values have a default; values that are commented out
> > \# serve to show the default.
> > 
> > \`\`\`
> > \`\`\`
> > import sys
> > import os
> > import sphinx
> > import shutil
> > 
> > \# helper
> > \# ------
> > 
> > def have\_command(cmd):
> > \`\`\`
> > """Search \`\`cmd\`\` in the \`\`PATH\`\` environment.
> > 
> > If found, return True.
> > If not found, return False.
> > """
> > \`\`\`
> > \`\`\`
> > return shutil.which(cmd) is not None
> > 
> > \`\`\`
> > \# Get Sphinx version
> > major, minor, patch = sphinx.version\_info\[:3\]
> > 
> > \`\`\`
> > 
> > \`\`\`
> > \# 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.
> > \`\`\`
> > \`\`\`
> > sys.path.insert(0, os.path.abspath('sphinx'))
> > from load\_config import loadConfig
> > \`\`\`
> > 
> > \`\`\`
> > \# -- General configuration ------------------------------------------------
> > 
> > \# If your documentation needs a minimal Sphinx version, state it here.
> > needs\_sphinx = '1.7'
> > 
> > \# Add any Sphinx extension module names here, as strings. They can be
> > \# extensions coming with Sphinx (named 'sphinx.ext.\*') or your custom
> > \# ones.
> > extensions = \['kerneldoc', 'rstFlatTable', 'kernel\_include',
> > 'kfigure', 'sphinx.ext.ifconfig', 'automarkup',
> > 'maintainers\_include', 'sphinx.ext.autosectionlabel',
> > 'kernel\_abi', 'kernel\_feat'\]
> > 
> > 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
> > c\_id\_attributes = \[
> > # GCC Compiler types not parsed by Sphinx:
> > "\_\_restrict\_\_",
> > 
> > # include/linux/compiler\_types.h:
> > "\_\_iomem",
> > "\_\_kernel",
> > "noinstr",
> > "notrace",
> > "\_\_percpu",
> > "\_\_rcu",
> > "\_\_user",
> > 
> > # include/linux/compiler\_attributes.h:
> > "\_\_alias",
> > "\_\_aligned",
> > "\_\_aligned\_largest",
> > "\_\_always\_inline",
> > "\_\_assume\_aligned",
> > "\_\_cold",
> > "\_\_attribute\_const\_\_",
> > "\_\_copy",
> > "\_\_pure",
> > "\_\_designated\_init",
> > "\_\_visible",
> > "\_\_printf",
> > "\_\_scanf",
> > "\_\_gnu\_inline",
> > "\_\_malloc",
> > "\_\_mode",
> > "\_\_no\_caller\_saved\_registers",
> > "\_\_noclone",
> > "\_\_nonstring",
> > "\_\_noreturn",
> > "\_\_packed",
> > "\_\_pure",
> > "\_\_section",
> > "\_\_always\_unused",
> > "\_\_maybe\_unused",
> > "\_\_used",
> > "\_\_weak",
> > "noinline",
> > "\_\_fix\_address",
> > 
> > # include/linux/memblock.h:
> > "\_\_init\_memblock",
> > "\_\_meminit",
> > 
> > # include/linux/init.h:
> > "\_\_init",
> > "\_\_ref",
> > 
> > # include/linux/linkage.h:
> > "asmlinkage",
> > \]
> > 
> > else:
> > extensions.append('cdomain')
> > 
> > \# Ensure that autosectionlabel will produce unique names
> > autosectionlabel\_prefix\_document = True
> > autosectionlabel\_maxdepth = 2
> > \`\`\`
> > 
> > \`\`\`
> > \# Load math renderer:
> > \# For html builder, load imgmath only when its dependencies are met.
> > \# mathjax is the default math renderer since Sphinx 1.8.
> > have\_latex = have\_command('latex')
> > have\_dvipng = have\_command('dvipng')
> > load\_imgmath = have\_latex and have\_dvipng
> > 
> > \# Respect SPHINX\_IMGMATH (for html docs only)
> > if 'SPHINX\_IMGMATH' in os.environ:
> > env\_sphinx\_imgmath = os.environ\['SPHINX\_IMGMATH'\]
> > if 'yes' in env\_sphinx\_imgmath:
> > load\_imgmath = True
> > elif 'no' in env\_sphinx\_imgmath:
> > load\_imgmath = False
> > 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'
> > else:
> > math\_renderer = 'mathjax'
> > 
> > \# Add any paths that contain templates here, relative to this directory.
> > templates\_path = \['\_templates'\]
> > 
> > \# The suffix(es) of source filenames.
> > \# You can specify multiple suffix as a list of string:
> > \# source\_suffix = \['.rst', '.md'\]
> > source\_suffix = '.rst'
> > 
> > \# The encoding of source files.
> > \#source\_encoding = 'utf-8-sig'
> > 
> > \# The master toctree document.
> > master\_doc = 'index'
> > 
> > \# General information about the project.
> > project = 'The Linux Kernel'
> > copyright = 'The kernel development community'
> > author = 'The kernel development community'
> > 
> > \# The version info for the project you're documenting, acts as replacement for
> > \# |version| and |release|, also used in various other places throughout the
> > \# built documents.
> > \#
> > \# In a normal build, version and release are are set to KERNELVERSION and
> > \# KERNELRELEASE, respectively, from the Makefile via Sphinx command line
> > \# arguments.
> > \#
> > \# The following code tries to extract the information by reading the Makefile,
> > \# when Sphinx is run directly (e.g. by Read the Docs).
> > try:
> > makefile\_version = None
> > makefile\_patchlevel = None
> > for line in open('../Makefile'):
> > key, val = \[x.strip() for x in line.split('=', 2)\]
> > if key == 'VERSION':
> > makefile\_version = val
> > elif key == 'PATCHLEVEL':
> > makefile\_patchlevel = val
> > if makefile\_version and makefile\_patchlevel:
> > break
> > except:
> > pass
> > finally:
> > if makefile\_version and makefile\_patchlevel:
> > version = release = makefile\_version + '.' + makefile\_patchlevel
> > else:
> > version = release = "unknown version"
> > 
> > \# The language for content autogenerated by Sphinx. Refer to documentation
> > \# for a list of supported languages.
> > \#
> > \# This is also used if you do content translation via gettext catalogs.
> > \# Usually you set "language" from the command line for these cases.
> > language = 'en'
> > 
> > \# There are two options for replacing |today|: either, you set today to some
> > \# non-false value, then it is used:
> > \#today = ''
> > \# Else, today\_fmt is used as the format for a strftime call.
> > \#today\_fmt = '%B %d, %Y'
> > 
> > \# List of patterns, relative to source directory, that match files and
> > \# directories to ignore when looking for source files.
> > exclude\_patterns = \['output'\]
> > 
> > \# The reST default role (used for this markup: \`text\`) to use for all
> > \# documents.
> > \#default\_role = None
> > 
> > \# If true, '()' will be appended to :func: etc. cross-reference text.
> > \#add\_function\_parentheses = True
> > 
> > \# If true, the current module name will be prepended to all description
> > \# unit titles (such as .. function::).
> > \#add\_module\_names = True
> > 
> > \# If true, sectionauthor and moduleauthor directives will be shown in the
> > \# output. They are ignored by default.
> > \#show\_authors = False
> > 
> > \# The name of the Pygments (syntax highlighting) style to use.
> > pygments\_style = 'sphinx'
> > 
> > \# A list of ignored prefixes for module index sorting.
> > \#modindex\_common\_prefix = \[\]
> > 
> > \# If true, keep warnings as "system message" paragraphs in the built documents.
> > \#keep\_warnings = False
> > 
> > \# If true, \`todo\` and \`todoList\` produce output, else they produce nothing.
> > todo\_include\_todos = False
> > 
> > primary\_domain = 'c'
> > highlight\_language = 'none'
> > 
> > \# -- Options for HTML output ----------------------------------------------
> > 
> > \# The theme to use for HTML and HTML Help pages. See the documentation for
> > \# a list of builtin themes.
> > 
> > \# Default theme
> > html\_theme = 'sphinx\_rtd\_theme'
> > html\_css\_files = \[\]
> > 
> > if "DOCS\_THEME" in os.environ:
> > html\_theme = os.environ\["DOCS\_THEME"\]
> > 
> > if html\_theme == 'sphinx\_rtd\_theme' or html\_theme == 'sphinx\_rtd\_dark\_mode':
> > # Read the Docs theme
> > try:
> > import sphinx\_rtd\_theme
> > html\_theme\_path = \[sphinx\_rtd\_theme.get\_html\_theme\_path()\]
> > 
> > # Add any paths that contain custom static files (such as style sheets) here,
> > # relative to this directory. They are copied after the builtin static files,
> > # so a file named "default.css" will overwrite the builtin "default.css".
> > html\_css\_files = \[
> > 'theme\_overrides.css',
> > \]
> > 
> > # Read the Docs dark mode override theme
> > if html\_theme == 'sphinx\_rtd\_dark\_mode':
> > try:
> > import sphinx\_rtd\_dark\_mode
> > extensions.append('sphinx\_rtd\_dark\_mode')
> > except ImportError:
> > html\_theme == 'sphinx\_rtd\_theme'
> > 
> > if html\_theme == 'sphinx\_rtd\_theme':
> > # Add color-specific RTD normal mode
> > html\_css\_files.append('theme\_rtd\_colors.css')
> > 
> > except ImportError:
> > html\_theme = 'classic'
> > 
> > if "DOCS\_CSS" in os.environ:
> > css = os.environ\["DOCS\_CSS"\].split(" ")
> > 
> > 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 == 'classic':
> > html\_theme\_options = {
> > 'rightsidebar': False,
> > 'stickysidebar': True,
> > 'collapsiblesidebar': True,
> > 'externalrefs': False,
> > 
> > 'footerbgcolor': "white",
> > 'footertextcolor': "white",
> > 'sidebarbgcolor': "white",
> > 'sidebarbtncolor': "black",
> > 'sidebartextcolor': "black",
> > 'sidebarlinkcolor': "#686bff",
> > 'relbarbgcolor': "#133f52",
> > 'relbartextcolor': "white",
> > 'relbarlinkcolor': "white",
> > 'bgcolor': "white",
> > 'textcolor': "black",
> > 'headbgcolor': "#f2f2f2",
> > 'headtextcolor': "#20435c",
> > 'headlinkcolor': "#c60f0f",
> > 'linkcolor': "#355f7c",
> > 'visitedlinkcolor': "#355f7c",
> > 'codebgcolor': "#3f3f3f",
> > 'codetextcolor': "white",
> > 
> > 'bodyfont': "serif",
> > 'headfont': "sans-serif",
> > }
> > 
> > sys.stderr.write("Using %s theme\\n" % html\_theme)
> > 
> > \# Theme options are theme-specific and customize the look and feel of a theme
> > \# further. For a list of options available for each theme, see the
> > \# documentation.
> > \#html\_theme\_options = {}
> > 
> > \# Add any paths that contain custom themes here, relative to this directory.
> > \#html\_theme\_path = \[\]
> > 
> > \# The name for this set of Sphinx documents. If None, it defaults to
> > \# "\<project\> v\<release\> documentation".
> > \#html\_title = None
> > 
> > \# A shorter title for the navigation bar. Default is the same as html\_title.
> > \#html\_short\_title = None
> > 
> > \# The name of an image file (relative to this directory) to place at the top
> > \# of the sidebar.
> > \#html\_logo = None
> > 
> > \# The name of an image file (within the static path) to use as favicon of the
> > \# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
> > \# pixels large.
> > \#html\_favicon = None
> > 
> > \# Add any paths that contain custom static files (such as style sheets) here,
> > \# relative to this directory. They are copied after the builtin static files,
> > \# so a file named "default.css" will overwrite the builtin "default.css".
> > html\_static\_path = \['sphinx-static'\]
> > 
> > \# Add any extra paths that contain custom files (such as robots.txt or
> > \# .htaccess) here, relative to this directory. These files are copied
> > \# directly to the root of the documentation.
> > \#html\_extra\_path = \[\]
> > 
> > \# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
> > \# using the given strftime format.
> > \#html\_last\_updated\_fmt = '%b %d, %Y'
> > 
> > \# If true, SmartyPants will be used to convert quotes and dashes to
> > \# typographically correct entities.
> > html\_use\_smartypants = False
> > 
> > \# Custom sidebar templates, maps document names to template names.
> > \# Note that the RTD theme ignores this.
> > html\_sidebars = { '\*\*': \['searchbox.html', 'localtoc.html', 'sourcelink.html'\]}
> > 
> > \# Additional templates that should be rendered to pages, maps page names to
> > \# template names.
> > \#html\_additional\_pages = {}
> > 
> > \# If false, no module index is generated.
> > \#html\_domain\_indices = True
> > 
> > \# If false, no index is generated.
> > \#html\_use\_index = True
> > 
> > \# If true, the index is split into individual pages for each letter.
> > \#html\_split\_index = False
> > 
> > \# If true, links to the reST sources are added to the pages.
> > \#html\_show\_sourcelink = True
> > 
> > \# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
> > \#html\_show\_sphinx = True
> > 
> > \# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
> > \#html\_show\_copyright = True
> > 
> > \# If true, an OpenSearch description file will be output, and all pages will
> > \# contain a \<link\> tag referring to it. The value of this option must be the
> > \# base URL from which the finished HTML is served.
> > \#html\_use\_opensearch = ''
> > 
> > \# This is the file name suffix for HTML files (e.g. ".xhtml").
> > \#html\_file\_suffix = None
> > 
> > \# Language to be used for generating the HTML full-text search index.
> > \# Sphinx supports the following languages:
> > \# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
> > \# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
> > \#html\_search\_language = 'en'
> > 
> > \# A dictionary with options for the search language support, empty by default.
> > \# Now only 'ja' uses this config value
> > \#html\_search\_options = {'type': 'default'}
> > 
> > \# The name of a javascript file (relative to the configuration directory) that
> > \# implements a search results scorer. If empty, the default will be used.
> > \#html\_search\_scorer = 'scorer.js'
> > 
> > \# Output file base name for HTML help builder.
> > htmlhelp\_basename = 'TheLinuxKerneldoc'
> > 
> > \# -- Options for LaTeX output ---------------------------------------------
> > 
> > latex\_elements = {
> > # The paper size ('letterpaper' or 'a4paper').
> > 'papersize': 'a4paper',
> > 
> > # The font size ('10pt', '11pt' or '12pt').
> > 'pointsize': '11pt',
> > 
> > # Latex figure (float) alignment
> > #'figure\_align': 'htbp',
> > 
> > # Don't mangle with UTF-8 chars
> > 'inputenc': '',
> > 'utf8extra': '',
> > 
> > # Set document margins
> > 'sphinxsetup': '''
> > hmargin=0.5in, vmargin=1in,
> > parsedliteralwraps=true,
> > verbatimhintsturnover=false,
> > ''',
> > 
> > # For CJK One-half spacing, need to be in front of hyperref
> > 'extrapackages': r'\\usepackage{setspace}',
> > 
> > # Additional stuff for the LaTeX preamble.
> > 'preamble': '''
> > % Use some font with UTF-8 support with XeLaTeX
> > \\\\usepackage{fontspec}
> > \\\\setsansfont{DejaVu Sans}
> > \\\\setromanfont{DejaVu Serif}
> > \\\\setmonofont{DejaVu Sans Mono}
> > ''',
> > }
> > 
> > \# 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
> > \\\\input{kerneldoc-preamble.sty}
> > '''
> > 
> > \# With Sphinx 1.6, it is possible to change the Bg color directly
> > \# by using:
> > \#	\\definecolor{sphinxnoteBgColor}{RGB}{204,255,255}
> > \#	\\definecolor{sphinxwarningBgColor}{RGB}{255,204,204}
> > \#	\\definecolor{sphinxattentionBgColor}{RGB}{255,255,204}
> > \#	\\definecolor{sphinximportantBgColor}{RGB}{192,255,204}
> > \#
> > \# However, it require to use sphinx heavy box with:
> > \#
> > \#	\\renewenvironment{sphinxlightbox} {%
> > \# \\\\begin{sphinxheavybox}
> > \#	}
> > \# \\\\end{sphinxheavybox}
> > \#	}
> > \#
> > \# Unfortunately, the implementation is buggy: if a note is inside a
> > \# table, it isn't displayed well. So, for now, let's use boring
> > \# black and white notes.
> > 
> > \# Grouping the document tree into LaTeX files. List of tuples
> > \# (source start file, target name, title,
> > \# author, documentclass \[howto, manual, or own class\]).
> > \# Sorted in alphabetical order
> > latex\_documents = \[
> > \]
> > 
> > \# Add all other index files from Documentation/ subdirectories
> > for fn in os.listdir('.'):
> > doc = os.path.join(fn, "index")
> > if os.path.exists(doc + ".rst"):
> > has = False
> > for l in latex\_documents:
> > if l\[0\] == doc:
> > has = True
> > break
> > if not has:
> > latex\_documents.append((doc, fn + '.tex',
> > 'Linux %s Documentation' % fn.capitalize(),
> > 'The kernel development community',
> > 'manual'))
> > 
> > \# The name of an image file (relative to this directory) to place at the top of
> > \# the title page.
> > \#latex\_logo = None
> > 
> > \# For "manual" documents, if this is true, then toplevel headings are parts,
> > \# not chapters.
> > \#latex\_use\_parts = False
> > 
> > \# If true, show page references after internal links.
> > \#latex\_show\_pagerefs = False
> > 
> > \# If true, show URL addresses after external links.
> > \#latex\_show\_urls = False
> > 
> > \# Documents to append as an appendix to all manuals.
> > \#latex\_appendices = \[\]
> > 
> > \# If false, no module index is generated.
> > \#latex\_domain\_indices = True
> > 
> > \# Additional LaTeX stuff to be copied to build directory
> > latex\_additional\_files = \[
> > 'sphinx/kerneldoc-preamble.sty',
> > \]
> > 
> > 
> > \# -- Options for manual page output ---------------------------------------
> > 
> > \# One entry per manual page. List of tuples
> > \# (source start file, name, description, authors, manual section).
> > man\_pages = \[
> > (master\_doc, 'thelinuxkernel', 'The Linux Kernel Documentation',
> > \[author\], 1)
> > \]
> > 
> > \# If true, show URL addresses after external links.
> > \#man\_show\_urls = False
> > 
> > 
> > \# -- Options for Texinfo output -------------------------------------------
> > 
> > \# Grouping the document tree into Texinfo files. List of tuples
> > \# (source start file, target name, title, author,
> > \# dir menu entry, description, category)
> > texinfo\_documents = \[
> > (master\_doc, 'TheLinuxKernel', 'The Linux Kernel Documentation',
> > author, 'TheLinuxKernel', 'One line description of project.',
> > 'Miscellaneous'),
> > \]
> > 
> > \# Documents to append as an appendix to all manuals.
> > \#texinfo\_appendices = \[\]
> > 
> > \# If false, no module index is generated.
> > \#texinfo\_domain\_indices = True
> > 
> > \# How to display URL addresses: 'footnote', 'no', or 'inline'.
> > \#texinfo\_show\_urls = 'footnote'
> > 
> > \# If true, do not generate a @detailmenu in the "Top" node's menu.
> > \#texinfo\_no\_detailmenu = False
> > 
> > 
> > \# -- Options for Epub output ----------------------------------------------
> > 
> > \# Bibliographic Dublin Core info.
> > epub\_title = project
> > epub\_author = author
> > epub\_publisher = author
> > epub\_copyright = copyright
> > 
> > \# The basename for the epub file. It defaults to the project name.
> > \#epub\_basename = project
> > 
> > \# The HTML theme for the epub output. Since the default themes are not
> > \# optimized for small screen space, using the same theme for HTML and epub
> > \# output is usually not wise. This defaults to 'epub', a theme designed to save
> > \# visual space.
> > \#epub\_theme = 'epub'
> > 
> > \# The language of the text. It defaults to the language option
> > \# or 'en' if the language is not set.
> > \#epub\_language = ''
> > 
> > \# The scheme of the identifier. Typical schemes are ISBN or URL.
> > \#epub\_scheme = ''
> > 
> > \# The unique identifier of the text. This can be a ISBN number
> > \# or the project homepage.
> > \#epub\_identifier = ''
> > 
> > \# A unique identification for the text.
> > \#epub\_uid = ''
> > 
> > \# A tuple containing the cover image and cover page html template filenames.
> > \#epub\_cover = ()
> > 
> > \# A sequence of (type, uri, title) tuples for the guide element of content.opf.
> > \#epub\_guide = ()
> > 
> > \# HTML files that should be inserted before the pages created by sphinx.
> > \# The format is a list of tuples containing the path and title.
> > \#epub\_pre\_files = \[\]
> > 
> > \# HTML files that should be inserted after the pages created by sphinx.
> > \# The format is a list of tuples containing the path and title.
> > \#epub\_post\_files = \[\]
> > 
> > \# A list of files that should not be packed into the epub file.
> > epub\_exclude\_files = \['search.html'\]
> > 
> > \# The depth of the table of contents in toc.ncx.
> > \#epub\_tocdepth = 3
> > 
> > \# Allow duplicate toc entries.
> > \#epub\_tocdup = True
> > 
> > \# Choose between 'default' and 'includehidden'.
> > \#epub\_tocscope = 'default'
> > 
> > \# Fix unsupported image types using the Pillow.
> > \#epub\_fix\_images = False
> > 
> > \# Scale large images.
> > \#epub\_max\_image\_width = 0
> > 
> > \# How to display URL addresses: 'footnote', 'no', or 'inline'.
> > \#epub\_show\_urls = 'inline'
> > 
> > \# If false, no index is generated.
> > \#epub\_use\_index = True
> > 
> > \#=======
> > \# rst2pdf
> > \#
> > \# Grouping the document tree into PDF files. List of tuples
> > \# (source start file, target name, title, author, options).
> > \#
> > \# See the Sphinx chapter of https://ralsina.me/static/manual.pdf
> > \#
> > \# FIXME: Do not add the index file here; the result will be too big. Adding
> > \# multiple PDF files here actually tries to get the cross-referencing right
> > \# \*between\* PDF files.
> > pdf\_documents = \[
> > ('kernel-documentation', u'Kernel', u'Kernel', u'J. Random Bozo'),
> > \]
> > 
> > \# kernel-doc extension configuration for running Sphinx directly (e.g. by Read
> > \# the Docs). In a normal build, these are supplied from the Makefile via command
> > \# line arguments.
> > kerneldoc\_bin = '../scripts/kernel-doc'
> > kerneldoc\_srctree = '..'
> > 
> > \# ------------------------------------------------------------------------------
> > \# Since loadConfig overwrites settings from the global namespace, it has to be
> > \# the last statement in the conf.py file
> > \# ------------------------------------------------------------------------------
> > loadConfig(globals())\`
> > 
> > \### Environment Information
> > 
> > \`\`\`text
> > sphinx-build --bug-report
> > Please paste all output below into the bug report template
> > 
> > 
> > 
> > Platform: linux; (Linux-6.2.0-rc3-x86\_64-with-glibc2.36)
> > Python version: 3.11.1 (main, Dec 31 2022, 10:23:59) \[GCC 12.2.0\])
> > Python implementation: CPython
> > Sphinx version: 6.1.3
> > Docutils version: 0.19
> > Jinja2 version: 3.0.3
> > Pygments version: 2.14.0
> > \`\`\`
> > 
> > 
> > \### Sphinx extensions
> > 
> > \_No response\_
> > 
> > \### Additional context
> > 
> > \_No response\_
> > \`\`\`

---

<div class="post-metadata">

### Author: ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)
#### Post date: [June 19, 2023, 12:17pm UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/7 "2023-06-19T12:17:58Z")

</div>

cc: @brad.king

Recently, I met a problem when I use `sphinx <= 2.4.5` to build the documentation of `cmake <= 3.8`. That is, there are lots of warning messages showed up after completing the build, for example:

```auto
WARNING: 4 column based index found. It might be a bug of extensions you use: [('pair', 'variable ; GRAPHVIZ_GRAPH_TYPE', 'variable:GRAPHVIZ_GRAPH_TYPE', 'main')]
WARNING: 4 column based index found. It might be a bug of extensions you use: [('pair', 'variable ; GRAPHVIZ_GRAPH_NAME', 'variable:GRAPHVIZ_GRAPH_NAME', 'main')]
WARNING: 4 column based index found. It might be a bug of extensions you use: [('pair', 'variable ; GRAPHVIZ_GRAPH_HEADER', 'variable:GRAPHVIZ_GRAPH_HEADER', 'main')]

```

and the strange background color of the generated HTML files:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/9/96347a01ab85ba3182df30793d6046578d8b37b6.png)

The followings are the commands I use:

```auto
pip install sphinx==2.4.5 docutils==0.17.1 jinja2==3.0.0
sphinx-build --version
git clone --depth 1 --no-single-branch https://github.com/Kitware/CMake.git
cd CMake
git checkout v3.5.2 --quiet
git describe --tag
mkdir build && cd build
cmake ../Utilities/Sphinx -DSPHINX_HTML=ON -DSPHINX_FLAGS="-A versionswitch=1"
cmake --build .

```

And the following is the log of the above commands:

[log.txt](https://discourse.cmake.org/uploads/short-url/pZDVrdy48AIVgeI7fwPrvZgEylR.txt) (72.6 KB)

Do you know what happened? I guess it might be related to Sphinx’s dependencies. And the followings are the requirements when I install `sphinx==2.4.5`:

```auto
Requirement already satisfied: sphinx==2.4.5 in c:\python\python310\lib\site-packages (2.4.5)
Requirement already satisfied: docutils==0.17.1 in c:\python\python310\lib\site-packages (0.17.1)
Requirement already satisfied: jinja2==3.0.0 in c:\python\python310\lib\site-packages (3.0.0)
Requirement already satisfied: sphinxcontrib-applehelp in c:\python\python310\lib\site-packages (from sphinx==2.4.5) (1.0.2)
Requirement already satisfied: sphinxcontrib-devhelp in c:\python\python310\lib\site-packages (from sphinx==2.4.5) (1.0.2)
Requirement already satisfied: sphinxcontrib-jsmath in c:\python\python310\lib\site-packages (from sphinx==2.4.5) (1.0.1)
Requirement already satisfied: sphinxcontrib-htmlhelp in c:\python\python310\lib\site-packages (from sphinx==2.4.5) (2.0.0)
Requirement already satisfied: sphinxcontrib-serializinghtml in c:\python\python310\lib\site-packages (from sphinx==2.4.5) (1.1.5)
Requirement already satisfied: sphinxcontrib-qthelp in c:\python\python310\lib\site-packages (from sphinx==2.4.5) (1.0.3)
Requirement already satisfied: Pygments>=2.0 in c:\users\hwhsu1231\appdata\roaming\python\python310\site-packages (from sphinx==2.4.5) (2.14.0)
Requirement already satisfied: snowballstemmer>=1.1 in c:\python\python310\lib\site-packages (from sphinx==2.4.5) (2.2.0)
Requirement already satisfied: babel!=2.0,>=1.3 in c:\python\python310\lib\site-packages (from sphinx==2.4.5) (2.11.0)
Requirement already satisfied: alabaster<0.8,>=0.7 in c:\python\python310\lib\site-packages (from sphinx==2.4.5) (0.7.12)
Requirement already satisfied: imagesize in c:\python\python310\lib\site-packages (from sphinx==2.4.5) (1.4.1)
Requirement already satisfied: requests>=2.5.0 in c:\python\python310\lib\site-packages (from sphinx==2.4.5) (2.28.1)
Requirement already satisfied: setuptools in c:\python\python310\lib\site-packages (from sphinx==2.4.5) (59.8.0)
Requirement already satisfied: packaging in c:\users\hwhsu1231\appdata\roaming\python\python310\site-packages (from sphinx==2.4.5) (23.0)
Requirement already satisfied: colorama>=0.3.5 in c:\users\hwhsu1231\appdata\roaming\python\python310\site-packages (from sphinx==2.4.5) (0.4.6)
Requirement already satisfied: MarkupSafe>=2.0.0rc2 in c:\python\python310\lib\site-packages (from jinja2==3.0.0) (2.1.1)
Requirement already satisfied: pytz>=2015.7 in c:\python\python310\lib\site-packages (from babel!=2.0,>=1.3->sphinx==2.4.5) (2022.6)
Requirement already satisfied: charset-normalizer<3,>=2 in c:\python\python310\lib\site-packages (from requests>=2.5.0->sphinx==2.4.5) (2.1.1)
Requirement already satisfied: idna<4,>=2.5 in c:\users\hwhsu1231\appdata\roaming\python\python310\site-packages (from requests>=2.5.0->sphinx==2.4.5) (2.8)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\python\python310\lib\site-packages (from requests>=2.5.0->sphinx==2.4.5) (1.26.12)
Requirement already satisfied: certifi>=2017.4.17 in c:\python\python310\lib\site-packages (from requests>=2.5.0->sphinx==2.4.5) (2022.9.14)

```

---

<div class="post-metadata">

### Author: ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)
#### Post date: [March 3, 2024, 2:14am UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/8 "2024-03-03T02:14:30Z")

</div>

> [@brad.king](#):
>
> We do not maintain a mapping of CMake version to Sphinx version, but old CMake versions cannot be expected to support newer Sphinx versions that have removed compatibility with old Sphinx versions.

Hello, CMake Team. There’s something I want to confirm. Is it:

1. **technically impossible** , or
2. **technically possible but just lack of motivation**

to maintain those old CMake versions (ex. 3.0, 3.1, 3.2,…etc) to upgrade their Sphinx version to the latest?

For example, if CMake upgrades its Sphinx version to `v7.2.6` in `master` version, then all of the previous released versions, 3.0~3.28(the current latest release), will upgrade their Sphinx as well. Is it technically possible to do so?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 29, 2024, 11:26am UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/9 "2024-03-29T11:26:15Z")

</div>

> [@hwhsu1231](#):
>
> Is it technically possible to do so?

I suspect other changes may need backported to those source trees. But CMake generates its docs from the source tree, so some tracking of how to update these releases to newer Sphinx would best be tracked in the history as well (basically, branch off of the last 3.0.x release, update it to work with new Sphinx, then regenerate and merge the changes into `master` with `-s ours` for tracking purposes). What would be the benefit of regenerating the docs?

---

<div class="post-metadata">

### Author: ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)
#### Post date: [March 31, 2024, 1:14pm UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/10 "2024-03-31T13:14:08Z")

</div>

> [@ben.boeckel](#):
>
> What would be the benefit of regenerating the docs?

Hello, @ben.boeckel

Over the past months, I’ve been working on making the localization project for CMake Documentation (using Sphinx’s [Internationalization](https://www.sphinx-doc.org/en/master/usage/advanced/intl.html)), in which I also designed the mechanism to translate all the possible versions listed in the version switcher: `v3.0~v3.xx`, `latest`, and `git-master`. The following screenshot is the demo result:

 ![Screenshot_20240313_125108](https://discourse.cmake.org/uploads/default/original/2X/1/1b64ccce9c2c47494ef2d7f15dd29a50f3b51021.png)

In short, my localization project will store the generated Gettext .po files, so that CMake can use these .po files to build its documentation in mulitple languages. (Just like [Python Documentation](https://docs.python.org/3/))

However, there are some restrictions when building different versions of CMake Documentation:

- For `v3.0~v3.8`, we should use sphinx-1.6.1
- For `v3.9~v3.18`, we should use sphinx-2.4.5
- For `v3.19~v3.27`, we should use sphinx-5.3.0
- For `v3.28~`, we can use sphinx-6.3.0

Besides, based on this [topic](https://discourse.cmake.org/t/how-did-cmake-documentation-deal-with-its-version-switcher-before-v3-9-0/8490), it seems that the version switcher must be added manually to the generated html documentation before `v3.9.0`.

Therefore, I hope that CMake Team can fix those older versions, and they had better being able to use the same version of Sphinx as the `latest` version uses.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [March 31, 2024, 11:12pm UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/11 "2024-03-31T23:12:46Z")

</div>

Maybe something for its own dedicated thread, but do you only intend to translate past releases, or also the current release? There are often documentation updates for the current release, and I’m wondering how you plan to ensure all translations pick up those doc updates. It won’t be feasible to expect any contributors or the CMake maintainers to notify you or anyone else when such doc updates are made, so you’d need some way to detect or be notified of this yourself.

I also expect there to be some challenges during the release candidate phase of a new release, unless you don’t intend to do any translations until after the release candidate stage (i.e. only for formal .0 releases or later).

---

<div class="post-metadata">

### Author: ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)
#### Post date: [April 1, 2024, 2:49am UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/12 "2024-04-01T02:49:26Z")

</div>

Hello, @craig.scott

> [@craig.scott](#):
>
> Maybe something for its own dedicated thread, but do you only intend to translate past releases, or also the current release? There are often documentation updates for the current release, and I’m wondering how you plan to ensure all translations pick up those doc updates. It won’t be feasible to expect any contributors or the CMake maintainers to notify you or anyone else when such doc updates are made, so you’d need some way to detect or be notified of this yourself.

Don’t worry about this. I’ve writen a series of GitHub Workflows to help me update each version.

- For `git-master` version, if there exist new commits, it will update and create a PR.
- For `v3.x` or `latest` version, if there exist new tags, it will update and create a PR.
- …etc.

When I was designing this project, I took into consideration that even if I were the only one maintaining it, I could do so without any stress.

> [@craig.scott](#):
>
> I also expect there to be some challenges during the release candidate phase of a new release, unless you don’t intend to do any translations until after the release candidate stage (i.e. only for formal .0 releases or later).

I’ve also considered the release candidate as well. The following is what I wrote for detecting the latest tag of each release version. You can take a look.

> **Click to expand**
>
> ```cmake
> function(get_git_latest_tag_on_tag_pattern)
> #
> # Parse arguments.
> #
> set(TAG_OPTIONS)
> set(TAG_ONE_VALUE_ARGS IN_REPO_PATH 
> IN_TAG_PATTERN 
> OUT_TAG)
> set(TAG_MULTI_VALUE_ARGS)
> cmake_parse_arguments(ARGS 
> "${TAG_OPTIONS}"
> "${TAG_ONE_VALUE_ARGS}"
> "${TAG_MULTI_VALUE_ARGS}"
> ${ARGN})
> #
> # Ensure all required arguments are provided.
> #
> set(REQUIRED_ARGS IN_REPO_PATH 
> IN_TAG_PATTERN 
> OUT_TAG)
> foreach(ARG ${REQUIRED_ARGS})
> if(NOT DEFINED ARGS_${ARG})
> message(FATAL_ERROR "Missing ARGS_${ARG} argument.")
> endif()
> endforeach()
> if(NOT EXISTS "${Git_EXECUTABLE}")
> find_package(Git QUIET MODULE REQUIRED)
> endif()
> #
> # Get a list of tags matching the tag pattern.
> #
> execute_process(
> COMMAND "${Git_EXECUTABLE}" tag --list
> --sort=-v:refname
> "${ARGS_IN_TAG_PATTERN}"
> WORKING_DIRECTORY "${PROJ_OUT_REPO_DIR}"
> RESULT_VARIABLE RES_VAR
> OUTPUT_VARIABLE OUT_VAR
> ERROR_VARIABLE ERR_VAR
> OUTPUT_STRIP_TRAILING_WHITESPACE
> ERROR_STRIP_TRAILING_WHITESPACE)
> string(REPLACE "\n" ";" TAG_LIST "${OUT_VAR}")
> #
> # Get a list of release candidate tags matching the tag pattern.
> #
> execute_process(
> COMMAND "${Git_EXECUTABLE}" tag --list
> --sort=-v:refname
> "${ARGS_IN_TAG_PATTERN}-rc*"
> WORKING_DIRECTORY "${PROJ_OUT_REPO_DIR}"
> RESULT_VARIABLE RES_VAR
> OUTPUT_VARIABLE OUT_VAR
> ERROR_VARIABLE ERR_VAR
> OUTPUT_STRIP_TRAILING_WHITESPACE
> ERROR_STRIP_TRAILING_WHITESPACE)
> string(REPLACE "\n" ";" TAG_RC_LIST "${OUT_VAR}")
> #
> # Get a list of release tags matching the tag pattern.
> #
> set(TAG_REL_LIST "${TAG_LIST}")
> list(REMOVE_ITEM TAG_REL_LIST ${TAG_RC_LIST})
> #
> # Get the max release candidate tag.
> #
> if(TAG_RC_LIST)
> list(GET TAG_RC_LIST 0 TAG_RC_MAX)
> else()
> set(TAG_RC_MAX)
> endif()
> #
> # Get the max release tag.
> #
> if(TAG_REL_LIST)
> list(GET TAG_REL_LIST 0 TAG_REL_MAX)
> else()
> set(TAG_REL_MAX)
> endif()
> #
> # If there exists ${TAG_REL_MAX}, consider release version.
> # Otherwise, consider release candidate version.
> #
> if(NOT TAG_REL_MAX STREQUAL "")
> set(LATEST_TAG ${TAG_REL_MAX})
> else()
> if(NOT TAG_RC_MAX STREQUAL "")
> set(LATEST_TAG ${TAG_RC_MAX})
> else()
> message(FATAL_ERROR "There is no available tag on ${ARGS_IN_TAG_PATTERN}")
> endif()
> endif()
> #
> # Return the latest tag on ${ARGS_IN_TAG_PATTERN}.
> #
> set(${ARGS_OUT_TAG} "${LATEST_TAG}" PARENT_SCOPE)
> endfunction()
> 
> ```

---

<div class="post-metadata">

### Author: ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)
#### Post date: [April 19, 2024, 4:58pm UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/13 "2024-04-19T16:58:51Z")

</div>

Hello, CMake Team.

From the research of this [topic](https://discourse.cmake.org/t/failed-to-translate-the-content-of-parsed-literal-directive-with-hyperlinks-in-cmake-1-rst/10541), it appears that the [issue](https://github.com/sphinx-doc/sphinx/issues/12287) is actually a bug from Sphinx itself. Therefore, it can be resolved by fixing the issue in a new version of Sphinx. However, some old versions of CMake files can only be built using old versions of Sphinx, so they won’t be able to fix this issue. This is why I hope the CMake team will continue to maintain the Sphinx documentation system for older versions of CMake.

Additionally, I hope that the CMake project, like other projects using Sphinx, would prepare a `requirements.txt` file specifying the required Sphinx version and other dependencies. This way, users only need to run `pip install -r requirements.txt` before building the documentation, without worrying about which version of Sphinx to install. For instance, to build documentation for all versions of CMake, I had to prepare corresponding `requirements.txt` files in the project as shown below:

 ![Screenshot_20240420_003349](https://discourse.cmake.org/uploads/default/original/2X/2/27d6bcdfb1d600b841eb967c89b7fa2debd0a057.png)

If CMake project can prepare a `requirements.txt`, then this code can be removed. All I need to do is to find the `requirements.txt` and run `pip install -r` to install it.

---

<div class="post-metadata">

### Author: ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)
#### Post date: [June 7, 2024, 4:45am UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/14 "2024-06-07T04:45:00Z")

</div>

Hello, CMake Team.

About what @ben.boeckel mentioned previously:

> [@ben.boeckel](#):
>
> (basically, branch off of the last 3.0.x release, update it to work with new Sphinx, then regenerate and merge the changes into `master` with `-s ours` for tracking purposes).

Here is the full log and the screenshot from [vscode-git-graph](https://github.com/mhutchie/vscode-git-graph) of my experimental demo:

> **Click to expand the full log**
>
> ```bash
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git status
> On branch master
> nothing to commit, working tree clean
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git log --oneline
> 249f752 (HEAD -> master) Init the repo
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ echo "v3.0.0" >> v3.0.0.txt
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git add .
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git commit -m "Add v3.0.0 for release-3.0"
> [master 4435866] Add v3.0.0 for release-3.0
> 1 file changed, 1 insertion(+)
> create mode 100644 v3.0.0.txt
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git tag v3.0.0
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ echo "v3.1.0" >> v3.1.0.txt
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git add .
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git commit -m "Add v3.1.0 for release-3.1"
> [master 4e629da] Add v3.1.0 for release-3.1
> 1 file changed, 1 insertion(+)
> create mode 100644 v3.1.0.txt
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git tag v3.1.0
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ echo "v3.2.0" >> v3.2.0.txt
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git add .
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git commit -m "Add v3.2.0 for release-3.2"
> [master 75df260] Add v3.2.0 for release-3.2
> 1 file changed, 1 insertion(+)
> create mode 100644 v3.2.0.txt
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git tag v3.2.0
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git checkout v3.0.0
> Note: switching to 'v3.0.0'.
> 
> You are in 'detached HEAD' state. You can look around, make experimental
> changes and commit them, and you can discard any commits you make in this
> state without impacting any branches by switching back to a branch.
> 
> If you want to create a new branch to retain commits you create, you may
> do so (now or later) by using -c with the switch command. Example:
> 
> git switch -c <new-branch-name>
> 
> Or undo this operation with:
> 
> git switch -
> 
> Turn off this advice by setting config variable advice.detachedHead to false
> 
> HEAD is now at 4435866 Add v3.0.0 for release-3.0
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git branch release-3.0
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git checkout release-3.0
> Switched to branch 'release-3.0'
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ echo "v3.0.1" >> v3.0.1.txt
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git add .
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git commit -m "Add v3.0.1 for release-3.0"
> [release-3.0 da4df98] Add v3.0.1 for release-3.0
> 1 file changed, 1 insertion(+)
> create mode 100644 v3.0.1.txt
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git tag v3.0.1
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git checkout master
> Switched to branch 'master'
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git merge --strategy=ours release-3.0
> Merge made by the 'ours' strategy.
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ git log --oneline --graph
> * 263d93d (HEAD -> master) Merge branch 'release-3.0'
> |\  
> | * da4df98 (tag: v3.0.1, release-3.0) Add v3.0.1 for release-3.0
> * | 75df260 (tag: v3.2.0) Add v3.2.0 for release-3.2
> * | 4e629da (tag: v3.1.0) Add v3.1.0 for release-3.1
> |/  
> * 4435866 (tag: v3.0.0) Add v3.0.0 for release-3.0
> * 249f752 Init the repo
> hwhsu1231@vb-kubuntu:~/Repo/testing/test-git-merge-s-ours$ 
> 
> ```

 ![Screenshot_20240607_122833](https://discourse.cmake.org/uploads/default/original/2X/7/72509b502a2e4ab63599c78563161d7b1fa25502.png)

Is the operation he described exactly like this? If so, does CMake Team use this method to handle all the patches for those older releases?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [June 11, 2024, 4:46pm UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/15 "2024-06-11T16:46:13Z")

</div>

The topology looks fine to me at a first glance (hard to tell if the merge is `-s ours` or not).

---

<div class="post-metadata">

### Author: ![hwhsu1231](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hwhsu1231/32/5358_2.png) [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)
#### Post date: [April 28, 2025, 2:19pm UTC](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/16 "2025-04-28T14:19:01Z")

</div>

### Summary of the Previous Content

Hello, CMake Team.

About a year and a half ago, I discussed in this topic the suitable Sphinx versions required to build CMake documentation from version 3.0 to the latest. Through experimentation, I concluded that:

- For `v3.0~v3.8`, we should use sphinx-1.6.1
- For `v3.9~v3.18`, we should use sphinx-2.4.5
- For `v3.19~v3.27`, we should use sphinx-5.3.0
- For `v3.28~`, we can use sphinx-6.3.0 and sphinx-latest.

In this [reply](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/8), I suggested that the team could maintain the documentation for those older CMake versions so that they could be built using the latest Sphinx. At that time, @ben.boeckel mentioned in this [reply](https://discourse.cmake.org/t/suitable-versions-of-sphinx-for-building-different-versions-of-cmake-docs/7982/9) that this could be achieved using `git merge --strategy=ours release-3.0`.

### What I discover now…

Recently, I realized that the errors mainly occur in the `conf.py`, `cmake.py`, and `colors.py` files. So, if I copy those files from the latest version (currently `v4.0.1`) repository, it should probably resolve those build errors.

For example, suppose that I want to use Sphinx version `8.1.3` to build the problematic older CMake documentation. If I place the following three files from the `v4.0.1` version into the corresponding local locations before configuring and building:

- [CMake/Utilities/Sphinx/conf.py.in at v4.0.1 · Kitware/CMake · GitHub](https://github.com/Kitware/CMake/blob/v4.0.1/Utilities/Sphinx/conf.py.in)
- [CMake/Utilities/Sphinx/cmake.py at v4.0.1 · Kitware/CMake · GitHub](https://github.com/Kitware/CMake/blob/v4.0.1/Utilities/Sphinx/cmake.py)
- [CMake/Utilities/Sphinx/colors.py at v4.0.1 · Kitware/CMake · GitHub](https://github.com/Kitware/CMake/blob/v4.0.1/Utilities/Sphinx/colors.py)

Then, the build errors should be resolved. The results after testing prove that the previous fatal errors have disappeared.

Below are the commands I used for demonstration:

> **Click to expand the demo commands for v3.8.2 tag**
>
> ```bash
> # Prepare repository and build environment
> git clone --branch=v3.8.2 --depth=1 https://github.com/Kitware/CMake.git cmake-3.8.2
> cd cmake-3.8.2
> conda create --prefix ./.conda --yes
> conda activate ./.conda
> conda install conda-forge::python=3.12 --channel conda-forge --yes
> export LANG=en_US.UTF-8 LANGUAGE=en_US PYTHONNOUSERSITE=1
> pip install sphinx==8.1.3 --progress-bar=off --verbose
> # Directly configure and build
> cmake -B build -S Utilities/Sphinx -G Ninja -DSPHINX_HTML=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5
> sphinx-build -b html -c build Help build/html
> # Update those three files before configuring and building
> rm -rf build
> curl -o Utilities/Sphinx/cmake.py https://raw.githubusercontent.com/Kitware/CMake/refs/tags/v4.0.1/Utilities/Sphinx/cmake.py
> curl -o Utilities/Sphinx/colors.py https://raw.githubusercontent.com/Kitware/CMake/refs/tags/v4.0.1/Utilities/Sphinx/colors.py
> curl -o Utilities/Sphinx/conf.py.in https://raw.githubusercontent.com/Kitware/CMake/refs/tags/v4.0.1/Utilities/Sphinx/conf.py.in
> cmake -B build -S Utilities/Sphinx -G Ninja -DSPHINX_HTML=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5
> sphinx-build -b html -c build Help build/html
> # Open documentation homepage in browser
> firefox build/html/index.html
> 
> ```

> **Click to expand the demo commands for v3.18.6 tag**
>
> ```bash
> # Prepare repository and build environment
> git clone --branch=v3.18.6 --depth=1 https://github.com/Kitware/CMake.git cmake-3.18.6
> cd cmake-3.18.6
> conda create --prefix ./.conda --yes
> conda activate ./.conda
> conda install conda-forge::python=3.12 --channel conda-forge --yes
> export LANG=en_US.UTF-8 LANGUAGE=en_US PYTHONNOUSERSITE=1
> pip install sphinx==8.1.3 --progress-bar=off --verbose
> # Directly configure and build
> cmake -B build -S Utilities/Sphinx -G Ninja -DSPHINX_HTML=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5
> sphinx-build -b html -c build Help build/html
> # Update those three files before configuring and building
> rm -rf build
> curl -o Utilities/Sphinx/cmake.py https://raw.githubusercontent.com/Kitware/CMake/refs/tags/v4.0.1/Utilities/Sphinx/cmake.py
> curl -o Utilities/Sphinx/colors.py https://raw.githubusercontent.com/Kitware/CMake/refs/tags/v4.0.1/Utilities/Sphinx/colors.py
> curl -o Utilities/Sphinx/conf.py.in https://raw.githubusercontent.com/Kitware/CMake/refs/tags/v4.0.1/Utilities/Sphinx/conf.py.in
> cmake -B build -S Utilities/Sphinx -G Ninja -DSPHINX_HTML=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5
> sphinx-build -b html -c build Help build/html
> # Open documentation homepage in browser
> firefox build/html/index.html
> 
> ```

> **Click to expand the demo commands for v3.27.9 tag**
>
> ```bash
> # Prepare repository and build environment
> git clone --branch=v3.27.9 --depth=1 https://github.com/Kitware/CMake.git cmake-3.27.9
> cd cmake-3.27.9
> conda create --prefix ./.conda --yes
> conda activate ./.conda
> conda install conda-forge::python=3.12 --channel conda-forge --yes
> export LANG=en_US.UTF-8 LANGUAGE=en_US PYTHONNOUSERSITE=1
> pip install sphinx==8.1.3 --progress-bar=off --verbose
> # Directly configure and build
> cmake -B build -S Utilities/Sphinx -G Ninja -DSPHINX_HTML=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5
> sphinx-build -b html -c build Help build/html
> # Update those three files before configuring and building
> rm -rf build
> curl -o Utilities/Sphinx/cmake.py https://raw.githubusercontent.com/Kitware/CMake/refs/tags/v4.0.1/Utilities/Sphinx/cmake.py
> curl -o Utilities/Sphinx/colors.py https://raw.githubusercontent.com/Kitware/CMake/refs/tags/v4.0.1/Utilities/Sphinx/colors.py
> curl -o Utilities/Sphinx/conf.py.in https://raw.githubusercontent.com/Kitware/CMake/refs/tags/v4.0.1/Utilities/Sphinx/conf.py.in
> cmake -B build -S Utilities/Sphinx -G Ninja -DSPHINX_HTML=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5
> sphinx-build -b html -c build Help build/html
> # Open documentation homepage in browser
> firefox build/html/index.html
> 
> ```

I believe this discovery should be very helpful for the “backporting” preparation! If the team decides to backport fixes for those older CMake documentation versions in the future, then they should only need to focus on those three files.
