mirror of
https://github.com/torvalds/linux.git
synced 2026-04-22 16:53:59 -04:00
docs: kdoc_output: use a method to emit the .TH header
All man emit functions need to add a .TH header. Move the code to a common function, as we'll be addressing some issues at the common code. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <2e55fcfe8724fde08a78635a1a3f8b449a6adf82.1772810752.git.mchehab+huawei@kernel.org>
This commit is contained in:
committed by
Jonathan Corbet
parent
0e4c8adad4
commit
c1873e7743
@@ -607,7 +607,20 @@ class ManFormat(OutputFormat):
|
||||
"%m %d %Y",
|
||||
]
|
||||
|
||||
def __init__(self, modulename):
|
||||
def emit_th(self, name, modulename = None, manual=None):
|
||||
"""Emit a title header line."""
|
||||
name = name.strip()
|
||||
|
||||
if not manual:
|
||||
manual = self.manual
|
||||
|
||||
if not modulename:
|
||||
modulename = self.modulename
|
||||
|
||||
self.data += f'.TH "{modulename}" {self.section} "{name}" '
|
||||
self.data += f'"{self.date}" "{manual}" LINUX\n'
|
||||
|
||||
def __init__(self, modulename, section="9", manual="API Manual"):
|
||||
"""
|
||||
Creates class variables.
|
||||
|
||||
@@ -616,7 +629,11 @@ class ManFormat(OutputFormat):
|
||||
"""
|
||||
|
||||
super().__init__()
|
||||
|
||||
self.modulename = modulename
|
||||
self.section = section
|
||||
self.manual = manual
|
||||
|
||||
self.symbols = []
|
||||
|
||||
dt = None
|
||||
@@ -632,7 +649,7 @@ class ManFormat(OutputFormat):
|
||||
if not dt:
|
||||
dt = datetime.now()
|
||||
|
||||
self.man_date = dt.strftime("%B %Y")
|
||||
self.date = dt.strftime("%B %Y")
|
||||
|
||||
def arg_name(self, args, name):
|
||||
"""
|
||||
@@ -724,7 +741,7 @@ class ManFormat(OutputFormat):
|
||||
|
||||
out_name = self.arg_name(args, name)
|
||||
|
||||
self.data += f'.TH "{self.modulename}" 9 "{out_name}" "{self.man_date}" "API Manual" LINUX' + "\n"
|
||||
self.emit_th(out_name)
|
||||
|
||||
for section, text in args.sections.items():
|
||||
self.data += f'.SH "{section}"' + "\n"
|
||||
@@ -734,7 +751,8 @@ class ManFormat(OutputFormat):
|
||||
|
||||
out_name = self.arg_name(args, name)
|
||||
|
||||
self.data += f'.TH "{name}" 9 "{out_name}" "{self.man_date}" "Kernel Hacker\'s Manual" LINUX' + "\n"
|
||||
self.emit_th(out_name, modulename = name,
|
||||
manual="Kernel Hacker\'s Manual")
|
||||
|
||||
self.data += ".SH NAME\n"
|
||||
self.data += f"{name} \\- {args['purpose']}\n"
|
||||
@@ -780,7 +798,7 @@ class ManFormat(OutputFormat):
|
||||
def out_enum(self, fname, name, args):
|
||||
out_name = self.arg_name(args, name)
|
||||
|
||||
self.data += f'.TH "{self.modulename}" 9 "{out_name}" "{self.man_date}" "API Manual" LINUX' + "\n"
|
||||
self.emit_th(out_name)
|
||||
|
||||
self.data += ".SH NAME\n"
|
||||
self.data += f"enum {name} \\- {args['purpose']}\n"
|
||||
@@ -813,7 +831,7 @@ class ManFormat(OutputFormat):
|
||||
out_name = self.arg_name(args, name)
|
||||
full_proto = args.other_stuff["full_proto"]
|
||||
|
||||
self.data += f'.TH "{self.modulename}" 9 "{out_name}" "{self.man_date}" "API Manual" LINUX' + "\n"
|
||||
self.emit_th(out_name)
|
||||
|
||||
self.data += ".SH NAME\n"
|
||||
self.data += f"{name} \\- {args['purpose']}\n"
|
||||
@@ -834,7 +852,7 @@ class ManFormat(OutputFormat):
|
||||
purpose = args.get('purpose')
|
||||
out_name = self.arg_name(args, name)
|
||||
|
||||
self.data += f'.TH "{module}" 9 "{out_name}" "{self.man_date}" "API Manual" LINUX' + "\n"
|
||||
self.emit_th(out_name)
|
||||
|
||||
self.data += ".SH NAME\n"
|
||||
self.data += f"typedef {name} \\- {purpose}\n"
|
||||
@@ -849,7 +867,7 @@ class ManFormat(OutputFormat):
|
||||
definition = args.get('definition')
|
||||
out_name = self.arg_name(args, name)
|
||||
|
||||
self.data += f'.TH "{module}" 9 "{out_name}" "{self.man_date}" "API Manual" LINUX' + "\n"
|
||||
self.emit_th(out_name)
|
||||
|
||||
self.data += ".SH NAME\n"
|
||||
self.data += f"{args.type} {name} \\- {purpose}\n"
|
||||
|
||||
Reference in New Issue
Block a user