# Yacine Belkadi <yacine.belkadi.1@gmail.com>
# Yujie Liu <yujie.liu@intel.com>
-# TODO: implement warning filtering
-
"""
kernel_doc
==========
if msg:
print(msg)
+ error_count = kfiles.errors
+ if not error_count:
+ sys.exit(0)
+
+ if args.werror:
+ print(f"{error_count} warnings as errors")
+ sys.exit(error_count)
+
+ if args.verbose:
+ print(f"{error_count} errors")
+
+ if args.none:
+ sys.exit(0)
+
+ sys.exit(error_count)
+
# Call main method
if __name__ == "__main__":
import logging
import os
import re
-import sys
from kdoc_parser import KernelDoc
from kdoc_output import OutputFormat
KernelDoc.process_export(self.config.function_table, line)
except IOError:
- print(f"Error: Cannot open fname {fname}", fname=sys.stderr)
+ self.config.log.error("Error: Cannot open fname %s", fname)
self.config.errors += 1
def file_not_found_cb(self, fname):
fname, ln, dtype)
if msg:
yield fname, msg
+
+ @property
+ def errors(self):
+ """
+ Return a count of the number of warnings found, including
+ the ones displayed while interacting over self.msg.
+ """
+
+ return self.config.errors
warnings = args.get('warnings', [])
- for warning, log_msg in warnings:
- if warning:
- self.config.log.warning(log_msg)
- else:
- self.config.log.info(log_msg)
+ for log_msg in warnings:
+ self.config.log.warning(log_msg)
+ self.config.errors += 1
def check_doc(self, name, args):
"""Check if DOC should be output"""
log_msg = f"{self.fname}:{ln} {msg}"
+ if not warning:
+ self.config.log.info(log_msg)
+ return
+
if self.entry:
# Delegate warning output to output logic, as this way it
# will report warnings/info only for symbols that are output
- self.entry.warnings.append((warning, log_msg))
+ self.entry.warnings.append(log_msg)
return
- if warning:
- self.config.log.warning(log_msg)
- else:
- self.config.log.info(log_msg)
+ self.config.log.warning(log_msg)
def dump_section(self, start_new=True):
"""
if not members:
self.emit_warning(ln, f"{proto} error: Cannot parse struct or union!")
- self.config.errors += 1
return
if self.entry.identifier != declaration_name:
if not members:
self.emit_warning(ln, f"{proto}: error: Cannot parse enum!")
- self.config.errors += 1
return
if self.entry.identifier != declaration_name:
return
self.emit_warning(ln, "error: Cannot parse typedef!")
- self.config.errors += 1
@staticmethod
def process_export(function_table, line):
self.process_docblock(ln, line)
except OSError:
self.config.log.error(f"Error: Cannot open file {self.fname}")
- self.config.errors += 1