fish-shell/CONTRIBUTING.md

106 lines
2 KiB
Markdown
Raw Normal View History

2012-11-18 12:39:37 +00:00
# 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. fish uses the Allman/BSD style of indentation.
2. Indent with spaces, not tabs.
3. Use 4 spaces per indent (unless needed like `Makefile`).
4. Opening curly bracket is on the following line:
2012-11-18 12:39:37 +00:00
// ✔:
struct name
{
2012-11-18 12:39:37 +00:00
// code
};
void func()
{
2012-11-18 12:39:37 +00:00
// code
}
if (...)
{
2012-11-18 12:39:37 +00:00
// code
}
// ✗:
void func() {
2012-11-18 12:39:37 +00:00
// code
}
5. Put space after `if`, `while` and `for` before conditions.
2012-11-18 12:39:37 +00:00
// ✔:
if () {}
// ✗:
if() {}
6. Put spaces before and after operators excluding increment and decrement;
2012-11-18 12:39:37 +00:00
// ✔:
int a = 1 + 2 * 3;
a++;
// ✗:
int a=1+2*3;
a ++;
7. Never put spaces between function name and parameters list.
2012-11-18 12:39:37 +00:00
// ✔:
func(args);
// ✗:
func (args);
8. Never put spaces after `(` and before `)`.
9. Always put space after comma and semicolon.
2012-11-18 12:39:37 +00:00
// ✔:
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 tripple slash:
2012-11-18 12:39:37 +00:00
// ✔:
/// 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
2012-11-19 21:16:50 +00:00
All names in code should be `small_snake_case`. No Hungarian notation is used.
2012-11-18 12:39:37 +00:00
Classes and structs names should be followed by `_t`.
[dox]: http://www.stack.nl/~dimitri/doxygen/ "Doxygen homepage"