From 82f41683eaeb94cfd9463893defc132eced74c91 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Mon, 7 Oct 2024 16:37:30 +0100 Subject: [PATCH] check-style: Add support for more format guards --- utils/check-style-clang-format.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/utils/check-style-clang-format.py b/utils/check-style-clang-format.py index 00358acd0..12ef377a8 100755 --- a/utils/check-style-clang-format.py +++ b/utils/check-style-clang-format.py @@ -43,8 +43,17 @@ CLANG_FORMAT_VERSIONS = [ 14, ] -CLANG_FORMAT_GUARD_ON = "// clang-format on" -CLANG_FORMAT_GUARD_OFF = "// clang-format off" +FORMAT_GUARD_ON = [ + "// clang-format on", + "# cmake-format: on", + "# fmt: on", +] + +FORMAT_GUARD_OFF = [ + "// clang-format off", + "# cmake-format: off", + "# fmt: off", +] DIRECTORIES_TO_SKIP = [ "__pycache__", @@ -514,14 +523,13 @@ def check_manually_file( if respect_clang_format_guards: line_stripped = line.strip() - if line_stripped == CLANG_FORMAT_GUARD_ON: + if line_stripped in FORMAT_GUARD_ON: clang_format_enabled = True - elif line_stripped == CLANG_FORMAT_GUARD_OFF: + elif line_stripped in FORMAT_GUARD_OFF: clang_format_enabled = False if not clang_format_enabled and line_stripped not in ( - CLANG_FORMAT_GUARD_ON, - CLANG_FORMAT_GUARD_OFF, + FORMAT_GUARD_ON + FORMAT_GUARD_OFF ): continue