Commit 94578837 authored by Konstantinos Chatzilygeroudis's avatar Konstantinos Chatzilygeroudis Committed by GitHub
Browse files

Merge pull request #143 from resibots/remove-clang-format

Remove clang-format tools
parents 10775366 6bb3dd41
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakTemplateDeclarations: false
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackParameters: true
BinPackArguments: true
ColumnLimit: 0
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: false
IndentWrappedFunctionNames: false
IndentFunctionDeclarationAfterType: false
MaxEmptyLinesToKeep: 1
KeepEmptyLinesAtTheStartOfBlocks: true
NamespaceIndentation: All
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
SpacesBeforeTrailingComments: 1
Cpp11BracedListStyle: true
Standard: Cpp11
IndentWidth: 4
TabWidth: 4
UseTab: Never
BreakBeforeBraces: Stroustrup
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
CommentPragmas: '^ IWYU pragma:'
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
SpaceBeforeParens: ControlStatements
DisableFormat: false
...
#!/usr/bin/env python
from subprocess import call, check_output
import fnmatch
import os
import sys
clang_format = "clang-format"
# Format directories and all subfolders using clang-format
def format_dir(folder, extensions):
matches = []
for root, dirnames, filenames in os.walk(folder):
for ext in extensions:
for filename in fnmatch.filter(filenames, '*'+ext):
matches.append(os.path.join(root, filename))
for filename in matches:
call([clang_format, "-i", filename])
# possible extensions
exts = ['.h', '.c', '.hpp', '.cpp', '.hh', '.cc']
if __name__ == "__main__":
if len(sys.argv) <= 1:
print "Usage: clean_code.py folder1 [folder2] ..."
sys.exit()
try:
check_output(["clang-format", "-help"])
clang_format = "clang-format"
except:
try:
check_output(["clang-format-3.6", "-help"])
clang_format = "clang-format-3.6"
except:
print "[ERROR]: You must have clang-format installed to run this script"
sys.exit()
# config file
curr_dir = os.getcwd()
# change if needed to find the config file
if curr_dir[len(curr_dir)-5:] == 'limbo':
os.chdir('tools')
# copy config file
call(["cp", ".clang-format", curr_dir])
# change back to old dir
os.chdir(curr_dir)
# format directories specified by the user
for arg in sys.argv[1:]:
format_dir(arg, exts)
# remove copied file if needed
if curr_dir[len(curr_dir)-5:] == 'limbo':
call(["rm", ".clang-format"])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment