summaryrefslogtreecommitdiff
path: root/tools/lib/python/kdoc/kdoc_output.py
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2026-03-06 16:45:45 +0100
committerJonathan Corbet <corbet@lwn.net>2026-03-09 10:34:38 -0600
commit4160533d058cfa667159e8d6a46fe42c738a4a84 (patch)
tree4f7db1b0c61d1ef9e1d671fc49df6cbcabebb144 /tools/lib/python/kdoc/kdoc_output.py
parent1a63342a2774c734b73841fdfa41cf4d8d58cd94 (diff)
downloadlwn-4160533d058cfa667159e8d6a46fe42c738a4a84.tar.gz
lwn-4160533d058cfa667159e8d6a46fe42c738a4a84.zip
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>
Diffstat (limited to 'tools/lib/python/kdoc/kdoc_output.py')
-rw-r--r--tools/lib/python/kdoc/kdoc_output.py38
1 files changed, 23 insertions, 15 deletions
diff --git a/tools/lib/python/kdoc/kdoc_output.py b/tools/lib/python/kdoc/kdoc_output.py
index 62e300e65405..cf834dbf2725 100644
--- a/tools/lib/python/kdoc/kdoc_output.py
+++ b/tools/lib/python/kdoc/kdoc_output.py
@@ -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"