Skip to content

Commit

Permalink
ENH: Support documents for better code formatting conformance
Browse files Browse the repository at this point in the history
Use Update C++/C attributes for itk style conformance.

Add script to assist with running clang-format on topic-branches Derived
from
https://github.com/Kitware/CMake/blob/master/Utilities/Scripts/clang-format.bash

Define the .clang-format config file to enforce style that is compatible
with automated enforcement.

A code style that can be automatically enforced and integrated
with IDE's for automated conformance.

The code style options are defined at
https://clang.llvm.org/docs/ClangFormatStyleOptions.html
  • Loading branch information
hjmjohnson committed Aug 20, 2019
1 parent 30b8145 commit d2fd21f
Show file tree
Hide file tree
Showing 928 changed files with 81,731 additions and 81,897 deletions.
53 changes: 37 additions & 16 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
## This config file is only relevant for clang-format version 8.0.0
## See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html for details of each option
##
## The clang-foramt binaries can be downloaded as part of the clang binar distributions
## from http://releases.llvm.org/download.html
---
# This configuration requires clang-format version 8.0.0 exactly.
# BasedOnStyle: Mozilla
Language: Cpp
BasedOnStyle: Mozilla
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
# clang 9.0 AllowAllArgumentsOnNextLine: true
# clang 9.0 AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
# clang 9.0 AllowShortLambdasOnASingleLine: All
# clang 9.0 features AllowShortIfStatementsOnASingleLine: Never
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: TopLevel
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: All
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: true
BreakBeforeBraces: Custom
BraceWrapping:
# clang 9.0 feature AfterCaseLabel: false
AfterClass: true
AfterControlStatement: true
AfterEnum: true
Expand All @@ -32,20 +44,23 @@ BraceWrapping:
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: true
## This is the big change from historical ITK formatting!
# Historically ITK used a style similar to https://en.wikipedia.org/wiki/Indentation_style#Whitesmiths_style
# with indented braces, and not indented code. This style is very difficult to automatically
# maintain with code beautification tools. Not indenting braces is more common among
# formatting tools.
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: true
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: GNU
BreakBeforeInheritanceComma: true
#clang 6.0 BreakBeforeInheritanceComma: true
BreakInheritanceList: BeforeComma
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
#clang 6.0 BreakConstructorInitializersBeforeComma: true
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
# ColumnLimit: 200
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
Expand All @@ -71,12 +86,12 @@ IncludeCategories:
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentPPDirectives: AfterHash
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
Expand All @@ -92,13 +107,16 @@ PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 0
PointerAlignment: Left
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Middle
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
# We may want to sort the includes as a separate pass
SortIncludes: false
# We may want to revisit this later
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
# SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
Expand All @@ -113,6 +131,9 @@ SpacesInCStyleCastParentheses: false
SpacesInParentheses: true
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 2
UseTab: Never
...
46 changes: 46 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.git* export-ignore
.hooks* export-ignore
.mailmap export-ignore

*.bat -crlf
*.bin -crlf
*.jpg -crlf
*.mha -crlf
*.pdf -crlf
*.png -crlf
*.raw -crlf
*.sh crlf=input
*.sh.in crlf=input
configure crlf=input
cvsrmvend crlf=input
imcp crlf=input
imglob crlf=input
imln crlf=input
immv crlf=input
imrm crlf=input
imtest crlf=input
install-sh crlf=input
newalpha crlf=input
newversion crlf=input
remove_ext crlf=input
vxl_doxy.pl crlf=input
zap.pl crlf=input


# Custom attribute to mark sources as using our C++/C code style.
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat

*.c our-c-style
*.h our-c-style
*.cxx our-c-style
*.hxx our-c-style
*.txx our-c-style
*.txt whitespace=tab-in-indent,no-lf-at-eof
*.cmake whitespace=tab-in-indent,no-lf-at-eof

# ExternalData content links must have LF newlines
*.md5 crlf=input
*.sha512 crlf=input

# ghostflow-director GitHub automatic check for maximum repository file size
# * hooks-max-size=100000
Loading

0 comments on commit d2fd21f

Please sign in to comment.