Mercurial > geeqie
annotate CODING @ 1802:956aab097ea7
added 2010 to copyright text
author | nadvornik |
---|---|
date | Tue, 16 Feb 2010 21:18:03 +0000 |
parents | b9a9a457860d |
children |
rev | line source |
---|---|
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
1 GPL header, in every file, like this: |
524 | 2 |
1645 | 3 /** \file |
4 * \short Short description of this file. | |
5 * \author Author1 | |
6 * \author Author2 | |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
7 * |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
8 * Optionaly detailed description of this file |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
9 * on more lines. |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
10 */ |
1645 | 11 |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
12 /* |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
13 * This file is a part of Geeqie project (http://geeqie.sourceforge.net/). |
1802 | 14 * Copyright (C) 2008 - 2010 The Geeqie Team |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
15 * |
1645 | 16 * This program is free software; you can redistribute it and/or modify it |
17 * under the terms of the GNU General Public License as published by the Free | |
18 * Software Foundation; either version 2 of the License, or (at your option) | |
19 * any later version. | |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
20 * |
1645 | 21 * This program is distributed in the hope that it will be useful, but WITHOUT |
22 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
23 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
24 * more details. | |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
25 */ |
524 | 26 |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
27 -------------------------------------------------------------------------------- |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
28 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
29 svn change-log: |
524 | 30 |
1645 | 31 Start with a short summary in the first line (without a dot at the end) followed |
32 by a empty line. Use whole sentences begins with Capital letter. For each | |
33 modification use new line. Or you can write the theme, colon and then every | |
34 change on new line, begin with "- ". | |
35 | |
36 See also: http://www.tpope.net/node/106 | |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
37 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
38 Example: |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
39 |
1645 | 40 I did some bugfixes |
41 | |
42 There was the bug that something was wrong. I fixed it. | |
43 | |
44 Library: | |
45 - the interface was modified | |
46 - new functions were added | |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
47 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
48 -------------------------------------------------------------------------------- |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
49 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
50 sources: |
524 | 51 |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
52 Indentation: tabs |
1645 | 53 Names of variables & functions: small_letters |
54 of defines: CAPITAL_LETTERS | |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
55 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
56 Try to use explicit variable and function names. |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
57 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
58 Try not to use macros. |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
59 Use EITHER "struct foo" OR "foo"; never both |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
60 |
1645 | 61 |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
62 Conditions, cycles: |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
63 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
64 if (<cond>) |
524 | 65 { |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
66 <command>; |
524 | 67 ... |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
68 <command>; |
524 | 69 } |
70 else | |
71 { | |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
72 <command>; |
524 | 73 ... |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
74 <command>; |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
75 } |
1645 | 76 |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
77 if (<cond_very_very_very_very_very_very_very_very_very_long> && |
1645 | 78 <cond2very_very_very_very_very_very_very_very_very_long>) |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
79 <the_only_command>; |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
80 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
81 switch (<var>) |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
82 { |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
83 case 0: |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
84 <command>; |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
85 <command>; |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
86 break; |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
87 case 1: |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
88 <command>; break; |
524 | 89 } |
90 | |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
91 for (i = 0; i <= 10; i++) |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
92 { |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
93 <command>; |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
94 ... |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
95 <command>; |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
96 } |
1645 | 97 |
524 | 98 |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
99 Functions: |
524 | 100 |
809
83d3abd80b64
Minor fixes and add a note about variable declaration.
zas_
parents:
685
diff
changeset
|
101 gint bar(<var_def>, <var_def>, <var_def>) |
611
f31ae0d9e163
Update CODING and HACKING files, and add po/README file for translators.
zas_
parents:
525
diff
changeset
|
102 { |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
103 <command>; |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
104 ... |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
105 <command>; |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
106 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
107 return 0; // i.e. SUCCESS; if error, you must return minus <err_no> |
611
f31ae0d9e163
Update CODING and HACKING files, and add po/README file for translators.
zas_
parents:
525
diff
changeset
|
108 } |
f31ae0d9e163
Update CODING and HACKING files, and add po/README file for translators.
zas_
parents:
525
diff
changeset
|
109 |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
110 void bar2(void) |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
111 { |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
112 <command>; |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
113 ... |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
114 <command>; |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
115 } |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
116 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
117 Pragma: (Indentation 2 spaces) |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
118 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
119 #ifdef ENABLE_NLS |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
120 # undef _ |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
121 # define _(String) (String) |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
122 #endif /* ENABLE_NLS */ |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
123 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
124 Headers: |
524 | 125 |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
126 #ifndef _FILENAME_H |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
127 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
128 -------------------------------------------------------------------------------- |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
129 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
130 Use spaces around every operator (except ".", "->", "++" and "--"); |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
131 unary operator '*' and '&' are missing the space from right; |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
132 (and also unary '-'). |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
133 As you can see above, parentheses are closed to inside, i.e. " (blah blah) " |
1645 | 134 In "function(<var>)" there are no space before '('. |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
135 You MAY use more tabs/spaces than you OUGHT TO (according to this CodingStyle), if |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
136 it makes your code nicer in being verticaly indented. |
809
83d3abd80b64
Minor fixes and add a note about variable declaration.
zas_
parents:
685
diff
changeset
|
137 Variables declarations should be followed by a blank line and should always be |
83d3abd80b64
Minor fixes and add a note about variable declaration.
zas_
parents:
685
diff
changeset
|
138 at the start of the block. |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
139 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
140 -------------------------------------------------------------------------------- |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
141 |
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
142 Use glib types when possible (ie. gint and gchar instead of int and char). |
611
f31ae0d9e163
Update CODING and HACKING files, and add po/README file for translators.
zas_
parents:
525
diff
changeset
|
143 Use glib functions when possible (ie. g_ascii_isspace() instead of isspace()). |
f31ae0d9e163
Update CODING and HACKING files, and add po/README file for translators.
zas_
parents:
525
diff
changeset
|
144 Check if used functions are not deprecated. |
f31ae0d9e163
Update CODING and HACKING files, and add po/README file for translators.
zas_
parents:
525
diff
changeset
|
145 |
685
f20e7cebcb12
Updated CODING (GPL header, macros, svn change-log, ...).
bruclik
parents:
611
diff
changeset
|
146 -------------------------------------------------------------------------------- |
524 | 147 |
1645 | 148 Documentation: |
149 | |
150 To document the code use the following rules to allow extraction with doxygen. | |
151 Do not save with comments. Not all comments have to be doxygen comments. | |
152 | |
153 - Use C comments in plain C files and use C++ comments in C++ files for one line | |
154 comments. | |
155 - Use '/**' (note the two asterisks) to start comments to be extracted by | |
156 doxygen and start every following line with " *". | |
157 - Use '\' to indicate doxygen keywords/commands (see below). | |
158 - Use the '\deprecated' command to tell if the function is subject to be deleted | |
159 or to a complete rewrite. | |
160 | |
161 Example: | |
162 | |
163 To document functions or big structures: | |
164 /** | |
165 * \brief This is a short description of the function. | |
166 * | |
167 * This function does ... | |
168 * | |
169 * \param x1 This is the first parameter named x1 | |
170 * \param y1 This is the second parameter named y1 | |
171 * \return What the function returns | |
172 * You can extend that return description (or anything else) by indenting the | |
173 * following lines until the next empty line or the next keyword/command. | |
174 * \see Cross reference | |
175 */ | |
176 | |
177 To document members of a structure that have to be documented (use it at least | |
178 for big structures) use the '/**<' format: | |
179 int counter; /**< This counter counts images */ | |
180 | |
181 For further documentation about doxygen see | |
182 http://www.stack.nl/~dimitri/doxygen/manual.html. For the possible commands you | |
183 can use see http://www.stack.nl/~dimitri/doxygen/commands.html. | |
184 | |
185 But in case just think about that the documentation is for other developers not | |
186 for the end user. So keep the focus. |