From 4a748ae4d06501561208cc1fa4d1ed6851b2348a Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 13 May 2025 12:03:46 +0200 Subject: [PATCH 1/2] ENH: add clang-format file This makes it much easier to contribute to the project, since IDEs auto-save files using the proper formatting. No one needs to know the 100 rules by heart, the IDE takes care of it and saves time of reviewing Pull Requests. Format file copied from https://github.com/Slicer/Slicer/pull/7603 --- .clang-format | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..d81f24f3e --- /dev/null +++ b/.clang-format @@ -0,0 +1,41 @@ +--- +ColumnLimit: 120 +Language: Cpp +Standard: c++17 + +BasedOnStyle: Mozilla # Based on LLVM +# LLVM: https://github.com/llvm/llvm-project/blob/llvmorg-17.0.6/clang/lib/Format/Format.cpp#L1387-L1586 +# Mozilla: https://github.com/llvm/llvm-project/blob/llvmorg-17.0.6/clang/lib/Format/Format.cpp#L1790-L1814 + +# LLVM-style overides +AlignEscapedNewlines: Left +AllowShortEnumsOnASingleLine: true +AlwaysBreakTemplateDeclarations: true +BreakBeforeBinaryOperators: NonAssignment +ConstructorInitializerIndentWidth: 2 +IndentPPDirectives: AfterHash +PackConstructorInitializers: Never +PPIndentWidth: 1 + +# Mozilla-style overides +AllowShortFunctionsOnASingleLine: Inline +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +FixNamespaceComments: true +SpaceAfterTemplateKeyword: true + +BreakBeforeBraces: Allman + +# A list of macros that should be interpreted as foreach loops instead of as +# function calls. +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ] + +SortIncludes: false + +--- +Language: JavaScript +DisableFormat: true + +--- +Language: Json +DisableFormat: true From a154de3c7dad241d59052d62128e0d7ea0ad60b5 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Wed, 4 Jun 2025 14:52:48 +0200 Subject: [PATCH 2/2] ENH: Prevent clangformat from creating linebreaks as suggested by cpinter --- .clang-format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index d81f24f3e..bade17aa1 100644 --- a/.clang-format +++ b/.clang-format @@ -1,5 +1,5 @@ --- -ColumnLimit: 120 +ColumnLimit: 0 Language: Cpp Standard: c++17