summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskullydazed <skullydazed@users.noreply.github.com>2019-04-19 00:59:51 +0200
committerGitHub <noreply@github.com>2019-04-19 00:59:51 +0200
commit068571b9febb46edb64663bf6e84ae821a8219a3 (patch)
tree8dd5c2f1de76b60dc7261ff92cc5d84e3739adaa
parent7a1086e4057a64f841ba178aa9eebb0002722ae2 (diff)
downloadqmk_firmware-068571b9febb46edb64663bf6e84ae821a8219a3.tar.gz
qmk_firmware-068571b9febb46edb64663bf6e84ae821a8219a3.tar.xz
Update our style guide (#5500)
* Update our style guide * Clarify muiltple condition ifs * update the ifdef section
-rw-r--r--.clang-format2
-rw-r--r--.editorconfig2
-rw-r--r--docs/contributing.md10
3 files changed, 11 insertions, 3 deletions
diff --git a/.clang-format b/.clang-format
index bd896176d..4652b9e0a 100644
--- a/.clang-format
+++ b/.clang-format
@@ -20,7 +20,7 @@ SortIncludes: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: 'false'
-TabWidth: '2'
+TabWidth: '4'
UseTab: Never
...
diff --git a/.editorconfig b/.editorconfig
index 4cd051ce9..c8cb35b86 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -5,7 +5,7 @@ root = true
[*]
indent_style = space
-indent_size = 2
+indent_size = 4
# We recommend you to keep these unchanged
charset = utf-8
diff --git a/docs/contributing.md b/docs/contributing.md
index 15066185b..7d1a9691c 100644
--- a/docs/contributing.md
+++ b/docs/contributing.md
@@ -56,7 +56,7 @@ Never made an open source contribution before? Wondering how contributions work
Most of our style is pretty easy to pick up on, but right now it's not entirely consistent. You should match the style of the code surrounding your change, but if that code is inconsistent or unclear use the following guidelines:
-* We indent using two spaces (soft tabs)
+* We indent using four (4) spaces (soft tabs)
* We use a modified One True Brace Style
* Opening Brace: At the end of the same line as the statement that opens the block
* Closing Brace: Lined up with the first character of the statement that opens the block
@@ -71,6 +71,14 @@ Most of our style is pretty easy to pick up on, but right now it's not entirely
* If you not sure if a comment is obvious, go ahead and include it.
* In general we don't wrap lines, they can be as long as needed. If you do choose to wrap lines please do not wrap any wider than 76 columns.
* We use `#pragma once` at the start of header files rather than old-style include guards (`#ifndef THIS_FILE_H`, `#define THIS_FILE_H`, ..., `#endif`)
+* We accept both forms of preprocessor if's: `#ifdef DEFINED` and `#if defined(DEFINED)`
+ * If you are not sure which to prefer use the `#if defined(DEFINED)` form.
+ * Do not change existing code from one style to the other, except when moving to a multiple condition `#if`.
+ * Do not put whitespace between `#` and `if`.
+ * When deciding how (or if) to indent directives keep these points in mind:
+ * Readability is more important than consistency.
+ * Follow the file's existing style. If the file is mixed follow the style that makes sense for the section you are modifying.
+ * When choosing to indent you can follow the indention level of the surrounding C code, or preprocessor directives can have their own indent level. Choose the style that best communicates the intent of your code.
Here is an example for easy reference: