Skip to content

Commit 7901bba

Browse files
committed
ENH: Adding ITK code style files
1 parent 9545ae4 commit 7901bba

File tree

2 files changed

+170
-0
lines changed

2 files changed

+170
-0
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
## This config file is only relevant for clang-format version 8.0.0
2+
##
3+
## Examples of each format style can be found on the in the clang-format documentation
4+
## See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html for details of each option
5+
##
6+
## The clang-format binaries can be downloaded as part of the clang binary distributions
7+
## from http://releases.llvm.org/download.html
8+
##
9+
## Use the script Utilities/Maintenance/clang-format.bash to faciliate
10+
## maintaining a consistent code style.
11+
##
12+
## EXAMPLE apply code style enforcement before commit:
13+
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --modified
14+
## EXAMPLE apply code style enforcement after commit:
15+
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --last
16+
---
17+
# This configuration requires clang-format version 8.0.0 exactly.
18+
BasedOnStyle: Mozilla
19+
Language: Cpp
20+
AccessModifierOffset: -2
21+
AlignAfterOpenBracket: Align
22+
AlignConsecutiveAssignments: false
23+
AlignConsecutiveDeclarations: true
24+
AlignEscapedNewlines: Right
25+
AlignOperands: true
26+
AlignTrailingComments: true
27+
# clang 9.0 AllowAllArgumentsOnNextLine: true
28+
# clang 9.0 AllowAllConstructorInitializersOnNextLine: true
29+
AllowAllParametersOfDeclarationOnNextLine: false
30+
AllowShortBlocksOnASingleLine: false
31+
AllowShortCaseLabelsOnASingleLine: false
32+
AllowShortFunctionsOnASingleLine: Inline
33+
# clang 9.0 AllowShortLambdasOnASingleLine: All
34+
# clang 9.0 features AllowShortIfStatementsOnASingleLine: Never
35+
AllowShortIfStatementsOnASingleLine: false
36+
AllowShortLoopsOnASingleLine: false
37+
AlwaysBreakAfterDefinitionReturnType: None
38+
AlwaysBreakAfterReturnType: All
39+
AlwaysBreakBeforeMultilineStrings: false
40+
AlwaysBreakTemplateDeclarations: Yes
41+
BinPackArguments: false
42+
BinPackParameters: false
43+
BreakBeforeBraces: Custom
44+
BraceWrapping:
45+
# clang 9.0 feature AfterCaseLabel: false
46+
AfterClass: true
47+
AfterControlStatement: true
48+
AfterEnum: true
49+
AfterFunction: true
50+
AfterNamespace: true
51+
AfterObjCDeclaration: true
52+
AfterStruct: true
53+
AfterUnion: true
54+
AfterExternBlock: true
55+
BeforeCatch: true
56+
BeforeElse: true
57+
## This is the big change from historical ITK formatting!
58+
# Historically ITK used a style similar to https://en.wikipedia.org/wiki/Indentation_style#Whitesmiths_style
59+
# with indented braces, and not indented code. This style is very difficult to automatically
60+
# maintain with code beautification tools. Not indenting braces is more common among
61+
# formatting tools.
62+
IndentBraces: false
63+
SplitEmptyFunction: false
64+
SplitEmptyRecord: false
65+
SplitEmptyNamespace: false
66+
BreakBeforeBinaryOperators: None
67+
#clang 6.0 BreakBeforeInheritanceComma: true
68+
BreakInheritanceList: BeforeComma
69+
BreakBeforeTernaryOperators: true
70+
#clang 6.0 BreakConstructorInitializersBeforeComma: true
71+
BreakConstructorInitializers: BeforeComma
72+
BreakAfterJavaFieldAnnotations: false
73+
BreakStringLiterals: true
74+
## The following line allows larger lines in non-documentation code
75+
ColumnLimit: 120
76+
CommentPragmas: '^ IWYU pragma:'
77+
CompactNamespaces: false
78+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
79+
ConstructorInitializerIndentWidth: 2
80+
ContinuationIndentWidth: 2
81+
Cpp11BracedListStyle: false
82+
DerivePointerAlignment: false
83+
DisableFormat: false
84+
ExperimentalAutoDetectBinPacking: false
85+
FixNamespaceComments: true
86+
ForEachMacros:
87+
- foreach
88+
- Q_FOREACH
89+
- BOOST_FOREACH
90+
IncludeBlocks: Preserve
91+
IncludeCategories:
92+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
93+
Priority: 2
94+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
95+
Priority: 3
96+
- Regex: '.*'
97+
Priority: 1
98+
IncludeIsMainRegex: '(Test)?$'
99+
IndentCaseLabels: true
100+
IndentPPDirectives: AfterHash
101+
IndentWidth: 2
102+
IndentWrappedFunctionNames: false
103+
JavaScriptQuotes: Leave
104+
JavaScriptWrapImports: true
105+
KeepEmptyLinesAtTheStartOfBlocks: true
106+
MacroBlockBegin: ''
107+
MacroBlockEnd: ''
108+
MaxEmptyLinesToKeep: 2
109+
NamespaceIndentation: None
110+
ObjCBinPackProtocolList: Auto
111+
ObjCBlockIndentWidth: 2
112+
ObjCSpaceAfterProperty: true
113+
ObjCSpaceBeforeProtocolList: false
114+
PenaltyBreakAssignment: 2
115+
PenaltyBreakBeforeFirstCallParameter: 19
116+
PenaltyBreakComment: 300
117+
## The following line allows larger lines in non-documentation code
118+
PenaltyBreakFirstLessLess: 120
119+
PenaltyBreakString: 1000
120+
PenaltyBreakTemplateDeclaration: 10
121+
PenaltyExcessCharacter: 1000000
122+
PenaltyReturnTypeOnItsOwnLine: 200
123+
PointerAlignment: Middle
124+
ReflowComments: true
125+
# We may want to sort the includes as a separate pass
126+
SortIncludes: false
127+
# We may want to revisit this later
128+
SortUsingDeclarations: false
129+
SpaceAfterCStyleCast: false
130+
# SpaceAfterLogicalNot: false
131+
SpaceAfterTemplateKeyword: true
132+
SpaceBeforeAssignmentOperators: true
133+
SpaceBeforeCpp11BracedList: false
134+
SpaceBeforeCtorInitializerColon: true
135+
SpaceBeforeInheritanceColon: true
136+
SpaceBeforeParens: ControlStatements
137+
SpaceBeforeRangeBasedForLoopColon: true
138+
SpaceInEmptyParentheses: false
139+
SpacesBeforeTrailingComments: 1
140+
SpacesInAngles: false
141+
SpacesInContainerLiterals: false
142+
SpacesInCStyleCastParentheses: false
143+
SpacesInParentheses: false
144+
SpacesInSquareBrackets: false
145+
Standard: Cpp11
146+
StatementMacros:
147+
- Q_UNUSED
148+
- QT_REQUIRE_VERSION
149+
TabWidth: 2
150+
UseTab: Never
151+
...
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Apply to all code files
7+
[*]
8+
# A newline ending every file
9+
insert_final_newline = true
10+
11+
# Set default charset
12+
charset = utf-8
13+
14+
# 4 space indentation
15+
indent_style = space
16+
indent_size = 2
17+
18+
# Various options
19+
trim_trailing_whitespace = true

0 commit comments

Comments
 (0)