Skip to content

Commit 2d65213

Browse files
t-8chJonathan Corbet
authored andcommitted
tools/docs: sphinx-build-wrapper: make 'rustdoc' a local variable
All users of this variable are now in the same method. Demote the instance variable to a local one. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Tested-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <20260118-docs-spurious-rust-v1-2-998e14b9ed9e@weissschuh.net>
1 parent 5094f7d commit 2d65213

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

tools/docs/sphinx-build-wrapper

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,24 +123,24 @@ class SphinxBuilder:
123123
"""
124124
Checks if Rust is enabled
125125
"""
126-
self.rustdoc = False
127-
128126
config = os.path.join(self.srctree, ".config")
129127

130128
if not os.path.isfile(config):
131-
return
129+
return False
132130

133131
re_rust = re.compile(r"CONFIG_RUST=(m|y)")
134132

135133
try:
136134
with open(config, "r", encoding="utf-8") as fp:
137135
for line in fp:
138136
if re_rust.match(line):
139-
self.rustdoc = True
140-
return
137+
return True
141138

142139
except OSError as e:
143140
print(f"Failed to open {config}", file=sys.stderr)
141+
return False
142+
143+
return False
144144

145145
def get_sphinx_extra_opts(self, n_jobs):
146146
"""
@@ -259,8 +259,6 @@ class SphinxBuilder:
259259

260260
self.get_sphinx_extra_opts(n_jobs)
261261

262-
self.check_rust()
263-
264262
#
265263
# If venv command line argument is specified, run Sphinx from venv
266264
#
@@ -680,7 +678,8 @@ class SphinxBuilder:
680678

681679
args.extend(["-D", f"latex_elements.papersize={paper}paper"])
682680

683-
if self.rustdoc:
681+
rustdoc = self.check_rust()
682+
if rustdoc:
684683
args.extend(["-t", "rustdoc"])
685684

686685
if not sphinxdirs:
@@ -768,7 +767,7 @@ class SphinxBuilder:
768767
elif target == "infodocs":
769768
self.handle_info(output_dirs)
770769

771-
if self.rustdoc and target in ["htmldocs", "epubdocs"]:
770+
if rustdoc and target in ["htmldocs", "epubdocs"]:
772771
print("Building rust docs")
773772
if "MAKE" in self.env:
774773
cmd = [self.env["MAKE"]]

0 commit comments

Comments
 (0)