Skip to content

Commit 24f984a

Browse files
author
Jonathan Corbet
committed
docs: kdoc: remove support for an external kernel-doc from sphinx
The ability to build the docs with an external kernel-doc program involves some truly confusing logic and complicates the task of moving kernel-doc out of scripts/. But this feature is not useful for normal documentation builds, and the external kernel-doc can always be run by hand when it needs debugging. So just remove that feature and make life easier. There is still a bunch of logic to build a command line that we never use; the idea is to be able to output it, but I'm not sure if that is worth keeping. Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <a97a8361546648906344457a7e92e4db533048a9.1768823489.git.mchehab+huawei@kernel.org>
1 parent 6cc45ee commit 24f984a

1 file changed

Lines changed: 6 additions & 47 deletions

File tree

Documentation/sphinx/kerneldoc.py

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -190,35 +190,7 @@ def handle_args(self):
190190

191191
return cmd
192192

193-
def run_cmd(self, cmd):
194-
"""
195-
Execute an external kernel-doc command.
196-
"""
197-
198-
env = self.state.document.settings.env
199-
node = nodes.section()
200-
201-
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
202-
out, err = p.communicate()
203-
204-
out, err = codecs.decode(out, 'utf-8'), codecs.decode(err, 'utf-8')
205-
206-
if p.returncode != 0:
207-
sys.stderr.write(err)
208-
209-
logger.warning("kernel-doc '%s' failed with return code %d"
210-
% (" ".join(cmd), p.returncode))
211-
return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
212-
elif env.config.kerneldoc_verbosity > 0:
213-
sys.stderr.write(err)
214-
215-
filenames = self.parse_args["file_list"]
216-
for filename in filenames:
217-
self.parse_msg(filename, node, out, cmd)
218-
219-
return node.children
220-
221-
def parse_msg(self, filename, node, out, cmd):
193+
def parse_msg(self, filename, node, out):
222194
"""
223195
Handles a kernel-doc output for a given file
224196
"""
@@ -244,7 +216,7 @@ def parse_msg(self, filename, node, out, cmd):
244216

245217
self.do_parse(result, node)
246218

247-
def run_kdoc(self, cmd, kfiles):
219+
def run_kdoc(self, kfiles):
248220
"""
249221
Execute kernel-doc classes directly instead of running as a separate
250222
command.
@@ -258,23 +230,17 @@ def run_kdoc(self, cmd, kfiles):
258230
filenames = self.parse_args["file_list"]
259231

260232
for filename, out in kfiles.msg(**self.msg_args, filenames=filenames):
261-
self.parse_msg(filename, node, out, cmd)
233+
self.parse_msg(filename, node, out)
262234

263235
return node.children
264236

265237
def run(self):
266-
global kfiles
267-
268238
cmd = self.handle_args()
269239
if self.verbose >= 1:
270240
logger.info(cmd_str(cmd))
271241

272242
try:
273-
if kfiles:
274-
return self.run_kdoc(cmd, kfiles)
275-
else:
276-
return self.run_cmd(cmd)
277-
243+
return self.run_kdoc(kfiles)
278244
except Exception as e: # pylint: disable=W0703
279245
logger.warning("kernel-doc '%s' processing failed with: %s" %
280246
(cmd_str(cmd), pformat(e)))
@@ -286,15 +252,8 @@ def do_parse(self, result, node):
286252

287253
def setup_kfiles(app):
288254
global kfiles
289-
290-
kerneldoc_bin = app.env.config.kerneldoc_bin
291-
292-
if kerneldoc_bin and kerneldoc_bin.endswith("kernel-doc.py"):
293-
print("Using Python kernel-doc")
294-
out_style = RestFormat()
295-
kfiles = KernelFiles(out_style=out_style, logger=logger)
296-
else:
297-
print(f"Using {kerneldoc_bin}")
255+
out_style = RestFormat()
256+
kfiles = KernelFiles(out_style=out_style, logger=logger)
298257

299258

300259
def setup(app):

0 commit comments

Comments
 (0)