Skip to content

Commit f7182a0

Browse files
authored
Update CONTRIBUTING.md
Added style information.
1 parent be4dc51 commit f7182a0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Diff for: CONTRIBUTING.md

+32
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,35 @@ Consumers of this library require a strict approach to incrementing versioning o
111111
* Any new public symbols require a minor version bump.
112112
* Any alteration or removal of public symbols requires a major version bump, including changing the size of a class. This is necessary for
113113
consumers to do dependency injection properly.
114+
115+
## Preparing code for submission
116+
117+
Generally, JsonCpp's style guide has been pretty relaxed, with the following common themes:
118+
119+
* Variables and function names use lower camel case (E.g. parseValue or collectComments).
120+
* Class use camel case (e.g. OurReader)
121+
* Member variables have a trailing underscore
122+
* Prefer `nullptr` over `NULL`.
123+
* Passing by non-const reference is allowed.
124+
* Single statement if blocks may omit brackets.
125+
* Generally prefer less space over more space.
126+
127+
For an example:
128+
129+
```c++
130+
bool Reader::decodeNumber(Token& token) {
131+
Value decoded;
132+
if (!decodeNumber(token, decoded))
133+
return false;
134+
currentValue().swapPayload(decoded);
135+
currentValue().setOffsetStart(token.start_ - begin_);
136+
currentValue().setOffsetLimit(token.end_ - begin_);
137+
return true;
138+
}
139+
```
140+
141+
Before submitting your code, ensure that you meet the versioning requirements above, follow the style guide of the file you are modifying (or the above rules for new files), and run clang format. Meson exposes clang format with the following command:
142+
143+
```
144+
ninja -v -C build-${LIB_TYPE}/ clang-format
145+
```

0 commit comments

Comments
 (0)