Numerous minor updates and fixes for The Manual:
[openocd.git] / doc / manual / style.txt
1 /** @page styleguide Style Guides
2
3 The goals for each of these guides are:
4 - to produce correct code that appears clean, consistent, and readable,
5 - to allow developers to create patches that conform to a standard, and
6 - to eliminate these issues as points of future contention.
7
8 Some of these rules may be ignored in the spirit of these stated goals;
9 however, such exceptions should be fairly rare.
10
11 The following style guides describe a formatting, naming, and other
12 conventions that should be followed when writing or changing the OpenOCD
13 code:
14
15 - @subpage styletcl
16 - @subpage stylec
17 - @subpage styleperl
18 - @subpage styleautotools
19
20 In addition, the following style guides provide information for
21 providing documentation, either as part of the C code or stand-alone.
22
23 - @subpage styledoxygen
24 - @subpage styletexinfo
25 - @subpage stylelatex
26
27 Feedback would be welcome to improve the OpenOCD guidelines.
28
29 */
30 /** @page styletcl TCL Style Guide
31
32 OpenOCD needs to expand its Jim/TCL Style Guide.
33
34 Many of the guidelines listed on the @ref stylec page should apply to
35 OpenOCD's Jim/TCL code as well.
36
37 */
38 /** @page stylec C Style Guide
39
40 This page contains guidelines for writing new C source code for the
41 OpenOCD project.
42
43 @section styleformat Formatting Guide
44
45 - remove any trailing white space at the end of lines.
46 - use TAB characters for indentation; do NOT use spaces.
47 - displayed TAB width is 4 characters.
48 - use Unix line endings ('\\n'); do NOT use DOS endings ('\\r\\n')
49 - limit adjacent empty lines to at most two (2).
50 - remove any trailing empty lines at the end of source files
51 - do not "comment out" code from the tree; instead, one should either:
52 -# remove it entirely (Subversion can retrieve the old version), or
53 -# use an @c \#if/\#endif block.
54
55 Finally, try to avoid lines of code that are longer than than 72-80 columns:
56
57 - long lines frequently indicate other style problems:
58 - insufficient use of static functions, macros, or temporary variables
59 - poor flow-control structure; "inverted" logical tests
60 - a few lines may be wider than this limit (typically format strings), but:
61 - all C compilers will concatenate series of string constants.
62 - all long string constants should be split across multiple lines.
63
64 @section stylenames Naming Rules
65
66 - most identifiers must use lower-case letters (and digits) only.
67 - macros must use upper-case letters (and digits) only.
68 - OpenOCD identifiers should NEVER use @c MixedCaps.
69 - structure names must end with the '_s' suffix.
70 - typedef names must end with the '_t' suffix.
71 - use underline characters between consecutive words in identifiers
72 (e.g. @c more_than_one_word).
73
74 @section stylec99 C99 Rules
75
76 - inline functions
77 - @c // comments -- in new code, prefer these for single-line comments
78 - trailing comma allowed in enum declarations
79 - designated initializers (@{ .field = value @})
80 - variables declarations may be mixed with code
81 - new block scopes for selection and iteration statements
82
83 @section stylefunc Functions
84
85 - static inline functions should be prefered over macros:
86 @code
87 /** do NOT define macro-like functions like this... */
88 #define CUBE(x) ((x) * (x) * (x))
89 /** instead, define the same expression using a C99 inline function */
90 static inline int cube(int x) { return x * x * x; }
91 @endcode
92 - Functions should be declared static unless required by other modules
93 - define static functions before first usage to avoid forward declarations.
94 - Functions should have no space between its name and its parameter list:
95 @code
96 int f(int x1, int x2)
97 {
98 ...
99 int y = f(x1, x2 - x1);
100 ...
101 }
102 @endcode
103
104 */
105 /** @page styledoxygen Doxygen Style Guide
106
107 The following sections provide guidelines for OpenOCD developers
108 who wish to write Doxygen comments in the code or this manual.
109 For an introduction to Doxygen documentation,
110 see the @ref primerdoxygen.
111
112 @section styledoxyblocks Doxygen Block Selection
113
114 Several different types of Doxygen comments can be used; often,
115 one style will be the most appropriate for a specific context.
116 The following guidelines provide developers with heuristics for
117 selecting an appropriate form and writing consistent documentation
118 comments.
119
120 -# use @c /// to for one-line documentation of instances.
121 -# for documentation requiring multiple lines, use a "block" style:
122 @verbatim
123 /**
124 * @brief First sentence is short description. Remaining text becomes
125 * the full description block, where "empty" lines start new paragraphs.
126 *
127 * One can make text appear in @a italics, @b bold, @c monospace, or
128 * in blocks such as the one in which this example appears in the Style
129 * Guide. See the Doxygen Manual for the full list of commands.
130 *
131 * @param foo For a function, describe the parameters (e.g. @a foo).
132 * @returns The value(s) returned, or possible error conditions.
133 */
134 @endverbatim
135 -# The block should start on the line following the opening @c /**.
136 -# The end of the block, \f$*/\f$, should also be on its own line.
137 -# Every line in the block should have a @c '*' in-line with its start:
138 - A leading space is required to align the @c '*' with the @c /** line.
139 - A single "empty" line should separate the function documentation
140 from the block of parameter and return value descriptions.
141 - Except to separate paragraphs of documentation, other extra
142 "empty" lines should be removed from the block.
143 -# Only single spaces should be used; do @b not add mid-line indentation.
144 -# If the total line length will be less than 72-80 columns, then
145 - The @c /**< form can be used on the same line.
146 - This style should be used sparingly; the best use is for fields:
147 @code int field; /**< field description */ @endcode
148
149 @section styledoxyall Doxygen Style Guide
150
151 The following guidelines apply to all Doxygen comment blocks:
152
153 -# Use the @c '\@cmd' form for all doxygen commands (do @b not use @c '\\cmd').
154 -# Use symbol names such that Doxygen automatically creates links:
155 -# @c function_name() can be used to reference functions
156 (e.g. flash_set_dirty()).
157 -# @c struct_name::member_name should be used to reference structure
158 fields in the documentation (e.g. @c flash_driver_s::name).
159 -# URLS get converted to markup automatically, without any extra effort.
160 -# new pages can be linked into the heirarchy by using the @c \@subpage
161 command somewhere the page(s) under which they should be linked:
162 -# use @c \@ref in other contexts to create links to pages and sections.
163 -# Use good Doxygen mark-up:
164 -# '\@a' (italics) should be used to reference parameters (e.g. <i>foo</i>).
165 -# '\@b' (bold) should be used to emphasizing <b>single</b> words.
166 -# '\@c' (monospace) should be used with <code>file names</code> and
167 <code>code symbols</code>, so they appear visually distinct from
168 surrounding text.
169 -# To mark-up multiple words, the HTML alternatives must be used.
170 -# Two spaces should be used when nesting lists; do @b not use '\\t' in lists.
171 -# Code examples provided in documentation must conform to the Style Guide.
172
173 @section styledoxytext Doxygen Text Inputs
174
175 In addition to the guidelines in the preceding sections, the following
176 additional style guidelines should be considered when writing
177 documentation as part of standalone text files:
178
179 -# Text files must contain Doxygen at least one comment block:
180 -# Documentation should begin in the first column (except for nested lists).
181 -# Do NOT use the @c '*' convention that must be used in the source code.
182 -# Each file should contain at least one @c \@page block.
183 -# Each new page should be listed as a \@subpage in the \@page block
184 of the page that should serve as its parent.
185 -# Large pages should be structure in parts using meaningful \@section
186 and \@subsection commands.
187 -# Include a @c \@file block at the end of each Doxygen @c .txt file to
188 document its contents:
189 - Doxygen creates such pages for files automatically, but no content
190 will appear on them for those that only contain manual pages.
191 - The \@file block should provide useful meta-documentation to assist
192 techincal writers; typically, a list of the pages that it contains.
193 - For example, the @ref styleguide exists in @c doc/manual/style.txt,
194 which contains a reference back to itself.
195 -# The \@file and \@page commands should begin on the same line as
196 the start of the Doxygen comment:
197 @verbatim
198 /** @page pagename Page Title
199
200 Documentation for the page.
201
202 */
203 /** @file
204
205 This file contains the @ref pagename page.
206
207 */
208 @endverbatim
209
210 For an example, the Doxygen source for this Style Guide can be found in
211 @c doc/manual/style.txt, alongside other parts of The Manual.
212
213 */
214 /** @page styletexinfo Texinfo Style Guide
215
216 This page needs to provide style guidelines for Texinfo, the mark-up
217 language used by The Guide for OpenOCD Users.
218
219 */
220 /** @page stylelatex LaTeX Style Guide
221
222 This page needs to provide style guidelines for using LaTeX, the
223 typesetting language used by The References for OpenOCD Hardware.
224 Likewise, the @ref primerlatex for using this guide needs to be completed.
225
226 */
227 /** @page styleperl Perl Style Guide
228
229 This page provides some style guidelines for using Perl, a scripting
230 language used by several small tools in the tree:
231
232 -# Ensure all Perl scripts use the proper suffix (@c .pl for scripts, and
233 @c .pm for modules)
234 -# Pass files as script parameters or piped as input:
235 - Do NOT code paths to files in the tree, as this breaks out-of-tree builds.
236 - If you must, then you must also use an automake rule to create the script.
237 -# use @c '#!/usr/bin/perl' as the first line of Perl scripts.
238 -# always <code>use strict</code> and <code>use warnings</code>
239 -# invoke scripts indirectly in Makefiles or other scripts:
240 @code
241 perl script.pl
242 @endcode
243
244 Maintainers must also be sure to follow additional guidelines:
245 -# Ensure that Perl scripts are committed as executables:
246 - Use "<code>chmod +x script.pl</code>"
247 @a before using "<code>svn add script.pl</code>", or
248 - Use "<code>svn ps svn:executable '*' script.pl</code>"
249 @a after using "<code>svn add script.pl</code>".
250
251 */
252 /** @page styleautotools Autotools Style Guide
253
254 This page contains style guidelines for the OpenOCD autotools scripts.
255
256 The following guidelines apply to the @c configure.in file:
257 - Better guidelines need to be developed, but until then...
258 - Use good judgement.
259
260 The following guidelines apply to @c Makefile.am files:
261 -# When assigning variables with long lists of items:
262 -# Separate the values on each line to make the files "patch friendly":
263 @code
264 VAR = \
265 value1 \
266 value2 \
267 ...
268 value9 \
269 value10
270 @endcode
271 */
272 /** @file
273
274 This file contains the @ref styleguide pages. The @ref styleguide pages
275 include the following Style Guides for their respective code and
276 documentation languages:
277
278 - @ref styletcl
279 - @ref stylec
280 - @ref styledoxygen
281 - @ref styletexinfo
282 - @ref stylelatex
283 - @ref styleperl
284 - @ref styleautotools
285
286 */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)