diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-18 12:46:46 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-18 12:46:46 +0100 |
commit | 90ac822097aeadbe43669347e2e36f9bb91a951d (patch) | |
tree | 9ca1ada17ab24077c03eb19a6528846071af85db | |
parent | 5b65f0c7d386646229b6647332e7a09277872e4c (diff) |
Add Python code conventions to CODECONVENTIONS.
-rw-r--r-- | CODECONVENTIONS.md | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/CODECONVENTIONS.md b/CODECONVENTIONS.md index a0e0fc7ab..c8dbdae3d 100644 --- a/CODECONVENTIONS.md +++ b/CODECONVENTIONS.md @@ -1,7 +1,21 @@ -Code conventions -================ +Python code conventions +======================= -When writing new code, please adhere to the following conventions. +Python code follows [PEP 8](http://legacy.python.org/dev/peps/pep-0008/). + +Naming conventions: +- Module names are short and all lowercase; eg pyb, stm. +- Class names are CamelCase, with abreviations all uppercase; eg I2C, not + I2c. +- Function and method names are all lowercase with words separated by + a single underscore as necessary to improve readability; eg mem_read. +- Constants are all uppercase with words separated by a single underscore; + eg GPIO_IDR. + +C code conventions +================== + +When writing new C code, please adhere to the following conventions. White space: - Expand tabs to 4 spaces. @@ -18,8 +32,10 @@ Braces: - For else-statements, put the else on the same line as the previous closing brace. -Include directives: -- Don't include within a header file. +Header files: +- Try to stick to the Plan 9 header style, where header files do not + include other header files. +- Don't protect a header file from multiple inclusion with #if directives. Type names and declarations: - When defining a type, put '_t' after it. |