History

docs: kdoc: rework process_export() slightly

Reorganize process_export() to eliminate duplicated code, don't look for exports in states where we don't expect them, and don't bother with normal state-machine processing if an export declaration has been found.

Jonathan Corbet committed 1 year ago

Commit d06c54f1 parent 0aa36751 file · +14 −16Browse files

Unified · Split

scripts/lib/kdoc/kdoc_parser.py+14−16
@@ -1211,16 +1211,17 @@ class KernelDoc: · 1210 unmodified lines
1211 1211
1212 if export_symbol.search(line):1212 if export_symbol.search(line):
1213 symbol = export_symbol.group(2)1213 symbol = export_symbol.group(2)
1214 for suffix in suffixes:1214 elif export_symbol_ns.search(line):
1215 symbol = symbol.removesuffix(suffix)
1216 function_set.add(symbol)
1217 return
1218
1219 if export_symbol_ns.search(line):
1220 symbol = export_symbol_ns.group(2)1215 symbol = export_symbol_ns.group(2)
1221 for suffix in suffixes:1216 else:
1222 symbol = symbol.removesuffix(suffix)1217 return False
1223 function_set.add(symbol)1218 #
1219 # Found an export, trim out any special suffixes
1220 #
1221 for suffix in suffixes:
1222 symbol = symbol.removesuffix(suffix)
1223 function_set.add(symbol)
1224 return True
1224 1225
1225 def process_normal(self, ln, line):1226 def process_normal(self, ln, line):
1226 """1227 """
@@ -1767,13 +1768,10 @@ class KernelDoc: · 540 unmodified lines
1767 # it was read twice. Here, we use the already-existing1768 # it was read twice. Here, we use the already-existing
1768 # loop to parse exported symbols as well.1769 # loop to parse exported symbols as well.
1769 #1770 #
1770 # TODO: It should be noticed that not all states are1771 if (self.state != state.NORMAL) or \
1771 # needed here. On a future cleanup, process export only1772 not self.process_export(export_table, line):
1772 # at the states that aren't handling comment markups.1773 # Hand this line to the appropriate state handler
1773 self.process_export(export_table, line)1774 self.state_actions[self.state](self, ln, line)
1774
1775 # Hand this line to the appropriate state handler
1776 self.state_actions[self.state](self, ln, line)
1777 1775
1778 except OSError:1776 except OSError:
1779 self.config.log.error(f"Error: Cannot open file {self.fname}")1777 self.config.log.error(f"Error: Cannot open file {self.fname}")