From e236d39ef149a4580ed7ce48ed39cdbe2a53e3a1 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Fri, 21 Jun 2019 23:23:22 +0530 Subject: [PATCH] zulint: Add option to specify description of linter functions. Extract description of function from __doc__ if used as wrapper. --- tools/zulint/command.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/zulint/command.py b/tools/zulint/command.py index fa098d1e26..c6d98859f8 100644 --- a/tools/zulint/command.py +++ b/tools/zulint/command.py @@ -71,6 +71,7 @@ def run_parallel(lint_functions): class LinterConfig: lint_functions = {} # type: Dict[str, Callable[[], int]] + lint_descriptions = {} # type: Dict[str, str] def __init__(self, args): # type: (argparse.Namespace) -> None @@ -94,9 +95,10 @@ class LinterConfig: def lint(self, func): # type: (Callable[[], int]) -> Callable[[], int] self.lint_functions[func.__name__] = func + self.lint_descriptions[func.__name__] = func.__doc__ if func.__doc__ else "External Linter" return func - def external_linter(self, name, command, target_langs=[], pass_targets=True): + def external_linter(self, name, command, target_langs=[], pass_targets=True, description="External Linter"): # type: (str, List[str], List[str], bool) -> None """Registers an external linter program to be run as part of the linter. This program will be passed the subset of files being @@ -105,6 +107,7 @@ class LinterConfig: If target_langs is empty, just runs the linter unconditionally. """ + self.lint_descriptions[name] = description color = next(colors) def run_linter():