linux/tools/docs/sphinx-build-wrapper

902 lines
31 KiB

2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
tools/docs: sphinx-build-wrapper: fix compat with recent Tumbleweed On recent versions of openSUSE Tumbleweed, sphinx-buildis is no longer a Python script, but something else. Such change is due to how it now handles alternatives: https://en.opensuse.org/openSUSE:Migrating_to_libalternatives_with_alts The most common approach that distros use for alternatives is via symlinks: lrwxrwxrwx 1 root root 22 out 31 2024 /usr/bin/java -> /etc/alternatives/java lrwxrwxrwx 1 root root 37 mar 5 2025 /etc/alternatives/java -> /usr/lib/jvm/java-21-openjdk/bin/java With such approach, one can sun the script with either: <sphinx> python3 <script> However, openSUSE's implementation uses an ELF binary (/usr/bin/alts), which breaks the latter format. It is needed to allow users to specify the Python version to be used while building docs, as some distros like Leap 15.x are shipped with: - older, unsupported python3/python3-sphinx packages; - more modern python3xx/python3xx-sphinx packages that work properly. On such distros, building docs require running make with: make PYTHON3=python3.11 htmldocs Heh, even on more moderen distros where python3-sphinx is supported, one may still want to use a newer package, for instance, due to performance issues, as: - with Python < 3.11, kernel-doc is 3 times slower; - while building htmldocs with Python 3.13/Sphinx 8.x takes about 3 minutes on a modern machine, using Sphinx < 8.0 can take up to 16 minutes to build docs (7.x are the worse ones and require lots of RAM). So, even with not too old distros, one still may want to use for instance PYTHON3=python3.11. To acommodate using PYTHON3 without breaking on Tumbleweed, add a workaround that will only use: $(PYTHON3) sphinx-build if PYTHON3 env var is not default. While here, drop the special check for venv, as, with venv, we can just call sphinx-build directly without any extra checks. Reported-by: Randy Dunlap <rdunlap@infradead.org> Link: https://lore.kernel.org/all/883df949-0281-4a39-8745-bcdcce3a5594@infradead.org/ Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Tested-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <8917f862e0b8484c68408c274129c9f37a7aefb4.1758539031.git.mchehab+huawei@kernel.org>
2025-09-22 13:27:38 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
tools/docs: sphinx-build-wrapper: fix compat with recent Tumbleweed On recent versions of openSUSE Tumbleweed, sphinx-buildis is no longer a Python script, but something else. Such change is due to how it now handles alternatives: https://en.opensuse.org/openSUSE:Migrating_to_libalternatives_with_alts The most common approach that distros use for alternatives is via symlinks: lrwxrwxrwx 1 root root 22 out 31 2024 /usr/bin/java -> /etc/alternatives/java lrwxrwxrwx 1 root root 37 mar 5 2025 /etc/alternatives/java -> /usr/lib/jvm/java-21-openjdk/bin/java With such approach, one can sun the script with either: <sphinx> python3 <script> However, openSUSE's implementation uses an ELF binary (/usr/bin/alts), which breaks the latter format. It is needed to allow users to specify the Python version to be used while building docs, as some distros like Leap 15.x are shipped with: - older, unsupported python3/python3-sphinx packages; - more modern python3xx/python3xx-sphinx packages that work properly. On such distros, building docs require running make with: make PYTHON3=python3.11 htmldocs Heh, even on more moderen distros where python3-sphinx is supported, one may still want to use a newer package, for instance, due to performance issues, as: - with Python < 3.11, kernel-doc is 3 times slower; - while building htmldocs with Python 3.13/Sphinx 8.x takes about 3 minutes on a modern machine, using Sphinx < 8.0 can take up to 16 minutes to build docs (7.x are the worse ones and require lots of RAM). So, even with not too old distros, one still may want to use for instance PYTHON3=python3.11. To acommodate using PYTHON3 without breaking on Tumbleweed, add a workaround that will only use: $(PYTHON3) sphinx-build if PYTHON3 env var is not default. While here, drop the special check for venv, as, with venv, we can just call sphinx-build directly without any extra checks. Reported-by: Randy Dunlap <rdunlap@infradead.org> Link: https://lore.kernel.org/all/883df949-0281-4a39-8745-bcdcce3a5594@infradead.org/ Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Tested-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <8917f862e0b8484c68408c274129c9f37a7aefb4.1758539031.git.mchehab+huawei@kernel.org>
2025-09-22 13:27:38 +02:00
tools/docs: sphinx-build-wrapper: fix compat with recent Tumbleweed On recent versions of openSUSE Tumbleweed, sphinx-buildis is no longer a Python script, but something else. Such change is due to how it now handles alternatives: https://en.opensuse.org/openSUSE:Migrating_to_libalternatives_with_alts The most common approach that distros use for alternatives is via symlinks: lrwxrwxrwx 1 root root 22 out 31 2024 /usr/bin/java -> /etc/alternatives/java lrwxrwxrwx 1 root root 37 mar 5 2025 /etc/alternatives/java -> /usr/lib/jvm/java-21-openjdk/bin/java With such approach, one can sun the script with either: <sphinx> python3 <script> However, openSUSE's implementation uses an ELF binary (/usr/bin/alts), which breaks the latter format. It is needed to allow users to specify the Python version to be used while building docs, as some distros like Leap 15.x are shipped with: - older, unsupported python3/python3-sphinx packages; - more modern python3xx/python3xx-sphinx packages that work properly. On such distros, building docs require running make with: make PYTHON3=python3.11 htmldocs Heh, even on more moderen distros where python3-sphinx is supported, one may still want to use a newer package, for instance, due to performance issues, as: - with Python < 3.11, kernel-doc is 3 times slower; - while building htmldocs with Python 3.13/Sphinx 8.x takes about 3 minutes on a modern machine, using Sphinx < 8.0 can take up to 16 minutes to build docs (7.x are the worse ones and require lots of RAM). So, even with not too old distros, one still may want to use for instance PYTHON3=python3.11. To acommodate using PYTHON3 without breaking on Tumbleweed, add a workaround that will only use: $(PYTHON3) sphinx-build if PYTHON3 env var is not default. While here, drop the special check for venv, as, with venv, we can just call sphinx-build directly without any extra checks. Reported-by: Randy Dunlap <rdunlap@infradead.org> Link: https://lore.kernel.org/all/883df949-0281-4a39-8745-bcdcce3a5594@infradead.org/ Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Tested-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <8917f862e0b8484c68408c274129c9f37a7aefb4.1758539031.git.mchehab+huawei@kernel.org>
2025-09-22 13:27:38 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
tools/docs: sphinx-build-wrapper: move rust doc builder to wrapper Simplify even further the docs Makefile by moving rust build logic to the wrapper. After this change, running make on an environment with rust enabled works as expected. With CONFIG_RUST: $ make O=/tmp/foo LLVM=1 SPHINXDIRS=peci htmldocs make[1]: Entrando no diretório '/tmp/foo' Using alabaster theme Using Python kernel-doc GEN Makefile DESCEND objtool CC arch/x86/kernel/asm-offsets.s INSTALL libsubcmd_headers CALL /new_devel/docs/scripts/checksyscalls.sh RUSTC L rust/core.o BINDGEN rust/bindings/bindings_generated.rs BINDGEN rust/bindings/bindings_helpers_generated.rs ... Without it: $ make SPHINXDIRS=peci htmldocs Using alabaster theme Using Python kernel-doc Both work as it is it is supposed to do. After the change, it is also possible to build directly with the script by passing "--rustodoc". if CONFIG_RUST, this works fine: $ ./tools/docs/sphinx-build-wrapper --sphinxdirs peci --rustdoc -- htmldocs Using alabaster theme Using Python kernel-doc SYNC include/config/auto.conf ... RUSTC L rust/core.o ... If not, it will produce a warning that RUST may be disabled: $ ./tools/docs/sphinx-build-wrapper --sphinxdirs peci --rustdoc -- htmldocs Using alabaster theme Using Python kernel-doc *** *** Configuration file ".config" not found! *** *** Please run some configurator (e.g. "make oldconfig" or *** "make menuconfig" or "make xconfig"). *** make[1]: *** [/new_devel/docs/Makefile:829: .config] Error 1 make: *** [Makefile:248: __sub-make] Error 2 Ignored errors when building rustdoc: Command '['make', 'LLVM=1', 'rustdoc']' returned non-zero exit status 2.. Is RUST enabled? Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Message-ID: <fa1235ccf859f6ebfeef7ffba0ebde2015a75042.1758196090.git.mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 13:54:56 +02:00
2025-09-18 13:54:45 +02:00
tools/docs: sphinx-build-wrapper: move rust doc builder to wrapper Simplify even further the docs Makefile by moving rust build logic to the wrapper. After this change, running make on an environment with rust enabled works as expected. With CONFIG_RUST: $ make O=/tmp/foo LLVM=1 SPHINXDIRS=peci htmldocs make[1]: Entrando no diretório '/tmp/foo' Using alabaster theme Using Python kernel-doc GEN Makefile DESCEND objtool CC arch/x86/kernel/asm-offsets.s INSTALL libsubcmd_headers CALL /new_devel/docs/scripts/checksyscalls.sh RUSTC L rust/core.o BINDGEN rust/bindings/bindings_generated.rs BINDGEN rust/bindings/bindings_helpers_generated.rs ... Without it: $ make SPHINXDIRS=peci htmldocs Using alabaster theme Using Python kernel-doc Both work as it is it is supposed to do. After the change, it is also possible to build directly with the script by passing "--rustodoc". if CONFIG_RUST, this works fine: $ ./tools/docs/sphinx-build-wrapper --sphinxdirs peci --rustdoc -- htmldocs Using alabaster theme Using Python kernel-doc SYNC include/config/auto.conf ... RUSTC L rust/core.o ... If not, it will produce a warning that RUST may be disabled: $ ./tools/docs/sphinx-build-wrapper --sphinxdirs peci --rustdoc -- htmldocs Using alabaster theme Using Python kernel-doc *** *** Configuration file ".config" not found! *** *** Please run some configurator (e.g. "make oldconfig" or *** "make menuconfig" or "make xconfig"). *** make[1]: *** [/new_devel/docs/Makefile:829: .config] Error 1 make: *** [Makefile:248: __sub-make] Error 2 Ignored errors when building rustdoc: Command '['make', 'LLVM=1', 'rustdoc']' returned non-zero exit status 2.. Is RUST enabled? Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Message-ID: <fa1235ccf859f6ebfeef7ffba0ebde2015a75042.1758196090.git.mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 13:54:56 +02:00
2025-09-18 13:54:45 +02:00
tools/docs: sphinx-build-wrapper: move rust doc builder to wrapper Simplify even further the docs Makefile by moving rust build logic to the wrapper. After this change, running make on an environment with rust enabled works as expected. With CONFIG_RUST: $ make O=/tmp/foo LLVM=1 SPHINXDIRS=peci htmldocs make[1]: Entrando no diretório '/tmp/foo' Using alabaster theme Using Python kernel-doc GEN Makefile DESCEND objtool CC arch/x86/kernel/asm-offsets.s INSTALL libsubcmd_headers CALL /new_devel/docs/scripts/checksyscalls.sh RUSTC L rust/core.o BINDGEN rust/bindings/bindings_generated.rs BINDGEN rust/bindings/bindings_helpers_generated.rs ... Without it: $ make SPHINXDIRS=peci htmldocs Using alabaster theme Using Python kernel-doc Both work as it is it is supposed to do. After the change, it is also possible to build directly with the script by passing "--rustodoc". if CONFIG_RUST, this works fine: $ ./tools/docs/sphinx-build-wrapper --sphinxdirs peci --rustdoc -- htmldocs Using alabaster theme Using Python kernel-doc SYNC include/config/auto.conf ... RUSTC L rust/core.o ... If not, it will produce a warning that RUST may be disabled: $ ./tools/docs/sphinx-build-wrapper --sphinxdirs peci --rustdoc -- htmldocs Using alabaster theme Using Python kernel-doc *** *** Configuration file ".config" not found! *** *** Please run some configurator (e.g. "make oldconfig" or *** "make menuconfig" or "make xconfig"). *** make[1]: *** [/new_devel/docs/Makefile:829: .config] Error 1 make: *** [Makefile:248: __sub-make] Error 2 Ignored errors when building rustdoc: Command '['make', 'LLVM=1', 'rustdoc']' returned non-zero exit status 2.. Is RUST enabled? Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Message-ID: <fa1235ccf859f6ebfeef7ffba0ebde2015a75042.1758196090.git.mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 13:54:56 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
tools/docs: sphinx-* break documentation bulds on openSUSE Before this patch, building htmldocs on opensuseLEAP works fine: # make htmldocs Available Python versions: /usr/bin/python3.11 Python 3.6.15 not supported. Changing to /usr/bin/python3.11 Python 3.6.15 not supported. Changing to /usr/bin/python3.11 Using alabaster theme Using Python kernel-doc ... As the logic detects that Python 3.6 is too old and recommends intalling python311-Sphinx. If installed, documentation builds work like a charm. Yet, some develpers complained that running python3.11 instead of python3 should not happen. So, let's break the build to make them happier: $ make htmldocs Python 3.6.15 not supported. Bailing out You could run, instead: /usr/bin/python3.11 tools/docs/sphinx-build-wrapper htmldocs \ --sphinxdirs=. --conf=conf.py --builddir=Documentation/output --theme= --css= \ --paper= Python 3.6.15 not supported. Bailing out make[2]: *** [Documentation/Makefile:76: htmldocs] Error 1 make[1]: *** [Makefile:1806: htmldocs] Error 2 make: *** [Makefile:248: __sub-make] Error 2 It should be noticed that: 1. after this change, sphinx-pre-install needs to be called by hand: $ /usr/bin/python3.11 tools/docs/sphinx-pre-install Detected OS: openSUSE Leap 15.6. Sphinx version: 7.2.6 All optional dependencies are met. Needed package dependencies are met. 2. sphinx-build-wrapper will auto-detect python3.11 and suggest a way to build the docs using the parameters passed via make variables. In this specific example: /usr/bin/python3.11 tools/docs/sphinx-build-wrapper htmldocs --sphinxdirs=. --conf=conf.py --theme= --css= --paper= 3. As this needs to be executed outside docs Makefile, it won't run the validation check scripts nor build Rust documentation if enabled, as the extra scripts are part of the docs Makefile. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Message-ID: <0635c311295300e9fb48c0ea607e2408910036e3.1758196090.git.mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 13:54:57 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00
2025-09-18 13:54:45 +02:00