comparison doc/interpreter/contrib.txi @ 18529:3e731fc1e4d5 stable

contrib.txi: Improve the documentation for Contribution Guidelines. * contrib.txi: Improve the documentation for Contribution Guidelines.
author Rik <rik@octave.org>
date Thu, 27 Feb 2014 22:31:11 -0800
parents 42c3e30557a4
children 186ea1c2bbd4
comparison
equal deleted inserted replaced
18527:ae1b1ba1b693 18529:3e731fc1e4d5
34 * Other Sources:: 34 * Other Sources::
35 @end menu 35 @end menu
36 36
37 @node How to Contribute 37 @node How to Contribute
38 @section How to Contribute 38 @section How to Contribute
39 The mailing list for Octave development discussion is 39 The mailing list for Octave development discussions is
40 @email{maintainers@@octave.org}. Patches should be submitted to 40 @email{maintainers@@octave.org}. Patches should be submitted to
41 @url{https://savannah.gnu.org/patch/?func=additem&group=octave, Octave's patch tracker}. 41 @url{https://savannah.gnu.org/patch/?func=additem&group=octave, Octave's patch tracker}.
42 This concerns the development of Octave core, i.e., code that goes to Octave 42 This concerns the development of Octave core, i.e., code that goes in to Octave
43 directly. You may consider developing and publishing a package instead; 43 directly. You may consider developing and publishing a package instead;
44 a great place for this is the allied Octave-Forge project 44 a great place for this is the allied Octave-Forge project
45 (@url{http://octave.sourceforge.net}). Note that the Octave core 45 (@url{http://octave.sourceforge.net}). Note that the Octave core
46 project is inherently more conservative and follows narrower rules. 46 project is inherently more conservative and follows narrower rules.
47 47
48 @node Building the Development Sources 48 @node Building the Development Sources
49 @section Building the Development Sources 49 @section Building the Development Sources
50 50
51 The directions for building from the Development sources change from 51 The directions for building from the development sources change from
52 time to time, so you should read the resources for developers on the web 52 time to time, so you should read the resources for developers on the web
53 or in the development sources archive. Start here: 53 or in the development sources archive. Start here:
54 @url{http://www.octave.org/get-involved.html}. 54 @url{http://www.octave.org/get-involved.html}.
55 55
56 @node Basics of Generating a Changeset 56 @node Basics of Generating a Changeset
57 @section Basics of Generating a Changeset 57 @section Basics of Generating a Changeset
58 58
59 The preferable form of contribution is creating a Mercurial changeset 59 The best way to contribute is to create a Mercurial changeset and submit it to
60 and submit it to the @url{http://savannah.gnu.org/bugs/?group=octave, bug} or 60 the @url{http://savannah.gnu.org/bugs/?group=octave, bug} or
61 @url{http://savannah.gnu.org/patch/?func=additem&group=octave, patch} 61 @url{http://savannah.gnu.org/patch/?func=additem&group=octave, patch}
62 trackers@footnote{Please use the patch tracker only for patches which add new 62 trackers@footnote{Please use the patch tracker only for patches which add new
63 features. If you have a patch to submit that fixes a bug, you should use the 63 features. If you have a patch to submit that fixes a bug, you should use the
64 bug tracker instead.}. 64 bug tracker instead.}.
65 Mercurial is the source code management system currently used to develop 65 Mercurial is the source code management system currently used to develop
66 Octave. Other forms of contributions (e.g., simple diff patches) are 66 Octave. Other forms of contributions (e.g., simple diff patches) are
67 also acceptable, but they slow down the review process. If you want to 67 also acceptable, but they slow down the review process. If you want to
68 make more contributions, you should really get familiar with Mercurial. 68 make more contributions, you should really get familiar with Mercurial.
69 A good place to start is 69 A good place to start is
70 @url{http://www.selenic.com/mercurial/wiki/index.cgi/Tutorial}. There 70 @url{http://www.selenic.com/mercurial/wiki/index.cgi/Tutorial}. There
71 you will also find help how to install Mercurial. 71 you will also find help about how to install Mercurial.
72 72
73 A simple contribution sequence could look like this: 73 A simple contribution sequence could look like this:
74 74
75 @example 75 @example
76 @group 76 @group
88 # attach ../cool.diff to your bug report 88 # attach ../cool.diff to your bug report
89 @end group 89 @end group
90 @end example 90 @end example
91 91
92 You may want to get familiar with Mercurial queues to manage your 92 You may want to get familiar with Mercurial queues to manage your
93 changesets. For working with queues you have to activate the extension 93 changesets. To work with queues you must activate the extension
94 @nospell{mq} with the following entry in Mercurial's configuration file 94 @nospell{mq} with the following entry in Mercurial's configuration file
95 @file{.hgrc} (or @file{Mercurial.ini} on Windows): 95 @file{.hgrc} (or @file{Mercurial.ini} on Windows):
96 96
97 @example 97 @example
98 @group 98 @group
165 @end group 165 @end group
166 @end example 166 @end example
167 167
168 Sometimes a few further improvements for the pager extension are 168 Sometimes a few further improvements for the pager extension are
169 necessary. The following options should not be enabled unless paging 169 necessary. The following options should not be enabled unless paging
170 isn't working correctly: 170 is not working correctly.
171 171
172 @example 172 @example
173 @group 173 @group
174 [pager] 174 [pager]
175 # Some options for the less pager, see less(1) for their meaning. 175 # Some options for the less pager, see less(1) for their meaning.
183 @end example 183 @end example
184 184
185 Enabling the described extensions should immediately lead to a difference 185 Enabling the described extensions should immediately lead to a difference
186 when using the command line version of @nospell{hg}. Of these options, the 186 when using the command line version of @nospell{hg}. Of these options, the
187 only one that enables a new command is @nospell{graphlog}. It is recommanded 187 only one that enables a new command is @nospell{graphlog}. It is recommanded
188 that you use the command @code{hg glog} instead of @code{hg log} for a better 188 that to use the command @code{hg glog}, instead of @code{hg log}, for a better
189 feel what commits are being based on. 189 feel about what commits are being based on.
190 190
191 @node General Guidelines 191 @node General Guidelines
192 @section General Guidelines 192 @section General Guidelines
193 193
194 All Octave's sources are distributed under the General Public License 194 All Octave's sources are distributed under the GNU General Public License
195 (GPL). Currently, Octave uses GPL version 3. For details about this 195 (GPL). Currently, Octave uses GPL version 3. For details about this
196 license, see @url{http://www.gnu.org/licenses/gpl.html}. Therefore, 196 license, see @url{http://www.gnu.org/licenses/gpl.html}. Therefore,
197 whenever you create a new source file, it should have the following 197 whenever you create a new source file, it should have the following
198 comment header (use appropriate year, name and comment marks): 198 comment header (use appropriate year, name and comment marks):
199 199
200 @example 200 @example
201 ## Copyright (C) 1996-2013 John W. Eaton <jwe@@octave.org> 201 ## Copyright (C) 1996-2013 John W. Eaton <jwe@@octave.org>
202 ## 202 ##
203 ## This file is part of Octave. 203 ## This file is part of Octave.
204 ## 204 ##
205 ## Octave is free software; you can redistribute it and/or 205 ## Octave is free software; you can redistribute it and/or modify it
206 ## modify it under the terms of the GNU General Public 206 ## under the terms of the GNU General Public License as published by
207 ## License as published by the Free Software Foundation; 207 ## the Free Software Foundation; either version 3 of the License, or
208 ## either version 3 of the License, or (at your option) any 208 ## (at your option) any later version.
209 ## later version.
210 ## 209 ##
211 ## Octave is distributed in the hope that it will be useful, 210 ## Octave is distributed in the hope that it will be useful, but
212 ## but WITHOUT ANY WARRANTY; without even the implied 211 ## WITHOUT ANY WARRANTY; without even the implied warranty of
213 ## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 212 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
214 ## PURPOSE. See the GNU General Public License for more 213 ## GNU General Public License for more details.
215 ## details.
216 ## 214 ##
217 ## You should have received a copy of the GNU General Public 215 ## You should have received a copy of the GNU General Public License
218 ## License along with Octave; see the file COPYING. If not, 216 ## along with Octave; see the file COPYING. If not,
219 ## see <http://www.gnu.org/licenses/>. 217 ## see <http://www.gnu.org/licenses/>.
220 @end example 218 @end example
221 219
222 Always include commit messages in changesets. After making your source 220 Always include commit messages in changesets. After making your source
223 changes, record and briefly describe the changes in your commit message. 221 changes, record and briefly describe the changes in your commit message.
224 You should have previously configured your @file{.hgrc} (or 222 You should have previously configured your @file{.hgrc} (or
225 @file{Mercurial.ini} on Windows) with your name and email, which will 223 @file{Mercurial.ini} on Windows) with your name and email, which will
226 get automatically added to your commit message. Your commit message 224 be automatically added to your commit message. Your commit message
227 should have a brief one-line explanation of what the commit does. If you 225 should have a brief one-line explanation of what the commit does. If you
228 are patching a bug, this one-line explanation should mention the bug 226 are patching a bug, this one-line explanation should mention the bug
229 number at the end. If your change is small and only touches one file, 227 number at the end. If your change is small and only touches one file then
230 this is typically sufficient. If you are modifying several files or 228 this is typically sufficient. If you are modifying several files, or
231 several parts of one file, you should enumerate your changes roughly 229 several parts of one file, you should enumerate your changes roughly
232 following the GNU coding standards on changelogs, like the following 230 following the GNU coding standards for changelogs, as in the following
233 example: 231 example:
234 232
235 @example 233 @example
236 @group 234 @group
237 look for methods before constructors 235 look for methods before constructors
246 (FCN_FILES): Include test_ctor_vs_method.m in the list. 244 (FCN_FILES): Include test_ctor_vs_method.m in the list.
247 @end group 245 @end group
248 @end example 246 @end example
249 247
250 @noindent 248 @noindent
251 In this example, the names of files is mentioned, and in parentheses the 249 In this example, the names of the file changed is listed first, and in
252 name of the function in that file that was modified. There is no need to 250 parentheses the name of the function in that file that was modified. There
253 mention the function for m-files that only contain one function. The 251 is no need to mention the function for m-files that only contain one function.
254 commit message should describe what is changed, not why. Any explanation 252 The commit message should describe what was changed, not why it was changed.
255 of why a change is needed should appear as comments in the code, 253 Any explanation for why a change is needed should appear as comments in the
256 particularly if there is something that might not be obvious to someone 254 code, particularly if there is something that might not be obvious to someone
257 reading it later. 255 reading it later.
258 256
259 When submitting code which addresses a known bug on the Octave bug 257 When submitting code which addresses a known bug on the Octave bug
260 tracker (@url{http://bugs.octave.org}), please add '(bug #XXXXX)' to the 258 tracker (@url{http://bugs.octave.org}), please add '(bug #XXXXX)' to the
261 first line of the commit messages. For example: 259 first line of the commit messages. For example:
265 Fix bug for complex input for gradient (bug #34292). 263 Fix bug for complex input for gradient (bug #34292).
266 @end group 264 @end group
267 @end example 265 @end example
268 266
269 The preferred comment mark for places that may need further attention is 267 The preferred comment mark for places that may need further attention is
270 FIXME. 268 @code{FIXME:}.
271 269
272 @node Octave Sources (m-files) 270 @node Octave Sources (m-files)
273 @section Octave Sources (m-files) 271 @section Octave Sources (m-files)
274 272
275 Don't use tabs. Tabs cause trouble. If you are used to them, set up 273 Don't use tabs. Tabs cause trouble. If you are used to them, set up
276 your editor so that it converts tabs to spaces. Indent the bodies of 274 your editor so that it converts tabs to spaces. Indent the bodies of
277 the statement blocks. Recommended indent is 2 spaces. When calling 275 statement blocks. The recommended indent is 2 spaces. When calling
278 functions, put spaces after commas and before the calling parentheses, 276 functions, put spaces after commas and before the calling parentheses,
279 like this: 277 like this:
280 278
281 @example 279 @example
282 x = max (sin (y+3), 2); 280 x = max (sin (y+3), 2);
283 @end example 281 @end example
284 282
285 @noindent 283 @noindent
286 An exception are matrix and vector constructors: 284 An exception are matrix or cell constructors:
287 285
288 @example 286 @example
289 [sin(x), cos(x)] 287 [sin(x), cos(x)]
288 {sin(x), cos(x)}
290 @end example 289 @end example
291 290
292 @noindent 291 @noindent
293 Here, putting spaces after @code{sin}, @code{cos} would result in a 292 Here, putting spaces after @code{sin}, @code{cos} would result in a
294 parse error. In indexing expression, do not put a space after the 293 parse error. For an indexing expression, do not put a space after the
295 identifier (this differentiates indexing and function calls nicely). 294 identifier (this differentiates indexing and function calls nicely).
296 The space after comma is not necessary if index expressions are simple, 295 The space after a comma is not necessary if index expressions are simple,
297 i.e., you may write 296 i.e., you may write
298 297
299 @example 298 @example
300 A(:,i,j) 299 A(:,i,j)
301 @end example 300 @end example
311 names consisting of 1-2 letters. Do not use mixed case names. Function 310 names consisting of 1-2 letters. Do not use mixed case names. Function
312 names must be lowercase. Function names are global, so choose them 311 names must be lowercase. Function names are global, so choose them
313 wisely. 312 wisely.
314 313
315 Always use a specific end-of-block statement (like @code{endif}, 314 Always use a specific end-of-block statement (like @code{endif},
316 @code{endswitch}) rather than generic @code{end}. 315 @code{endswitch}) rather than the generic @code{end}.
317 316
318 Enclose the @code{if}, @code{while}, @code{until} and @code{switch} 317 Enclose the @code{if}, @code{while}, @code{until}, and @code{switch}
319 conditions in parentheses, like in C: 318 conditions in parentheses, as in C:
320 319
321 @example 320 @example
322 @group 321 @group
323 if (isvector (a)) 322 if (isvector (a))
324 s = sum (a); 323 s = sum (a);
357 The function name should start in column 1, and multi-line argument 356 The function name should start in column 1, and multi-line argument
358 lists should be aligned on the first char after the open parenthesis. 357 lists should be aligned on the first char after the open parenthesis.
359 You should put a space before the left open parenthesis and after commas, 358 You should put a space before the left open parenthesis and after commas,
360 for both function definitions and function calls. 359 for both function definitions and function calls.
361 360
362 Recommended indent is 2 spaces. When indenting, indent the statement 361 The recommended indent is 2 spaces. When indenting, indent the statement
363 after control structures (like @code{if}, @code{while}, etc.). If there 362 after control structures (like @code{if}, @code{while}, etc.). If there
364 is a compound statement, indent @emph{both} the curly braces and the 363 is a compound statement, indent @emph{both} the curly braces and the
365 body of the statement (so that the body gets indented by @emph{two} 364 body of the statement (so that the body gets indented by @emph{two}
366 indents). Example: 365 indents). Example:
367 366
393 : (nargin == 2) ? SVD::economy : SVD::std); 392 : (nargin == 2) ? SVD::economy : SVD::std);
394 @end group 393 @end group
395 @end example 394 @end example
396 395
397 @noindent 396 @noindent
398 Consider putting extra braces around a multiline expression to make it 397 Consider putting extra braces around a multi-line expression to make it
399 more readable, even if they are not necessary. Also, do not hesitate to 398 more readable, even if they are not necessary. Also, do not hesitate to
400 put extra braces anywhere if it improves clarity. 399 put extra braces anywhere if it improves clarity.
401 400
402 Declare variables just before they're needed. Use local variables of 401 Declare variables just before they are needed. Use local variables of
403 blocks---it helps optimization. Don't write multi-line variable 402 blocks---it helps optimization. Don't write a multi-line variable
404 declaration with a single type specification and multiple variables. If 403 declaration with a single type specification and multiple variables. If
405 the variables don't fit on single line, repeat the type specification. 404 the variables don't fit on single line, repeat the type specification.
406 Example: 405 Example:
407 406
408 @example 407 @example