File: README.adoc

package info (click to toggle)
ltt-control 2.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,860 kB
  • sloc: cpp: 192,012; sh: 28,777; ansic: 10,960; python: 7,108; makefile: 3,520; java: 109; xml: 46
file content (390 lines) | stat: -rw-r--r-- 11,577 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
// Render with Asciidoctor

= LTTng-tools C API documentation guidelines
Philippe Proulx <pproulx@efficios.com>
25 August 2021
:toc: left

This document explains how to write documentation for the LTTng-tools
C{nbsp}API.

== General rules

* Use four spaces to indent Doxygen text and two spaces to indent HTML.

* Try to stay behind the 72^th^ column mark when possible.

* Use https://en.wikipedia.org/wiki/Non-breaking_space[`+&nbsp;+`]
  wherever needed.

* Refer to a function with the `func()` form and to an
  enumerator/structure/variable or type with the `#name` syntax.
+
You don't need any `struct`/`enum` prefix with Doxygen.

* When you refer to any keyword or definition, use the `+\c+` command if
  it's a single word, otherwise surround the words with `<code>` and
  `</code>`:
+
--
----
@returns
    Event rule on success, or \c NULL on error.
----
--

* Use the `$$\$$__command__` style in text (paragraphs, list items,
  definition terms, and the rest) and the `@__command__` style for
  other locations (for example, `@brief`, `@param`, `@sa`, `@file`).

* Use a `@code{.unparsed}` block for a plain text block (shell input,
  for example):
+
----
@code{.unparsed}
$ lttng enable-event --all --kernel --syscall
@endcode
----

* In the text, use custom aliases when applicable.
+
See `Doxyfile.in` for the list of available aliases.

== Function documentation

Full example:

----
/*!
@brief
    Does something (third person singular, simple present) with some
    parameter \lt_p{param} unless some other parameter
    \lt_p{other_param} has some value.

Full documentation goes here and adds any relevant information that's
not in the brief description.

@code
/* If needed, put any C code in a code block. */
@endcode

Crucifix scenester vegan organic neutra palo santo glossier occupy
truffaut. Meh fixie taiyaki single-origin coffee wayfarers. Thundercats
farm-to-table shoreditch vinyl.

@remarks
    This is where you would put some remarks. Occupy flexitarian neutra,
    edison bulb bespoke sriracha post-ironic. Mlkshk plaid pop-up
    polaroid chillwave, ennui neutra.

See this image:

@image html mein-illustration.png "Caption goes here."

@note
    @parblock
    This is a multiparagraph note.

    Tote bag sartorial distillery, try-hard succulents wayfarers DIY
    YOLO four loko jianbing farm-to-table unicorn vice.

    Mumblecore semiotics raw denim palo santo chartreuse helvetica
    shabby chic, distillery pabst poke swag copper mug blue bottle.
    @endpar

@attention
    Use an attention command if this message is really important.

@attention
    @parblock
    An attention block with more than one paragraph:

    @code
    some_code(23)
    @endcode

    Elit dolore pariatur ex anim officia cupidatat adipisicing mollit
    incididunt irure anim nostrud.
    @endparblock

@param[in] param
    Description of this parameter.
@param[in] other_param
    @parblock
    Description of this other parameter. Nulla consequat tempus libero,
    sed finibus velit.

    Offal actually vinyl taiyaki kickstarter etsy.
    @endparblock
@param[out] out_param
    <strong>On success</strong>, \lt_p{*out_param} contains to something
    useful.

@retval #LTTNG_SOME_STATUS_OK
    Success.
@retval #LTTNG_SOME_STATUS_MEMORY_ERROR
    Out of memory.
@retval #LTTNG_SOME_STATUS_ERROR
    @parblock
    Longer description for this specific status.

    Organic locavore sartorial 3 wolf moon brooklyn, VHS pug distillery
    schlitz tofu banjo chambray you probably haven't heard of them hot
    chicken copper mug.

    Neutra kale chips kombucha, salvia green juice live-edge swag
    biodiesel scenester austin yuccie dreamcatcher cronut small batch.
    @endparblock

@lt_pre_not_null{param}
@lt_pre_not_null{other_param}
@pre
    \lt_p{param} is like this or like that.

@post
    \lt_p{other_param} is still in some state, and woke jean waistcoat.

@sa lttng_some_other_function() --
    Does something else with some parameter.
@sa lttng_another_function() --
    Cardigan celiac palo santo, tacos chicharrones pitchfork chambray
    photo booth subway tile 90's street.
*/
----

Parts:

. **Opening Doxygen comment**.
+
Use `+/*!+`.

. **Brief description**.
+
Use third person singular in the simple present tense: you're
documenting what the function does. Assume that the sentence implicitly
starts with "`This function`".
+
Try to mention, briefly, all the parameters (with `\lt_p`) and what the
function returns.
+
End the sentence with a period.

. **Detailed description**.
+
Write complete sentences.
+
Refer to parameters (with `\lt_p`) as much as possible.
+
In general, keep paragraphs short: often, a single sentence is enough.
+
Refer to the documented function with "`this function`".
+
Write notes (`@note` command), remarks (`@remark` command), or
attentions (`@attention` command) when needed. Most notes and remarks,
however, can be simple paragraphs. Use `@parblock` end `@endparblock` to
have more than one note/remark/warning paragraph.

