summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jeremie Guichard <djebrest@gmail.com>2018-04-10 09:08:46 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-04-10 08:18:32 -0700
commit65c91e833ce1e851699b161beeceebc48527e4a4 (patch)
tree2188b5d526c9e20ba4e10e195c15f02d3c4ce89b
parent5d96d4af0cc6702c5473383b7a7ad0be875b375b (diff)
downloadsubsurface-65c91e833ce1e851699b161beeceebc48527e4a4.tar.gz
Add Coding conventions section in CodingStyle file
Add section about string manipulation Moved some of the existing conventions into the new section: - variable declarations - text strings - UI text style Update CONTRIBUTING.md with references to CodingStyle file Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
-rw-r--r--CONTRIBUTING.md4
-rw-r--r--CodingStyle24
2 files changed, 25 insertions, 3 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 68ea8ca12..a923918b5 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -75,6 +75,8 @@ Here is a (non exhaustive) list of Areas that can be used:
* Printing
* Profile
+In order to make reviews simpler and have contributions merged faster in the code base, please follow Subsurface project's coding style and coding conventions described in the [CodingStyle][11] file.
+
[1]: http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
[2]: http://freenode.net/
[3]: https://www.transifex.com/
@@ -85,3 +87,5 @@ Here is a (non exhaustive) list of Areas that can be used:
[8]: https://subsurface-divelog.org/building/
[9]: https://gerrit-review.googlesource.com/Documentation/user-signedoffby.html
[10]: https://subsurface-divelog.org/wp-content/uploads/2011/10/Screenshot-gitk-subsurface-1.png "Example with gitk"
+[11]: https://github.com/Subsurface-divelog/subsurface/blob/master/CodingStyle
+[12]: https://github.com/Subsurface-divelog/subsurface/blob/master/CONVENTIONS.md
diff --git a/CodingStyle b/CodingStyle
index 52fab7344..1a14fcacc 100644
--- a/CodingStyle
+++ b/CodingStyle
@@ -1,9 +1,9 @@
Coding Style
============
-Here are some of the basics that we are trying to enforce for our coding
-style. The existing code (as of the commit that adds these lines) is not
-yet fully consistent to these rules, but following these rules will make
+Here are some of the basics that we are trying to enforce for our coding style
+and conventions. The existing code (as of the commit that adds these lines) is
+not yet fully consistent to these rules, but following these rules will make
sure that no one yells at you about your patches.
We have a script that can be used to reformat code to be reasonably close
@@ -106,6 +106,9 @@ Basic rules
}
}
+Coding conventions
+==================
+
- variable declarations
in C code we really like them to be at the beginning of a code block,
not interspersed in the middle.
@@ -143,6 +146,21 @@ Basic rules
in use within Subsurface e.g. Cylinder vs. Tank.
+- string manipulation
+
+ -- user interface
+ In UI part of the code use of QString methods is preferred, see this pretty
+ good guide in QString documentation:
+ http://doc.qt.io/qt-5/qstring.html#manipulating-string-data
+
+ -- core components
+ In the core part of the code, C-string should be used.
+ C-string manipulation is not always straightforward specifically when
+ it comes to memory allocation, a set of helper functions has been developed
+ to help with this. Documentation and usage examples can be found in
+ core/membuffer.h file:
+ https://github.com/Subsurface-divelog/subsurface/blob/master/core/membuffer.h
+
Sample Settings
===============