docs: kdoc_output: fix naming for DOC markups

Right now, DOC markups aren't being handled properly, as it was
using the same name for all output.

Fix it by filling the title argument on a different way.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <11d809e5c4bec23240d3ace3f342dbb2a9263446.1772810752.git.mchehab+huawei@kernel.org>
This commit is contained in:
Mauro Carvalho Chehab
2026-03-06 16:45:45 +01:00
committed by Jonathan Corbet
parent 1a63342a27
commit 4160533d05
2 changed files with 24 additions and 16 deletions

View File

@@ -607,14 +607,21 @@ class ManFormat(OutputFormat):
"%m %d %Y",
]
def emit_th(self, name):
def modulename(self, args):
if self._modulename:
return self._modulename
return os.path.dirname(args.fname)
def emit_th(self, name, args):
"""Emit a title header line."""
name = name.strip()
title = name.strip()
module = self.modulename(args)
self.data += f'.TH "{self.modulename}" {self.section} "{name}" '
self.data += f'"{self.date}" "{self.manual}"\n'
self.data += f'.TH "{name}" {self.section} "{self.date}" '
self.data += f'"{self.modulename}" "{self.manual}"\n'
def __init__(self, modulename, section="9", manual="Kernel API Manual"):
def __init__(self, modulename=None, section="9", manual="Kernel API Manual"):
"""
Creates class variables.
@@ -624,7 +631,7 @@ class ManFormat(OutputFormat):
super().__init__()
self.modulename = modulename
self._modulename = modulename
self.section = section
self.manual = manual
@@ -658,7 +665,8 @@ class ManFormat(OutputFormat):
dtype = args.type
if dtype == "doc":
return self.modulename
return name
# return os.path.basename(self.modulename(args))
if dtype in ["function", "typedef"]:
return name
@@ -735,7 +743,7 @@ class ManFormat(OutputFormat):
out_name = self.arg_name(args, name)
self.emit_th(out_name)
self.emit_th(out_name, args)
for section, text in args.sections.items():
self.data += f'.SH "{section}"' + "\n"
@@ -745,7 +753,7 @@ class ManFormat(OutputFormat):
out_name = self.arg_name(args, name)
self.emit_th(out_name)
self.emit_th(out_name, args)
self.data += ".SH NAME\n"
self.data += f"{name} \\- {args['purpose']}\n"
@@ -791,7 +799,7 @@ class ManFormat(OutputFormat):
def out_enum(self, fname, name, args):
out_name = self.arg_name(args, name)
self.emit_th(out_name)
self.emit_th(out_name, args)
self.data += ".SH NAME\n"
self.data += f"enum {name} \\- {args['purpose']}\n"
@@ -824,7 +832,7 @@ class ManFormat(OutputFormat):
out_name = self.arg_name(args, name)
full_proto = args.other_stuff["full_proto"]
self.emit_th(out_name)
self.emit_th(out_name, args)
self.data += ".SH NAME\n"
self.data += f"{name} \\- {args['purpose']}\n"
@@ -841,11 +849,11 @@ class ManFormat(OutputFormat):
self.output_highlight(text)
def out_typedef(self, fname, name, args):
module = self.modulename
module = self.modulename(args)
purpose = args.get('purpose')
out_name = self.arg_name(args, name)
self.emit_th(out_name)
self.emit_th(out_name, args)
self.data += ".SH NAME\n"
self.data += f"typedef {name} \\- {purpose}\n"
@@ -855,12 +863,12 @@ class ManFormat(OutputFormat):
self.output_highlight(text)
def out_struct(self, fname, name, args):
module = self.modulename
module = self.modulename(args)
purpose = args.get('purpose')
definition = args.get('definition')
out_name = self.arg_name(args, name)
self.emit_th(out_name)
self.emit_th(out_name, args)
self.data += ".SH NAME\n"
self.data += f"{args.type} {name} \\- {purpose}\n"