. **Parameter descriptions** (if any).
+
Use the `@param[in]`, `@param[out]`, and `@param[in,out]` commands
depending on the parameter direction.
+
Document parameters in the declaration order.
+
Refer to other parameters (with `\lt_p`) when useful for the reader.
+
End each description with a period.
+
Use `@parblock` end `@endparblock` to have more than one paragraph for a
given parameter description.
+
Make sure there's no blank line, except within a `@parblock` block,
within the parameter description block so that Doxygen puts all the
descriptions in the same section. For example, _don't_ write this:
+
----
@param[in] hexagon
    Ugh literally +1 aesthetic, fashion axe try-hard mixtape pork belly
    four loko.

@param[in] selfies
    Brooklyn ethical migas, viral edison bulb meggings butcher
    flexitarian letterpress humblebrag kombucha pour-over etsy sriracha
    blog.
----

. **Return value** (if any).
+
If the function returns a status code::
    Use the `@retval` command multiple times to document each relevant
    status:
+
----
@retval #LTTNG_SOME_STATUS_OK
    Success.
@retval #LTTNG_SOME_STATUS_SOME_ERROR
    Some error.
----
+
End each description with a period.
+
Use `@parblock` and `@endparblock` to have more than one paragraph for a
given return value description.
+
Make sure there's no blank line, except within a `@parblock` block,
within the return value description block so that Doxygen puts all the
descriptions in the same section. For example, _don't_ write this:
+
----
@retval #LTTNG_SOME_STATUS_OK
    Success.

@retval #LTTNG_SOME_STATUS_SOME_ERROR
    Some error.
----

If the function returns a simple value::
    Use the `@returns` command to document it.
+
Refer to parameters (with `\lt_p`) when useful for the reader.
+
End the description with a period.

. **Preconditions** (if any).
+
List all the function's preconditions with the `@pre` command or any
alias which starts with `@lt_pre` (see `Doxyfile.in`).
+
Use the simple present tense.
+
Do not write the word "`must`" as a precondition is already a
requirement.
+
End the description with a period.
+
Make sure there's no blank line within the precondition description
block so that Doxygen puts all the descriptions in the same section. For
example, _don't_ write this:
+
----
@lt_pre_not_null{param}

@pre
    \lt_p{param} is like this or like that.
----

. **Postconditions** (if any).
+
List all the function's _relevant_ postconditions with the `@post`
command or any alias which starts with `@lt_post` (see `Doxyfile.in`).
+
Anything that the body of the function documentation describes and which
forms the nature of the function doesn't need to be written as an
explicit postcondition. For example, if a function adds some
object{nbsp}A to some object{nbsp}B, don't write the postcondition
"`B{nbsp}contains{nbsp}A`".
+
Use the simple present tense.
+
End the description with a period.
+
Make sure there's no blank line within the postcondition description
block so that Doxygen puts all the descriptions in the same section. For
example, _don't_ write this:
+
----
@post
    The returned pointer is blue.

@post
    \lt_p{other_param} is still in some state, and woke jean waistcoat.
----

. **Items to see also** (if any).
+
Use the `@sa` command, multiple times if needed, to refer to related
functions or types.
+
This is a way for you to inform the reader about other existing, related
items. Keep in mind that the reader doesn't always know where to look
for things.
+
In the brief description of the referred item, _don't_ mention its
parameters, if any.
+
End each brief description with a period.
+
Make sure there's no blank line within the item description block so
that Doxygen puts all the descriptions in the same section. For example,
_don't_ write this:
+
----
@sa lttng_some_other_function() --
    Does something else with a parameter.

@sa lttng_another_function() --
    Cardigan celiac palo santo, tacos chicharrones pitchfork chambray
    photo booth subway tile 90's street.
----


== Writing style

The ultimate goal of the LTTng-tools C{nbsp}API documentation is to make
the layman write code using this API as fast and correct as possible
without having to ask for help. For this purpose, the documentation must
be as clear as possible, just like the function and type names try to
be.

Don't hesitate to repeat technical terms, even in the same sentence, if
needed. For example, if you document an "`event rule`", then always use
the term "`event rule`" in the documentation, not "`event`", nor
"`rule`", since they are ambiguous.

You can use light emphasis to show the importance of a part of the text
with the `\em` command (one word) or by surrounding the text to
emphasize with `<em>` and `</em>`. Likewise, you can use strong emphasis
when needed with the `\b` command (one word) or with `<strong>` and
`</strong>`. In general, prefer light emphasis to strong emphasis, and
use it economically.

Links to other parts of the documentation are very important. Consider
that the reader never knows that other functions exist other than the
one she's reading. Use as many internal links as possible. Use the
following forms of links:

`__func__()`::
    Automatic link to the function or macro named `__func__`.

`#__name__`::
    Automatic link to the type or enumerator named `__name__`.

`\ref __ref__`::
    Link to `__ref__` (page name, group name, function or macro name,
    type name, variable name, etc.) using its default text.

`\ref __ref__ "__some text__"`::
    Link to `__ref__` (page name, group name, function or macro name,
    type name, variable name, etc.) using the text `__some text__`.

See Doxygen's "`http://www.doxygen.nl/manual/autolink.html[Automatic
link generation]`" page for other ways to create automatic links.

Follow, as much as possible, the
https://docs.microsoft.com/en-ca/style-guide/welcome/[Microsoft Style
Guide] when you document the API. This includes:

* Use an active voice.
* Use a gender-neutral language.
* Use the present tense (you almost never need the future tense).
* Address your reader directly (use "`you`").
* Use contractions ("`it's`", "`you're`", "`don't`", and the rest).
* Avoid anthropomorphism.
* Ensure parallelism in lists, procedures, and sentences.
* Terminate list items with a period, except when the list only contains
  very short items.
* Do not use Latin abbreviations.
* Use "`and`" or "`or`" instead of a slash.
* Avoid using negatives.
* Avoid using "`should`": most of the time, you mean "`must`", and
  that's very clear for the reader.