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: postpone warnings to the output plugin

We don't want to have warnings displayed for symbols that
weren't output. So, postpone warnings print to the output
plugin, where symbol output is validated.

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

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
9cbc2d3b 9235ec5e

+39 -26
+19 -5
scripts/lib/kdoc/kdoc_output.py
··· 116 116 117 117 return block 118 118 119 - def check_doc(self, name): 119 + def out_warnings(self, args): 120 + warnings = args.get('warnings', []) 121 + 122 + for warning, log_msg in warnings: 123 + if warning: 124 + self.config.log.warning(log_msg) 125 + else: 126 + self.config.log.info(log_msg) 127 + 128 + def check_doc(self, name, args): 120 129 """Check if DOC should be output""" 121 130 122 131 if self.no_doc_sections: ··· 135 126 return False 136 127 137 128 if self.out_mode == self.OUTPUT_ALL: 129 + self.out_warnings(args) 138 130 return True 139 131 140 132 if self.out_mode == self.OUTPUT_INCLUDE: 141 133 if name in self.function_table: 134 + self.out_warnings(args) 142 135 return True 143 136 144 137 return False 145 138 146 - def check_declaration(self, dtype, name): 139 + def check_declaration(self, dtype, name, args): 147 140 if name in self.nosymbol: 148 141 return False 149 142 150 143 if self.out_mode == self.OUTPUT_ALL: 144 + self.out_warnings(args) 151 145 return True 152 146 153 147 if self.out_mode in [self.OUTPUT_INCLUDE, self.OUTPUT_EXPORTED]: ··· 159 147 160 148 if self.out_mode == self.OUTPUT_INTERNAL: 161 149 if dtype != "function": 150 + self.out_warnings(args) 162 151 return True 163 152 164 153 if name not in self.function_table: 154 + self.out_warnings(args) 165 155 return True 166 156 167 157 return False ··· 177 163 self.out_doc(fname, name, args) 178 164 return self.data 179 165 180 - if not self.check_declaration(dtype, name): 166 + if not self.check_declaration(dtype, name, args): 181 167 return self.data 182 168 183 169 if dtype == "function": ··· 342 328 self.data += "\n" 343 329 344 330 def out_doc(self, fname, name, args): 345 - if not self.check_doc(name): 331 + if not self.check_doc(name, args): 346 332 return 347 333 self.out_section(args, out_docblock=True) 348 334 ··· 600 586 sectionlist = args.get('sectionlist', []) 601 587 sections = args.get('sections', {}) 602 588 603 - if not self.check_doc(name): 589 + if not self.check_doc(name, args): 604 590 return 605 591 606 592 self.data += f'.TH "{module}" 9 "{module}" "{self.man_date}" "API Manual" LINUX' + "\n"
+20 -21
scripts/lib/kdoc/kdoc_parser.py
··· 131 131 # Place all potential outputs into an array 132 132 self.entries = [] 133 133 134 - def show_warnings(self, dtype, declaration_name): # pylint: disable=W0613 135 - """ 136 - Allow filtering out warnings 137 - """ 138 - 139 - # TODO: implement it 140 - 141 - return True 142 - 143 134 # TODO: rename to emit_message 144 135 def emit_warning(self, ln, msg, warning=True): 145 136 """Emit a message""" 146 137 138 + log_msg = f"{self.fname}:{ln} {msg}" 139 + 140 + if self.entry: 141 + # Delegate warning output to output logic, as this way it 142 + # will report warnings/info only for symbols that are output 143 + 144 + self.entry.warnings.append((warning, log_msg)) 145 + return 146 + 147 147 if warning: 148 - self.config.log.warning("%s:%d %s", self.fname, ln, msg) 148 + self.config.log.warning(log_msg) 149 149 else: 150 - self.config.log.info("%s:%d %s", self.fname, ln, msg) 150 + self.config.log.info(log_msg) 151 151 152 152 def dump_section(self, start_new=True): 153 153 """ ··· 221 221 # For now, we're keeping the same name of the function just to make 222 222 # easier to compare the source code of both scripts 223 223 224 - if "declaration_start_line" not in args: 225 - args["declaration_start_line"] = self.entry.declaration_start_line 226 - 224 + args["declaration_start_line"] = self.entry.declaration_start_line 227 225 args["type"] = dtype 226 + args["warnings"] = self.entry.warnings 228 227 229 228 # TODO: use colletions.OrderedDict 230 229 ··· 255 256 self.entry.sectcheck = "" 256 257 self.entry.struct_actual = "" 257 258 self.entry.prototype = "" 259 + 260 + self.entry.warnings = [] 258 261 259 262 self.entry.parameterlist = [] 260 263 self.entry.parameterdescs = {} ··· 329 328 if param not in self.entry.parameterdescs and not param.startswith("#"): 330 329 self.entry.parameterdescs[param] = self.undescribed 331 330 332 - if self.show_warnings(dtype, declaration_name) and "." not in param: 331 + if "." not in param: 333 332 if decl_type == 'function': 334 333 dname = f"{decl_type} parameter" 335 334 else: ··· 869 868 self.entry.parameterlist.append(arg) 870 869 if arg not in self.entry.parameterdescs: 871 870 self.entry.parameterdescs[arg] = self.undescribed 872 - if self.show_warnings("enum", declaration_name): 873 - self.emit_warning(ln, 874 - f"Enum value '{arg}' not described in enum '{declaration_name}'") 871 + self.emit_warning(ln, 872 + f"Enum value '{arg}' not described in enum '{declaration_name}'") 875 873 member_set.add(arg) 876 874 877 875 for k in self.entry.parameterdescs: 878 876 if k not in member_set: 879 - if self.show_warnings("enum", declaration_name): 880 - self.emit_warning(ln, 881 - f"Excess enum value '%{k}' description in '{declaration_name}'") 877 + self.emit_warning(ln, 878 + f"Excess enum value '%{k}' description in '{declaration_name}'") 882 879 883 880 self.output_declaration('enum', declaration_name, 884 881 enum=declaration_name,