summaryrefslogtreecommitdiffstatshomepage
path: root/CODECONVENTIONS.md
diff options
context:
space:
mode:
authorDamien <damien.p.george@gmail.com>2013-12-29 12:12:25 +0000
committerDamien <damien.p.george@gmail.com>2013-12-29 12:12:25 +0000
commit7f7636e41c930ab5044dd795e36bc9253a403ee9 (patch)
tree759480fb995740f1914e183ce69751ee398cd589 /CODECONVENTIONS.md
parent1e6a25882ca5e132b89372bc2315f7841af3791a (diff)
downloadmicropython-7f7636e41c930ab5044dd795e36bc9253a403ee9.tar.gz
micropython-7f7636e41c930ab5044dd795e36bc9253a403ee9.zip
Add CODECONVENTIONS, and modify i2c module to conform.
Diffstat (limited to 'CODECONVENTIONS.md')
-rw-r--r--CODECONVENTIONS.md48
1 files changed, 48 insertions, 0 deletions
diff --git a/CODECONVENTIONS.md b/CODECONVENTIONS.md
new file mode 100644
index 0000000000..a0e0fc7ab2
--- /dev/null
+++ b/CODECONVENTIONS.md
@@ -0,0 +1,48 @@
+Code conventions
+================
+
+When writing new code, please adhere to the following conventions.
+
+White space:
+- Expand tabs to 4 spaces.
+- Don't leave trailing whitespace at the end of a line.
+- For control blocks (if, for, while), put 1 space between the
+ keyword and the opening parenthesis.
+- Put 1 space after a comma, and 1 space around operators.
+
+Braces:
+- Use braces for all blocks, even no-line and single-line pieces of
+ code.
+- Put opening braces on the end of the line it belongs to, not on
+ a new line.
+- For else-statements, put the else on the same line as the previous
+ closing brace.
+
+Include directives:
+- Don't include within a header file.
+
+Type names and declarations:
+- When defining a type, put '_t' after it.
+
+Examples
+--------
+
+Braces and spaces:
+
+ int foo(int x, int y) {
+ if (x < y) {
+ foo(y, x);
+ } else {
+ foo(x + 1, y - 1);
+ }
+
+ for (int i = 0; i < x; i++) {
+ }
+ }
+
+Type declarations:
+
+ typedef struct _my_struct_t {
+ int member;
+ void *data;
+ } my_struct_t;