diff options
author | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2018-06-19 14:44:57 +0000 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2018-06-19 14:44:57 +0000 |
commit | baf161085f20b6c7b1332a5c4b0c9c5d174bc1bc (patch) | |
tree | 2020b94b1f111115b8083785fe8519cdf3a907c2 /docs | |
parent | c89a919536bc53a54ca4e35eca183020f606e5cc (diff) | |
download | gnome-control-center-baf161085f20b6c7b1332a5c4b0c9c5d174bc1bc.tar.gz |
docs: Document more of the code style
Diffstat (limited to 'docs')
-rw-r--r-- | docs/HACKING.md | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/docs/HACKING.md b/docs/HACKING.md index 880c3fcd5..8983e962a 100644 --- a/docs/HACKING.md +++ b/docs/HACKING.md @@ -7,6 +7,12 @@ rules. Please read them carefully and, if in doubt, ask a maintainer for directi The most important rule is: **see the surrounding code, and copy its style**. +That said, GNOME Settings assumes: + + * 2 spaces of indentation + * 120 columns of line width + * Newline before `{` + Another rule that applies to function declarations is that all parameters are aligned by the last '*'. There are plenty of examples below. @@ -23,6 +29,36 @@ Comment blocks should be formatted as following: */ ``` +## Conditionals + +Conditionals should either be all in one line, or one per line. Newlines inside +conditionals are aligned by the last parenthesis. + + +Some examples below: + +```c +// Single line if +if (a || b || (c && d)) + return; + +// Multiline if with nested parenthesis +if (long_boolean_variable_used_in_this_condition_a || + long_boolean_variable_used_in_this_condition_b || + (long_boolean_variable_used_in_this_condition_c && + long_boolean_variable_used_in_this_condition_d)) + { + return; + } + +// Another single line example with do {} while (...) +do + { + /* something */ + } +while (a || b || (c && d)); +``` + ## Structs and Enums Structures and enums are formatted as following: |