Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scripts/kernel-doc.py: fix line number output

With the Pyhton version, the actual output happens after parsing,
from records stored at self.entries.

Ensure that line numbers will be properly stored there and
that they'll produce the desired results at the ReST output.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/5182a531d14b5fe9e1fc5da5f9dae05d66852a60.1744106242.git.mchehab+huawei@kernel.org

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
c3597ab2 0873e554

+24 -10
+7 -6
scripts/lib/kdoc/kdoc_output.py
··· 255 255 def print_lineno(self, ln): 256 256 """Outputs a line number""" 257 257 258 - if self.enable_lineno and ln: 258 + if self.enable_lineno and ln is not None: 259 + ln += 1 259 260 self.data += f".. LINENO {ln}\n" 260 261 261 262 def output_highlight(self, args): ··· 359 358 parameterdescs = args.get('parameterdescs', {}) 360 359 parameterdesc_start_lines = args.get('parameterdesc_start_lines', {}) 361 360 362 - ln = args.get('ln', 0) 361 + ln = args.get('declaration_start_line', 0) 363 362 364 363 count = 0 365 364 for parameter in parameterlist: ··· 376 375 if not func_macro: 377 376 signature += ")" 378 377 378 + self.print_lineno(ln) 379 379 if args.get('typedef') or not args.get('functiontype'): 380 380 self.data += f".. c:macro:: {args['function']}\n\n" 381 381 382 382 if args.get('typedef'): 383 - self.print_lineno(ln) 384 383 self.data += " **Typedef**: " 385 384 self.lineprefix = "" 386 385 self.output_highlight(args.get('purpose', "")) ··· 435 434 name = args.get('enum', '') 436 435 parameterlist = args.get('parameterlist', []) 437 436 parameterdescs = args.get('parameterdescs', {}) 438 - ln = args.get('ln', 0) 437 + ln = args.get('declaration_start_line', 0) 439 438 440 439 self.data += f"\n\n.. c:enum:: {name}\n\n" 441 440 ··· 465 464 466 465 oldprefix = self.lineprefix 467 466 name = args.get('typedef', '') 468 - ln = args.get('ln', 0) 467 + ln = args.get('declaration_start_line', 0) 469 468 470 469 self.data += f"\n\n.. c:type:: {name}\n\n" 471 470 ··· 485 484 purpose = args.get('purpose', "") 486 485 declaration = args.get('definition', "") 487 486 dtype = args.get('type', "struct") 488 - ln = args.get('ln', 0) 487 + ln = args.get('declaration_start_line', 0) 489 488 490 489 parameterlist = args.get('parameterlist', []) 491 490 parameterdescs = args.get('parameterdescs', {})
+17 -4
scripts/lib/kdoc/kdoc_parser.py
··· 276 276 self.entry.brcount = 0 277 277 278 278 self.entry.in_doc_sect = False 279 - self.entry.declaration_start_line = ln 279 + self.entry.declaration_start_line = ln + 1 280 280 281 281 def push_parameter(self, ln, decl_type, param, dtype, 282 282 org_arg, declaration_name): ··· 806 806 parameterlist=self.entry.parameterlist, 807 807 parameterdescs=self.entry.parameterdescs, 808 808 parametertypes=self.entry.parametertypes, 809 + parameterdesc_start_lines=self.entry.parameterdesc_start_lines, 809 810 sectionlist=self.entry.sectionlist, 810 811 sections=self.entry.sections, 812 + section_start_lines=self.entry.section_start_lines, 811 813 purpose=self.entry.declaration_purpose) 812 814 813 815 def dump_enum(self, ln, proto): ··· 884 882 module=self.config.modulename, 885 883 parameterlist=self.entry.parameterlist, 886 884 parameterdescs=self.entry.parameterdescs, 885 + parameterdesc_start_lines=self.entry.parameterdesc_start_lines, 887 886 sectionlist=self.entry.sectionlist, 888 887 sections=self.entry.sections, 888 + section_start_lines=self.entry.section_start_lines, 889 889 purpose=self.entry.declaration_purpose) 890 890 891 891 def dump_declaration(self, ln, prototype): ··· 1058 1054 parameterlist=self.entry.parameterlist, 1059 1055 parameterdescs=self.entry.parameterdescs, 1060 1056 parametertypes=self.entry.parametertypes, 1057 + parameterdesc_start_lines=self.entry.parameterdesc_start_lines, 1061 1058 sectionlist=self.entry.sectionlist, 1062 1059 sections=self.entry.sections, 1060 + section_start_lines=self.entry.section_start_lines, 1063 1061 purpose=self.entry.declaration_purpose, 1064 1062 func_macro=func_macro) 1065 1063 else: ··· 1073 1067 parameterlist=self.entry.parameterlist, 1074 1068 parameterdescs=self.entry.parameterdescs, 1075 1069 parametertypes=self.entry.parametertypes, 1070 + parameterdesc_start_lines=self.entry.parameterdesc_start_lines, 1076 1071 sectionlist=self.entry.sectionlist, 1077 1072 sections=self.entry.sections, 1073 + section_start_lines=self.entry.section_start_lines, 1078 1074 purpose=self.entry.declaration_purpose, 1079 1075 func_macro=func_macro) 1080 1076 ··· 1120 1112 parameterlist=self.entry.parameterlist, 1121 1113 parameterdescs=self.entry.parameterdescs, 1122 1114 parametertypes=self.entry.parametertypes, 1115 + parameterdesc_start_lines=self.entry.parameterdesc_start_lines, 1123 1116 sectionlist=self.entry.sectionlist, 1124 1117 sections=self.entry.sections, 1118 + section_start_lines=self.entry.section_start_lines, 1125 1119 purpose=self.entry.declaration_purpose) 1126 1120 return 1127 1121 ··· 1146 1136 module=self.entry.modulename, 1147 1137 sectionlist=self.entry.sectionlist, 1148 1138 sections=self.entry.sections, 1139 + section_start_lines=self.entry.section_start_lines, 1149 1140 purpose=self.entry.declaration_purpose) 1150 1141 return 1151 1142 ··· 1179 1168 return 1180 1169 1181 1170 # start a new entry 1182 - self.reset_state(ln + 1) 1171 + self.reset_state(ln) 1183 1172 self.entry.in_doc_sect = False 1184 1173 1185 1174 # next line is always the function name ··· 1292 1281 if r.match(line): 1293 1282 self.dump_section() 1294 1283 self.entry.section = self.section_default 1295 - self.entry.new_start_line = line 1284 + self.entry.new_start_line = ln 1296 1285 self.entry.contents = "" 1297 1286 1298 1287 if doc_sect.search(line): ··· 1630 1619 self.dump_section() 1631 1620 self.output_declaration("doc", None, 1632 1621 sectionlist=self.entry.sectionlist, 1633 - sections=self.entry.sections, module=self.config.modulename) 1622 + sections=self.entry.sections, 1623 + section_start_lines=self.entry.section_start_lines, 1624 + module=self.config.modulename) 1634 1625 self.reset_state(ln) 1635 1626 1636 1627 elif doc_content.search(line):