Skip to content

Commit bd5628b

Browse files
author
Jonathan Corbet
committed
docs: kdoc: directly access the always-there KdocItem fields
They are part of the interface, so use them directly. This allows the removal of the transitional __dict__ hack in KdocItem. Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent 08b8dc4 commit bd5628b

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

scripts/lib/kdoc/kdoc_item.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ def __init__(self, name, type, start_line, **other_stuff):
2323
self.other_stuff = other_stuff
2424

2525
def get(self, key, default = None):
26-
ret = self.other_stuff.get(key, default)
27-
if ret == default:
28-
return self.__dict__.get(key, default)
29-
return ret
26+
return self.other_stuff.get(key, default)
3027

3128
def __getitem__(self, key):
3229
return self.get(key)

scripts/lib/kdoc/kdoc_output.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ def out_warnings(self, args):
124124
Output warnings for identifiers that will be displayed.
125125
"""
126126

127-
warnings = args.get('warnings', [])
128-
129-
for log_msg in warnings:
127+
for log_msg in args.warnings:
130128
self.config.warning(log_msg)
131129

132130
def check_doc(self, name, args):
@@ -184,7 +182,7 @@ def msg(self, fname, name, args):
184182

185183
self.data = ""
186184

187-
dtype = args.get('type', "")
185+
dtype = args.type
188186

189187
if dtype == "doc":
190188
self.out_doc(fname, name, args)
@@ -373,7 +371,7 @@ def out_function(self, fname, name, args):
373371
signature = args['functiontype'] + " "
374372
signature += name + " ("
375373

376-
ln = args.get('declaration_start_line', 0)
374+
ln = args.declaration_start_line
377375
count = 0
378376
for parameter in args.parameterlist:
379377
if count != 0:
@@ -445,7 +443,7 @@ def out_function(self, fname, name, args):
445443
def out_enum(self, fname, name, args):
446444

447445
oldprefix = self.lineprefix
448-
ln = args.get('declaration_start_line', 0)
446+
ln = args.declaration_start_line
449447

450448
self.data += f"\n\n.. c:enum:: {name}\n\n"
451449

@@ -474,7 +472,7 @@ def out_enum(self, fname, name, args):
474472
def out_typedef(self, fname, name, args):
475473

476474
oldprefix = self.lineprefix
477-
ln = args.get('declaration_start_line', 0)
475+
ln = args.declaration_start_line
478476

479477
self.data += f"\n\n.. c:type:: {name}\n\n"
480478

@@ -492,8 +490,8 @@ def out_struct(self, fname, name, args):
492490

493491
purpose = args.get('purpose', "")
494492
declaration = args.get('definition', "")
495-
dtype = args.get('type', "struct")
496-
ln = args.get('declaration_start_line', 0)
493+
dtype = args.type
494+
ln = args.declaration_start_line
497495

498496
self.data += f"\n\n.. c:{dtype}:: {name}\n\n"
499497

0 commit comments

Comments
 (0)