Skip to content

Commit

Permalink
Merge pull request #239 from kuke/add_clang-format_hook
Browse files Browse the repository at this point in the history
Add clang-format hook
  • Loading branch information
kuke authored Sep 8, 2017
2 parents 87931b4 + a3a6503 commit adfc955
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file is used by clang-format to autoformat paddle source code
#
# The clang-format is part of llvm toolchain.
# It need to install llvm and clang to format source code style.
#
# The basic usage is,
# clang-format -i -style=file PATH/TO/SOURCE/CODE
#
# The -style=file implicit use ".clang-format" file located in one of
# parent directory.
# The -i means inplace change.
#
# The document of clang-format is
# http://clang.llvm.org/docs/ClangFormat.html
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
---
Language: Cpp
BasedOnStyle: Google
IndentWidth: 2
TabWidth: 2
ContinuationIndentWidth: 4
MaxEmptyLinesToKeep: 2
AccessModifierOffset: -2 # The private/protected/public has no indent in class
Standard: Cpp11
AllowAllParametersOfDeclarationOnNextLine: true
BinPackParameters: false
BinPackArguments: false
...

5 changes: 5 additions & 0 deletions .clang_format.hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# clang-format hook without version check

clang-format $@
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
files: \.md$
- id: remove-tabs
files: \.md$
- repo: local
hooks:
- id: clang-format
name: clang-format
description: Format files with ClangFormat
entry: bash .clang_format.hook -i
language: system
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$
- repo: local
hooks:
- id: convert-markdown-into-html
Expand Down

0 comments on commit adfc955

Please sign in to comment.