From c9012bf2f2b35ee990839a73e6411233562d9464 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 31 Mar 2011 22:32:37 +0200 Subject: Update docs --- doc/reference/xml/coding-standards.xml | 109 +++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 doc/reference/xml/coding-standards.xml (limited to 'doc/reference/xml') diff --git a/doc/reference/xml/coding-standards.xml b/doc/reference/xml/coding-standards.xml new file mode 100644 index 00000000..e3d549f4 --- /dev/null +++ b/doc/reference/xml/coding-standards.xml @@ -0,0 +1,109 @@ + + +]> + + +CrystFEL coding standards +3 + + Coding standards + + + + + + +Summary + +This page documents the coding conventions used within the CrystFEL source code. Read these to help when reading the code or before making modifications destined to be sent upstream. + + + + + +Licensing and copyright + +CrystFEL is distributed under the terms of the GNU General Public License version 3 or higher. Contributions are very welcome provided they also use this license. + + +Whenever you edit a source file, don't forget to update the copyright dates at the top. Add your name and email address if they're not there already. Be sure to add your name to the 'AUTHORS' file in the top level folder, as well. + + + + + +Formatting + +Indentation is done with tabs and +alignment is done with spaces. This way, the code looks +neat whatever width you configure your editor to display tabs as. + + +However, code must be strictly wrapped at 80 columns, or +what would be 80 columns if the tabs were displayed as 8 spaces. +If you think you need more width, you're at too many levels of indentation and +need to break things down a bit. + + + + + +Brackets and so on + +Brackets and so on should go like this: + + + +/* Multiple line comments have stars + * down one side */ +void somefunction(int someparam) +{ + /* Single line comments use this style (not //) */ + if ( a < b ) { + /* 'if' statements usually have the opening brace on the same + * line as the condition. */ + } else { + /* 'else's are 'cuddled' */ + } + + if ( some && very && long && condition && that && spans + && two && lines ) + { + /* Opening brace is on a line by itself in the case of a very + * long condition */ + } +} + +/* Comments use proper capitalisation to make things look neat */ + + + +'struct' blocks can have the braces like functions or 'if' statements. Usually +the former looks nicer if the struct is large. + + + + + +Cleverness + +Yes, we all know you can insert a new node into an RB-tree while simultaneously +calculating Pi to 150 decimal places in one line of code. You don't need to +prove it here. As a general rule, if you think you're about to do something clever, don't do it at all. + + + + + +Evil dictator + +Despite your following all of the above, I will probably still touch up your +code in some places while (or shortly after) integrating it into mainline +CrystFEL. Please try not to take it personally. + + + + -- cgit v1.2.3