"""
Parse lernel-doc tags on multiple kernel source files. """
import argparse import logging import os import re
from kdoc_parser import KernelDoc from kdoc_output import OutputFormat
class GlobSourceFiles: """
Parse C source code file names and directories via an Interactor. """
def __init__(self, srctree=None, valid_extensions=None): """
Initialize valid extensions with a tuple.
Ifnot defined, assume default C extensions (.c and .h)
It would be possible to use python's glob function, but it is
very slow, and it isnot interactive. So, it would wait to read all
directories before actually do something.
def parse_files(self, file_list, file_not_found_cb): """
Define an interator to parse all source files from file_list,
handling directories if any """
ifnot file_list: return
for fname in file_list: if self.srctree:
f = os.path.join(self.srctree, fname) else:
f = fname
if os.path.isdir(f): yieldfrom self._parse_dir(f) elif os.path.isfile(f): yield f elif file_not_found_cb:
file_not_found_cb(fname)
class KernelFiles(): """
Parse kernel-doc tags on multiple kernel source files.
There are two type of parsers defined here:
- self.parse_file(): parses both kernel-doc markups and
EXPORT_SYMBOL* macros;
- self.process_export_file(): parses only EXPORT_SYMBOL* macros. """
def warning(self, msg): """Ancillary routine to output a warning and increment error count"""
self.config.log.warning(msg)
self.errors += 1
def error(self, msg): """Ancillary routine to output an error and increment error count"""
self.config.log.error(msg)
self.errors += 1
def parse_file(self, fname): """
Parse a single Kernel source. """
# Prevent parsing the same file twice if results are cached if fname in self.files: return
ifnot werror:
kcflags = os.environ.get("KCFLAGS", None) if kcflags:
match = re.search(r"(\s|^)-Werror(\s|$)/", kcflags) if match:
werror = True
# reading this variable is for backwards compat just in case # someone was calling it with the variable from outside the # kernel's build system
kdoc_werror = os.environ.get("KDOC_WERROR", None) if kdoc_werror:
werror = kdoc_werror
# Some variables are global to the parser logic as a whole as they are # used to send control configuration to KernelDoc class. As such, # those variables are read-only inside the KernelDoc.
self.config = argparse.Namespace
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.