Skip to content

Commit 52d1906

Browse files
Riksu9000JF002
authored andcommitted
Separate and update coding conventions and contributing pages
1 parent 1d3098b commit 52d1906

3 files changed

Lines changed: 51 additions & 52 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ InfiniTime is an open-source firmware for the [Pinetime smartwatch](https://www.
1717
## Documentation
1818

1919
### Develop
20+
- [Coding conventions](/doc/coding-convention.md)
2021
- [Rough structure of the code](doc/code/Intro.md)
2122
- [How to implement an application](doc/code/Apps.md)
2223
- [Generate the fonts and symbols](src/displayapp/fonts/README.md)
@@ -48,9 +49,9 @@ InfiniTime is an open-source firmware for the [Pinetime smartwatch](https://www.
4849

4950
This project is far from being finished, and there are still a lot of things to do for this project to become a firmware usable by the general public.
5051

51-
Do not hesitate to fork the code, hack it and create pull-requests!
52+
Do not hesitate to fork the code, hack it and create pull-requests! Make sure to read the [coding conventions](/doc/coding-convention.md)
5253

53-
Read this page for more information on how you can help: [How to contribute?](doc/contribute.md)
54+
You don't need to be a programmer to contribute. Read this page for more information on how you can help: [How to contribute?](doc/contribute.md)
5455

5556
## Licenses
5657

doc/coding-convention.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Coding convention
2+
3+
## Language
4+
5+
The language of this project is **C++**, and all new code must be written in C++. (Modern) C++ provides a lot of useful tools and functionalities that are beneficial for embedded software development like `constexpr`, `template` and anything that provides zero-cost abstraction.
6+
7+
C code is accepted if it comes from another library like FreeRTOS, NimBLE, LVGL or the NRF-SDK.
8+
9+
## Coding style
10+
11+
The most important rule to follow is to try to keep the code as easy to read and maintain as possible.
12+
13+
Using an autoformatter is highly recommended, but make sure it's configured properly.
14+
15+
There are preconfigured autoformatter rules for:
16+
17+
* CLion (IntelliJ) in [.idea/codeStyles/Project.xml](/.idea/codeStyles/Project.xml)
18+
* `clang-format`
19+
20+
Also use `clang-tidy` to check the code for other issues.
21+
22+
If there are no preconfigured rules for your IDE, you can use one of the existing ones to configure your IDE.
23+
24+
- **Indentation** : 2 spaces, no tabulation
25+
- **Opening brace** at the end of the line
26+
- **Naming** : Choose self-describing variable name
27+
- **class** : PascalCase
28+
- **namespace** : PascalCase
29+
- **variable** : camelCase, **no** prefix/suffix ('_', 'm_',...) for class members
30+
- **Include guard** : `#pragma once` (no `#ifdef __MODULE__ / #define __MODULE__ / #endif`)
31+
- **Includes** :
32+
- files from the project : `#include "relative/path/to/the/file.h"`
33+
- external files and std : `#include <file.h>`
34+
- Only use [primary spellings for operators and tokens](https://en.cppreference.com/w/cpp/language/operator_alternative)
35+
- Use auto sparingly. Don't use auto for [fundamental/built-in types](https://en.cppreference.com/w/cpp/language/types) and [fixed width integer types](https://en.cppreference.com/w/cpp/types/integer), except when initializing with a cast to avoid duplicating the type name.
36+
- Examples:
37+
- `auto* app = static_cast<DisplayApp*>(instance);`
38+
- `auto number = static_cast<uint8_t>(variable);`
39+
- `uint8_t returnValue = MyFunction();`
40+
- Use nullptr instead of NULL

doc/contribute.md

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ As the documentation is part of the source code, you can submit your improvement
1414

1515
You want to fix a bug, add a cool new functionality or improve the code? See *How to submit a pull request below*.
1616

17-
## Spread the word
18-
19-
The Pinetime is a cool open source project that deserves to be known. Talk about it around you, on social networks, on your blog,... and let people know that we are working on an open source firmware for a smartwatch!
20-
2117
# How to submit a pull request?
2218

2319
## TL;DR
2420

2521
- Create a branch from develop
2622
- Work on a single subject in this branch. Create multiple branches/pulls-requests if you want to work on multiple subjects (bugs, features,...)
2723
- Test your modifications on the actual hardware
28-
- Check the code formatting against our coding conventions and [clang-format](../.clang-format) and [clang-tidy](../.clang-tidy)
24+
- Check your code against the [coding conventions](/doc/coding-convention.md) and [clang-format](../.clang-format) and [clang-tidy](../.clang-tidy)
2925
- Clean your code and remove files that are not needed
3026
- Write documentation related to your new feature if applicable
3127
- Create a pull request and write a great description about it: what does your PR do, why, how,... Add pictures and video if possible
@@ -38,9 +34,9 @@ If you want to fix a bug, add functionality or improve the code, you'll first ne
3834

3935
When your feature branch is ready, **make sure it actually works** and **do not forget to write documentation** about it if it's relevant.
4036

41-
**Creating a pull request containing modifications that haven't been tested is strongly discouraged.** If, for any reason, you cannot test your modifications but want to publish them anyway, **please mention it in the description**. This way, other contributors might be willing to test it and provide feedback about your code.
37+
**Creating a pull request containing modifications that haven't been tested is strongly discouraged.** If for any reason you cannot test your modifications, but want to publish them anyway, **please mention it in the description**. This way, other contributors might be willing to test it and provide feedback about your code.
4238

43-
Also, before submitting your PR, check the coding style of your code against the **coding conventions** detailed below. This project also provides [clang-format](../.clang-format) and [clang-tidy](../.clang-tidy) configuration files. You can use them to ensure correct formatting of your code.
39+
Before submitting a PR, check your code against our [coding conventions](/doc/coding-convention.md). This project also provides [clang-format](../.clang-format) and [clang-tidy](../.clang-tidy) configuration files. You should use them to ensure correct formatting of your code.
4440

4541
Don't forget to check the files you are going to commit and remove those which aren't necessary (config files from your IDE, for example). Remove old comments, commented code,...
4642

@@ -52,52 +48,14 @@ Once the pull request is reviewed and accepted, it'll be merged into **develop**
5248

5349
## Why all these rules?
5450

55-
Reviewing pull requests is a **very time consuming task** for the creator of this project ([JF002](https://github.com/JF002)) and for other contributors who take the time to review them. Everything you do to make reviewing easier will **get your PR merged faster**.
51+
Reviewing pull requests is a **very time consuming task**. Everything you do to make reviewing easier will **get your PR merged faster**.
5652

57-
When reviewing PRs, the author and contributors will first look at the **description**. If it's easy to understand what the PR does, why the modification is needed or interesting and how it's done, a good part of the work is already done : we understand the PR and its context.
53+
Reviewers will first look at the **description**. If it's easy to understand what the PR does, why the modification is needed or interesting and how it's done, a good part of the work is already done : we understand the PR and its context.
5854

59-
Then, reviewing **a few files that were modified for a single purpose** is a lot more easier than to review 30 files modified for many reasons (bug fix, UI improvements, typos in doc,...), even if all these changes make sense. Also, it's possible that we agree on some modification but not on some other, so we won't be able to merge the PR because of the changes that are not accepted.
55+
Reviewing **a few files that were modified for a single purpose** is a lot easier than reviewing 30 files modified for many reasons (bug fix, UI improvements, typos in doc,...), even if all the changes make sense. Also, it's possible that we agree on some modification but not on another, so we won't be able to merge the PR because of the changes that are not accepted.
6056

61-
We do our best to keep the code as consistent as possible. If the formatting of the code in your PR is not consistent with our code base, we'll ask you to review it, which will take more time.
57+
We do our best to keep the code as consistent as possible. If the formatting of your code is not consistent with our code base, we'll ask you to review it.
6258

63-
The last step of the review consists of **testing** the modification. If it doesn't work out of the box, we'll ask your to review your code and to ensure that it works as expected.
59+
Lastly the changes are tested. If it doesn't work out of the box, we'll ask your to review your code and to ensure that it works as expected.
6460

6561
It's totally normal for a PR to need some more work even after it was created, that's why we review them. But every round trip takes time, so it's good practice to try to reduce them as much as possible by following those simple rules.
66-
67-
# Coding convention
68-
69-
## Language
70-
71-
The language of this project is **C++**, and all new code must be written in C++. (Modern) C++ provides a lot of useful tools and functionalities that are beneficial for embedded software development like `constexpr`, `template` and anything that provides zero-cost abstraction.
72-
73-
C code is accepted if it comes from another library like FreeRTOS, NimBLE, LVGL or the NRF-SDK.
74-
75-
## Coding style
76-
77-
The most important rule to follow is to try to keep the code as easy to read and maintain as possible.
78-
79-
Using an autoformatter is highly recommended, but make sure it's configured properly.
80-
81-
There are preconfigured autoformatter rules for:
82-
83-
* CLion (IntelliJ) in .idea/codeStyles/Project.xml
84-
85-
If there are no preconfigured rules for your IDE, you can use one of the existing ones to configure your IDE.
86-
87-
- **Indentation** : 2 spaces, no tabulation
88-
- **Opening brace** at the end of the line
89-
- **Naming** : Choose self-describing variable name
90-
- **class** : PascalCase
91-
- **namespace** : PascalCase
92-
- **variable** : camelCase, **no** prefix/suffix ('_', 'm_',...) for class members
93-
- **Include guard** : `#pragma once` (no `#ifdef __MODULE__ / #define __MODULE__ / #endif`)
94-
- **Includes** :
95-
- files from the project : `#include "relative/path/to/the/file.h"`
96-
- external files and std : `#include <file.h>`
97-
- Only use [primary spellings for operators and tokens](https://en.cppreference.com/w/cpp/language/operator_alternative)
98-
- Use auto sparingly. Don't use auto for [fundamental/built-in types](https://en.cppreference.com/w/cpp/language/types) and [fixed width integer types](https://en.cppreference.com/w/cpp/types/integer), except when initializing with a cast to avoid duplicating the type name.
99-
- Examples:
100-
- `auto* app = static_cast<DisplayApp*>(instance);`
101-
- `auto number = static_cast<uint8_t>(variable);`
102-
- `uint8_t returnValue = MyFunction();`
103-
- Use nullptr instead of NULL

0 commit comments

Comments
 (0)