Commit 5094f7d5 authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Jonathan Corbet
Browse files

tools/docs: sphinx-build-wrapper: generate rust docs only once



Currently the rust docs are generated for each entry in SPHINXDIRS.
This is unnecessary as they will be the same for each one.

Move the generation, so it is executed only once.

Signed-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
Reviewed-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tested-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
Message-ID: <20260118-docs-spurious-rust-v1-1-998e14b9ed9e@weissschuh.net>
parent 36718450
Loading
Loading
Loading
Loading
+17 −17
Original line number Diff line number Diff line
@@ -352,23 +352,6 @@ class SphinxBuilder:
            except (OSError, IOError) as e:
                print(f"Warning: Failed to copy CSS: {e}", file=sys.stderr)

        if self.rustdoc:
            print("Building rust docs")
            if "MAKE" in self.env:
                cmd = [self.env["MAKE"]]
            else:
                cmd = ["make", "LLVM=1"]

            cmd += [ "rustdoc"]
            if self.verbose:
                print(" ".join(cmd))

            try:
                subprocess.run(cmd, check=True)
            except subprocess.CalledProcessError as e:
                print(f"Ignored errors when building rustdoc: {e}. Is RUST enabled?",
                      file=sys.stderr)

    def build_pdf_file(self, latex_cmd, from_dir, path):
        """Builds a single pdf file using latex_cmd"""
        try:
@@ -785,6 +768,23 @@ class SphinxBuilder:
        elif target == "infodocs":
            self.handle_info(output_dirs)

        if self.rustdoc and target in ["htmldocs", "epubdocs"]:
            print("Building rust docs")
            if "MAKE" in self.env:
                cmd = [self.env["MAKE"]]
            else:
                cmd = ["make", "LLVM=1"]

            cmd += [ "rustdoc"]
            if self.verbose:
                print(" ".join(cmd))

            try:
                subprocess.run(cmd, check=True)
            except subprocess.CalledProcessError as e:
                print(f"Ignored errors when building rustdoc: {e}. Is RUST enabled?",
                      file=sys.stderr)

def jobs_type(value):
    """
    Handle valid values for -j. Accepts Sphinx "-jauto", plus a number