From patchwork Wed Jul 3 21:13:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1599 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 36C2D60C01 for ; Wed, 3 Jul 2019 23:14:24 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AC93324B for ; Wed, 3 Jul 2019 23:14:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1562188463; bh=B+Ksoj8SlgFZD/J4Fr60MOg75vBeN1fAVUHYNZa7S68=; h=From:To:Subject:Date:From; b=mGmIRG7tYe5BuWiZjVsHpnrnbPIyEyUNRuz0IDRTKv2DuwpuErUdEupaKp7crfP2p uh8hHE+0kojquHk5KDBPIK+VeZaqgn6XY3V6FrONoygtSppikkDhz0rlsMLcdJkrP2 LR0LZuYLSiVkJbTUiaubWDfbwsavxY/TOGF5TIlo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 4 Jul 2019 00:13:58 +0300 Message-Id: <20190703211358.2362-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] utils: checkstyle.py: Add Doxygen formatter X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jul 2019 21:14:24 -0000 Add a formatter for doxygen comments. In its initial implementation the formatter ensures that the first word of a \return statement starts with an uppercase letter. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Kieran Bingham --- utils/checkstyle.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index bc631d405007..fab4b116d2ff 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -350,6 +350,34 @@ class CLangFormatter(Formatter): return ret.stdout.decode('utf-8') +class DoxygenFormatter(Formatter): + patterns = ('*.c', '*.cpp') + + return_regex = re.compile(' +\\* +\\\\return +[a-z]') + + @classmethod + def format(cls, filename, data): + lines = [] + in_doxygen = False + + for line in data.split('\n'): + if line.find('/**') != -1: + in_doxygen = True + + if not in_doxygen: + lines.append(line) + continue + + line = cls.return_regex.sub(lambda m: m.group(0)[:-1] + m.group(0)[-1].upper(), line) + + if line.find('*/') != -1: + in_doxygen = False + + lines.append(line) + + return '\n'.join(lines) + + class StripTrailingSpaceFormatter(Formatter): patterns = ('*.c', '*.cpp', '*.h', '*.py', 'meson.build')