aboutsummaryrefslogtreecommitdiff
path: root/contributing.md
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-06 18:26:32 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-06 18:26:32 +0100
commit8b9297c12e47f433b13a45f9a80b2b0de15a3f21 (patch)
tree4c055a8b054349f3494fbe18f4f81b2e410c4336 /contributing.md
parenta1b8f56238bbc3d5f3eb273fad4a225592e7356f (diff)
parent32bc6d21987e9861d9089228388f9aab5f4f43d1 (diff)
Merge branch 'master' into max/scenes
Diffstat (limited to 'contributing.md')
-rw-r--r--contributing.md128
1 files changed, 124 insertions, 4 deletions
diff --git a/contributing.md b/contributing.md
index 88cba32..cd1b6a6 100644
--- a/contributing.md
+++ b/contributing.md
@@ -49,12 +49,11 @@ that you can click on to open them.
class Cars {};
```
</td></tr></table></details>
-- Source files (.cpp, .hpp) contain the following types of comments:
+- Source files (`.cpp`, `.hpp`) contain the following types of comments:
- What is the code supposed to do (optional)
- Implementation details (if applicable)
-- Header files (.h) contain the following types of comments:
- - Usage documentation (required)
-
+- Header files (`.h`) contain the following types of comments:
+ - [Usage documentation](#documentation) (required)
> [!NOTE]
> Constructors/destructors aren't required to have a `\brief` description
- Implementation details (if they affect the header)
@@ -421,6 +420,127 @@ that you can click on to open them.
void bar(Point p);
```
</td></tr></table></details>
+- <details><summary>
+ Follow the rule of five
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ class Foo {
+ public:
+ Foo();
+ ~Foo();
+ Foo(Foo &&) noexcept;
+ Foo & operator = (const Foo &);
+ Foo & operator = (Foo &&) noexcept;
+ };
+ ```
+ </td><td>
+
+ ```cpp
+ class Foo {
+ public:
+ Foo();
+ ~Foo();
+ };
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Ensure const-correctness
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ class Foo {
+ public:
+ int get_value() const;
+ void set_value(int new_value);
+ const std::string & get_name() const;
+ void set_name(const std::string & new_name);
+ private:
+ int value;
+ std::string name;
+ };
+ ```
+ </td><td>
+
+ ```cpp
+ class Foo {
+ public:
+ int get_value();
+ void set_value(int new_value);
+ std::string get_name();
+ void set_name(std::string new_name);
+ private:
+ int value;
+ std::string name;
+ };
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Files should be named after the class/struct/interface they implement
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ MyClass.h
+ MyClass.cpp
+ MyClass.hpp
+ ```
+ </td><td>
+
+ ```cpp
+ my_class.h
+ myClass.cpp
+ my-class.hpp
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Implementations are not allowed in header files, except if the implementation
+
+ - is `= default`
+ - is `= delete`
+ - is `{}` (empty)
+ - only returns a constant literal
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ class Foo {
+ public:
+ int get_value() const { return 42; }
+ };
+ ```
+ </td><td>
+
+ ```cpp
+ class Foo {
+ public:
+ int calculate_value() const {
+ int result = 0;
+ // complex calculation
+ return result;
+ }
+ };
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Use angle brackets (<code><></code>) only for including system headers and
+ double quotes (<code>""</code>) for including other engine files.
+
+ > [!NOTE]
+ > Only files in the examples folder should include engine headers with angle
+ > brackets
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ #include <iostream>
+
+ #include "facade/Sound.h"
+ ```
+ </td><td>
+
+ ```cpp
+ #include <iostream>
+ #include <crepe/facade/Sound.h>
+ ```
+ </td></tr></table></details>
## CMakeLists-specific