Update the style guide to mention that we're using clang-format now.

This commit is contained in:
Eric Haszlakiewicz
2020-04-06 01:49:14 +00:00
parent 31f1ab2be1
commit 9a494081cb

View File

@@ -4,22 +4,22 @@ When changing the style, commit that separately from other changes.
For new code and major changes to a function, switch to the official json-c style. For new code and major changes to a function, switch to the official json-c style.
Official json-c style: Official json-c style:
Aim for readability, not strict conformance to fixed style rules. Aim for readability, not strict conformance to fixed style rules.
These rules are not comprehensive. Look to existing code for guidelines. Formatting is tab based; previous attempts at proper alignment with
Indentation is tab based, with continuations of long lines starting with tabs then spaces for alignment. spaces for continuation lines have been abandoned in favor of the
Try to line up components of continuation lines with corresponding part of the line above (i.e. "indent -lp" effect), but avoid excessive indentation tha causes extra line wraps. convenience of using clang-format.
e.g. (T=tab, S=space): Refer to the .clang-format file for details, and run the tool before commit:
TTTTsome_long_func_call(arg1, arg2,
TTTTSSSSSSSSSSSSSSSSSSSarg3, arg4); clang-format -i somefile.c foo.h
TTTTsome_reallly_really_long_func_name(arg1,
TTTTTarg2, arg3, arg4); For sections of code that would be significantly negatively impacted, surround
There should be a space between "if"/"while" and the following parenthesis. them with magic comments to disable formatting:
"case" lines are indented at the same level as the "switch" statement.
Commas are followed by a single space. /* clang-format off */
Include spaces around most non-unary, non-postfix operators, "=", "==', "&", "||", etc... ...code...
Function calls have no space between the name and the parenthesis. /* clang-format on */
Curly braces go on their own line.
Curly braces may be omitted.
Naming: Naming:
Words within function and variable names are separated with underscores. Avoid camel case. Words within function and variable names are separated with underscores. Avoid camel case.
@@ -29,3 +29,4 @@ Other:
Variables should be defined for the smallest scope needed. Variables should be defined for the smallest scope needed.
Functions should be defined static when possible. Functions should be defined static when possible.
When possible, avoid exposing internals in the public API. When possible, avoid exposing internals in the public API.