diff options
author | Patrick Venture <venture@google.com> | 2018-09-24 10:39:54 -0700 |
---|---|---|
committer | Gunnar Mills <gmills@us.ibm.com> | 2018-09-27 15:36:14 +0000 |
commit | 0dcc430a56ba3a293972423305451dfe37ab00c7 (patch) | |
tree | 5c390b5724292092427168a1d3f609caeaff9906 | |
parent | 1cd8ea1f6cd967e1bae6a60aa709e4c97a37c8af (diff) | |
download | openbmc-docs-0dcc430a56ba3a293972423305451dfe37ab00c7.tar.gz openbmc-docs-0dcc430a56ba3a293972423305451dfe37ab00c7.zip |
add .clang-format exemplars
Adds .clang-format for cpp and javascript
Change-Id: I8a7ed63be54a3f44ef448cf603ee2a8643436afd
Signed-off-by: Patrick Venture <venture@google.com>
-rw-r--r-- | CONTRIBUTING.md | 8 | ||||
-rw-r--r-- | cpp-style-and-conventions.md | 102 | ||||
-rw-r--r-- | style/cpp/.clang-format | 99 | ||||
-rw-r--r-- | style/javascript/.clang-format | 5 |
4 files changed, 106 insertions, 108 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c75fb13..f00e10f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,13 +84,7 @@ ignore= NONE We follow the [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html). -A .clang-format file that closely approximates our JavaScript coding style is: -``` ---- -Language: JavaScript -BasedOnStyle: Google -ColumnLimit: 80 -``` +[Example .clang-format](https://www.github.com/openbmc/docs/blob/master/style/javascript/.clang-format) ### HTML/CSS diff --git a/cpp-style-and-conventions.md b/cpp-style-and-conventions.md index 15e957f..95f1a09 100644 --- a/cpp-style-and-conventions.md +++ b/cpp-style-and-conventions.md @@ -152,107 +152,7 @@ OpenBMC requires a clang-format of version 6.0 or greater. An example of how to run clang-format against all code in your repo can be found by referencing the [tool](https://github.com/openbmc/openbmc-build-scripts/blob/master/scripts/format-code.sh) used by CI. -A .clang-format file that closely approximates our coding style is: -``` ---- -Language: Cpp -# BasedOnStyle: LLVM -AccessModifierOffset: -2 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlinesLeft: false -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: true -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: true - AfterControlStatement: true - AfterEnum: true - AfterFunction: true - AfterNamespace: true - AfterObjCDeclaration: true - AfterStruct: true - AfterUnion: true - BeforeCatch: true - BeforeElse: true - IndentBraces: false -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Custom -BreakBeforeTernaryOperators: true -BreakConstructorInitializers: AfterColon -ColumnLimit: 80 -CommentPragmas: '^ IWYU pragma:' -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true -ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] -IncludeBlocks: Regroup -IncludeCategories: - - Regex: '^[<"](gtest|gmock)' - Priority: 5 - - Regex: '^"config.h"' - Priority: -1 - - Regex: '^".*\.hpp"' - Priority: 1 - - Regex: '^<.*\.h>' - Priority: 2 - - Regex: '^<.*' - Priority: 3 - - Regex: '.*' - Priority: 4 -IndentCaseLabels: true -IndentWidth: 4 -IndentWrappedFunctionNames: true -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Left -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 4 -UseTab: Never -... -``` +[Example .clang-format](https://www.github.com/openbmc/docs/blob/master/style/cpp/.clang-format) ### Bracket style diff --git a/style/cpp/.clang-format b/style/cpp/.clang-format new file mode 100644 index 0000000..ea71ad6 --- /dev/null +++ b/style/cpp/.clang-format @@ -0,0 +1,99 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: false +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + IndentBraces: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Custom +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: AfterColon +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +PointerAlignment: Left +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^[<"](gtest|gmock)' + Priority: 5 + - Regex: '^"config.h"' + Priority: -1 + - Regex: '^".*\.hpp"' + Priority: 1 + - Regex: '^<.*\.h>' + Priority: 2 + - Regex: '^<.*' + Priority: 3 + - Regex: '.*' + Priority: 4 +IndentCaseLabels: true +IndentWidth: 4 +IndentWrappedFunctionNames: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 4 +UseTab: Never +... + diff --git a/style/javascript/.clang-format b/style/javascript/.clang-format new file mode 100644 index 0000000..1240600 --- /dev/null +++ b/style/javascript/.clang-format @@ -0,0 +1,5 @@ +--- +Language: JavaScript +BasedOnStyle: Google +ColumnLimit: 80 +... |