aboutsummaryrefslogtreecommitdiffhomepage
path: root/STYLEGUIDE.md
diff options
context:
space:
mode:
authorGravatar Łukasz Niemier <lukasz@niemier.pl>2012-11-18 13:39:37 +0100
committerGravatar Łukasz Niemier <lukasz@niemier.pl>2012-11-18 13:39:37 +0100
commiteb7601d116e0ccbdf5dfaa62aba7ef9bc20fa761 (patch)
tree5f853ad2ddfd7efd35b699d148814a54a8978447 /STYLEGUIDE.md
parent47df1ae40adecd0a02fc7dd06ab0745cb18c3fe0 (diff)
Add styleguide
Diffstat (limited to 'STYLEGUIDE.md')
-rw-r--r--STYLEGUIDE.md101
1 files changed, 101 insertions, 0 deletions
diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md
new file mode 100644
index 00000000..dd304b3d
--- /dev/null
+++ b/STYLEGUIDE.md
@@ -0,0 +1,101 @@
+# Style guide
+
+This is style guide for fish contributors. You should use it for any new code
+that you would add to this project and try to format existing code to use this
+style.
+
+## Formatting
+
+1. Always use 2 spaces instead tabs as indent (unless needed like `Makefile`).
+2. Opening curly bracket is always the same line as declaration.
+
+ // ✔:
+ struct name {
+ // code
+ };
+
+ void func() {
+ // code
+ }
+
+ if (...) {
+ // code
+ }
+
+ // ✗:
+ void func()
+ {
+ // code
+ }
+
+3. Put space after `if`, `while` and `for` before conditions.
+
+ // ✔:
+ if () {}
+
+ // ✗:
+ if() {}
+
+4. Put spaces before and after operators excluding increment and decrement;
+
+ // ✔:
+ int a = 1 + 2 * 3;
+ a++;
+
+ // ✗:
+ int a=1+2*3;
+ a ++;
+
+5. Never put spaces between function name and parameters list.
+
+ // ✔:
+ func(args);
+
+ // ✗:
+ func (args);
+
+6. Never put spaces after `(` and before `)`.
+7. Always put space after comma and semicolon.
+
+ // ✔:
+ func(arg1, arg2);
+
+ for (int i = 0; i < LENGTH; i++) {}
+
+ // ✗:
+ func(arg1,arg2);
+
+ for (int i = 0;i<LENGTH;i++) {}
+
+## Documentation
+
+Document your code using [Doxygen][dox].
+
+1. Documentation comment should use double star notation or tipple slash:
+
+ // ✔:
+ /// Some var
+ int var;
+
+ /**
+ * Some func
+ */
+ void func();
+
+2. Use slash as tag mark:
+
+ // ✔:
+
+ /**
+ * \param a an integer argument.
+ * \param s a constant character pointer.
+ * \return The results
+ */
+ int foo(int a, const char *s);
+
+## Naming
+
+All names in code should be `small_snake_case`. No Hungary notation is used.
+Classes and structs names should be followed by `_t`.
+
+[dox]: http://www.stack.nl/~dimitri/doxygen/ "Doxygen homepage"