xref: /haiku/docs/user/apidoc.dox (revision a5061ecec55353a5f394759473f1fd6df04890da)
1/*
2 * Copyright 2007 Niels Sascha Reedijk. All rights reserved.
3 * Copyright 2008-2013, 2020 Haiku, Inc. All rights reserved.
4 * Distributed under the terms of the MIT License.
5 *
6 * Authors:
7 *		Niels Sascha Reedijk, niels.reedijk@gmail.com
8 *		John Scipione, jscipione@gmail.com
9 *
10 * Proofreaders:
11 *		Alan Smale, ajsmale@gmail.com
12 */
13
14
15/*!
16	\page apidoc Documenting the API
17
18	This article explains how to document the API. Its intended audience are the
19	Haiku developers who want to document their own classes, and also the
20	members of the API Documentation team who want to brush up the
21	documentation. The guidelines are synchronous with the Haiku Coding
22	Guidelines, which means that the formal requirements are the same where
23	applicable. If you find an inconsistency, it's usually a good idea to
24	report this on the documentation team's mailing list.
25
26	This document is divided into three sections. \ref formalrequirements
27	describes the demands that are made from the markup and spacing of the
28	files. \ref commands describes the subset of Doxygen commands the Haiku API
29	documentation uses, and which commands are used in which situation. \ref
30	style describes the required style and structure of the documentation. If
31	you are a developer and you want to prepare the first version of the
32	documentation for the API documentation team to go over, have a good look at
33	the formal requirements and the Doxygen commands. In addition, have a quick
34	glance at how to write member and class documentation, since you'll need to
35	know which information is mandatory for the documentation. Aspiring members
36	or members of the API documentation team should read the third section
37	carefully, and should also check out some of the finished documentation to
38	get a good grip on the actual tone, style and contents of the documentation.
39
40	\section formalrequirements Formal Requirements
41
42	This section describes formal requirements, such as location and naming of
43	the files, the header blocks of files, what blocks of documentation look
44	like and how to put delimiters to separate different 'blocks' in your source
45	file.
46
47	\subsection formalrequirements_location Location of the Documentation Source
48
49	Doxygen, the tool that we use to generate the marked up documentation, has
50	an ingenious parser that is able to scan through both header and source
51	files making it possible to document the API directly in the headers or the
52	source. However, the Haiku project have decided not to put the documentation
53	in either location, and opt for the third option Doxygen provides: to put
54	the documentation into separate files.
55
56	\note The reasons to not put the documentation in the header files are twofold.
57		First of all, it would add unnecessary cruft to the headers that the
58		compiler will needlessly have to parse, and developers will have a hard
59		time to find the info they are looking for. The second reason is that
60		the system headers are included throughout the tree. It's a waste of
61		electricity to have everybody recompile the entire tree if someone fixes
62		a typo in the documentation. Likewise, the reason to not put the
63		documentation in the source code is that it unnecessarily clutters up
64		that file. By not using direct documentation we lose some advantages,
65		like the fact that developers might be inclined to update the
66		documentation quicker if they change a method, but as you will see we'll
67		have some methods in place to prevent that to a certain extent.
68		There are a few aspects to the naming and locations of files:
69		-# Most important, documentation files \b mirror header files. This
70			not only means that they get the same name, but also that the order
71			of the methods, variables, functions, etc. will have to be the same.
72		-# The root directory of the public API headers is at \c
73			headers/os. In a similar vein, the root of the documentation
74			files is at \c docs/user. The subdirectory
75			structure, or the division of kits, will also be replicated.
76		-# The name of the files is the same as the base of the header files,
77			with the \c dox extension. So \c Something.h becomes \c
78			Something.dox. Note the case!
79
80	\subsection formalrequirements_headerblock The Header Block
81
82	Every documentation file will begin with the header block. It's basically a
83	copyright block, with a reference to the author(s) and against which
84	revision the documentation was written.
85
86\verbatim
87/*
88 * Copyright 2007-2013 Haiku, Inc. All rights reserved.
89 * Distributed under the terms of the MIT License.
90 *
91 * Authors:
92 *      Niels Sascha Reedijk, niels.reedijk@gmail.com
93 *
94 * Proofreaders:
95 *      Alan Smale, ajsmale@gmail.com
96 *
97 * Corresponds to:
98 *      headers/os/support/String.h  rev 19731
99 *      src/kits/support/String.cpp  rev 19731
100 */
101\endverbatim
102
103	The example above has a few elements that you should take note of:
104	-# The header is put in a standard C comment, which is enclosed between
105\verbatim
106/*
107\endverbatim
108	and
109\verbatim
110*/
111\endverbatim
112	-# Every line starts with a whitespace and an asterisk followed by another
113		space. If the text is part of a category, such as <tt>Authors</tt>, put
114		three spaces after the delimiter.
115	-# The first line is empty, then we get to the copyright notice. You may
116		either retain the copyright yourself, or you can attribute to to Haiku
117		Inc. It's your choice. The next line is the \e MIT License notice,
118		followed by an empty line.
119	-# Then there is a label <tt>Authors:</tt>, which is followed by
120		lines with names and email addresses. The latter one is optional, but
121		recommended. Each author is proceeded by two tabs after the asterisk.
122	-# In the same vein there is the label <tt>Proofreaders:</tt> in case the
123		file has been proofread.
124	-# The final part is underneath the label <tt>Corresponds to:</tt>.
125		Underneath there is a list of files and their svn revisions that the
126		current documentation is known to correspond with.
127	-# The header block ends with the
128\verbatim
129*/
130\endverbatim
131		where the asterisk is aligned with the ones above it.
132
133	\subsection formalrequirements_blocks Blocks
134
135	Blocks are the basic units of documentation for Doxygen. At first it will
136	feel like overkill to use blocks, but realize that Doxygen was initially
137	designed to operate on header and source files, and then the blocks of
138	documentation would be before the definition or declaration of the methods,
139	functions, etcetera. Doxygen is used to operating on blocks, and that's why
140	we need to reproduce them in our \c dox files.
141
142	Blocks should adhere to the following standards:
143	-# All blocks open with
144\verbatim
145/*!
146\endverbatim
147		and close with
148\verbatim
149*/
150\endverbatim
151	-# The documentation is placed in between these markers.
152	-# All the contents in between the markers is indented by tabs. The tab
153		length should be four.
154	-# Between blocks, there should be two empty lines.
155	-# The maximum width of the contents between blocks is 80 columns. <b>Try
156		not to cross this limit</b>, because it will severely limit
157		readability.
158
159	Example:
160\verbatim
161/*!
162    \fn bool BList::AddItem(void *item)
163    \brief Append an item to the list.
164
165    \param item The item to add.
166    \retval true The item was appended.
167    \retval false Item was not appended, since resizing the list failed.
168    \sa AddItem(void *item, int32 index)
169*/
170\endverbatim
171
172	\note Doxygen also allows the use of single line comments, starting with
173		\c //!, however, we won't use these \b except for group markers, which
174		you can read more about in the next section.
175
176	\subsection formalrequirements_delimiters Delimiters
177
178	Many of the header files in the Haiku API just document one class or one
179	group of functions. However, there be a time when you come across a more
180	complex header and for the sake of clarity in your \c dox file you want to
181	mark the sections. Use the standard delimiter marker for this, which
182	consists of five slashes, a space, the title of the section, a space and
183	another five slashes. Like this: <tt>///// Global Functions /////</tt>.
184
185	\note This is only for the source files and for you as documenter. It will
186		not show up in the actual generated documentation!
187
188	\subsection formalrequirements_internal Internal documentation
189
190	It is possible that there is documentation for parts of the API that are
191	not (yet) part of the public API. It could either be that the documentation
192	is part of the public header file (usually hidden behind a namespace like
193	\c BPrivate), or it is part of a private header file.
194
195	In case you are in the situation where you need to store private API docs,
196	you should put the entirety of the documentation in a conditional block,
197	with the \c INTERNAL identifier. You open the block with the command
198	<tt>//! \\cond INTERNAL</tt> and end the block with the command
199	<tt>//! \\endcond INTERNAL</tt>.
200
201	There are two different cases where you must or could use these blocks:
202
203	1. For non-public API of a <em>public header file</em>, you must always
204		add the classes and other elements to the documentation (even if they)
205		are placeholders, and put them in the conditional block.
206	2. For parts of the non-public API that is in a <em>private header
207		file</em>, you could put the documentation in a conditional block. If
208		you choose to do so, you must document all elements in that header
209		file.
210
211	\section commands Doxygen Commands
212
213	This section describes all the Doxygen commands that will be used in the
214	Haiku API documentation. As a rule, Doxygen commands start with a backslash
215	(\\) and are followed by whitespace (such as a space or a newline), with the
216	exception of group markers; this is discussed in more detail later on. The
217	commands can be divided into several categories, which are described in the
218	following subsections.
219
220	\note This section does not discuss which commands you should actually use
221		in documentation. See the next section on \ref style for that. This
222		section merely explains the different groupings and syntaxes of
223		commands.
224
225	Most commands accept an argument. Arguments can be one of these three types:
226	- \<single_word\> - The argument is a single word.
227	- (until the end of the line) - The argument runs until the end of the line.
228	- {paragraph} - The argument runs for an entire paragraph. A paragraph is
229		ended by an empty line, or if another command that defines a \ref
230		commands_sections sections is found. Note that if you use commands that
231		work on a paragraph and you split it over multiple lines (because of the
232		maximum line width of 80 characters or because it looks better), you
233		will have to indent subsequent lines that belong to the paragraph with
234		two more spaces, making the total of four. This is to visually
235		distinguish paragraphs for other documenters.
236
237	\subsection commands_definitions Block Definitions
238
239	Because our API documentation is not done in the source, nor in the headers,
240	Doxygen needs to be helped with figuring out what the documentation in the
241	different blocks actually are about. That's why the first line in a
242	documentation block would be one of the following commands:
243
244	- \c \\class \<name\> \n
245		Tells Doxygen that the following section is going to be on the class as
246		specified by \a name.
247	- \c \\fn (function declaration) \n
248		This block is going to be about the function that corresponds to the
249		given declaration. Please note that the declaration is what you find in
250		the source file, so if class members are declared, the classname and the
251		scope operator, \c ::, are to be added as well. Modifiers such as \c
252		const should be included.
253	- \c \\var (variable declaration) \n
254		This block is going to be about the variable indicated by the
255		declaration. This means basically that data members of a class should
256		have the classname and the scope operator as well.
257	- \c \\typedef (typedef declaration) \n
258		This block is going to be about the typedef indicated by the
259		declaration. Copy the declaration exactly, including the leading \c
260		typedef keyword.
261	- \c \\struct \<name\> \n
262		Tells Doxygen the section is going to be on the \c struct indicated by
263		\a name.
264	- \c \\def \<name\> \n
265		This block is going to be about the \c \#define with the identifier \a
266		name.
267	- \c \\page \n
268		This block represents a page. See the section on \ref commands_pages for
269		detailed information on pages.
270
271	\subsection commands_sections Sections in Member Documentation
272
273	If you have a look at the output that Doxygen generates, you can see that
274	there are recurring sections in the documentation. Documentation that
275	belongs to a certain section should be placed after a command that marks the
276	start of that section. All the commands take a paragraph as answer. A
277	paragraph ends with a whitespace, or with a command that marks a new
278	section. Note that this list only shows the syntax of the commands. For the
279	semantics, have a look at the next section on style. In member documentation
280	you can use the following:
281
282	- \c \\brief {brief description} \n
283		This is the only \b mandatory section. Every member should have at least
284		a brief description.
285	- \c \\param \<parameter-name\> {parameter description} \n
286		This section describes a parameter with the name \a parameter-name. The
287		parameter name must match the function declaration, since Doxygen will
288		check if all the documented parameters exist.
289	- \c \\return {description of the return value} \n
290		This section describes the return value. This is a totally free form
291		paragraph, whereas \c \\retval has a more structured form.
292	- \c \\retval \<value\> {description} \n
293		This section describes the return value indicated by \a value.
294	- \c \\see {references} \n
295		This section contains references to other parts of the documentation.
296
297	There are also a number of things that can be used in pages and member
298	documentation. See the style section to find out the appropriate situations
299	in which to use them.
300	- \c \\note {text}
301	- \c \\attention {text}
302	- \c \\warning {text}
303	- \c \\remarks {text}
304
305	\subsection commands_markup Markup
306
307	Sometimes you might require certain text to have a special markup, to make
308	words stand out, but also if you want to have example code within the
309	documentation you'll need a special markup. Doxygen defines three types of
310	commands. There are commands that work on single words, commands that work
311	on longer phrases and commands that define blocks. Basically, the single
312	letter commands are commands that work on a the next word. If you need to
313	mark multiple words or sentences, use the HTML-style commands. Finally, for
314	blocks of code or blocks of text that need to be in "typewriter" font, use
315	the block commands. Have a look at the following listing:
316
317	- \c \\a \n
318		Use to refer to parameters or arguments in a running text, for example
319		when referring to parameters in method descriptions.
320	- <b>Bold text</b>
321		- For single words, use \c \\b.
322		- For multiple words, enclose between the \c \<b\> and \c \<\\b\> tags.
323	- <tt>Typewriter font</tt> \n
324		This can be used to refer to constants, or anything that needs to be in
325		a monospace, or typewriter, font. There are a few options
326		- \c \\c for single words.
327		- \c \<tt\> and \c \<\\tt\> for multiple words or phrases
328		- The commands \c \\verbatim and \c \\endverbatim. Everything between
329			these two commands will be put in a distinct block that stands out
330			from the rest of the text.
331		- The commands \c \\code and \c \\endcode do the same, but Doxygen will
332			parse the contents and try to mark up the code to make it look a
333			little bit nicer.
334	- <em>Emphasis</em>
335		- \c \\e for single words.
336		- \c \<em\> and \c \<\\em\> for phrases.
337
338	\subsection commands_pages Page Commands
339
340	Pages are a very special element of the documentation. They are not
341	associated with any kind of module, such as files or classes, and therefore,
342	since they're not members, some of the structuring commands won't work.
343	Important to know is that a page is the complete length of the block, so
344	dividing it up in subsections by starting new blocks will not work. Instead,
345	Doxygen provides some commands to structure text on a page.
346
347	First of all, you define a new page by using the \c \\page command. This
348	command takes two arguments: a \c \<name\> and <tt>(a title)</tt>. The name
349	is the internal identifier that can be used in linking between pages (see
350	\ref commands_miscellaneous for \c \\ref). After you've defined the block
351	to be a page, you can start writing the contents.
352
353	For more complicated pages,  you might want to divide the page up in
354	sections. Use the \c \\section command to define a new section. It takes the
355	same arguments as \c \\page, namely the \c \<name\> and the
356	<tt>(title)</tt>. If you need a deeper hierarchy you may use \c \\subsection
357	and \c \\subsubsection, again, both with the same syntax. If you need to
358	distinguish between sections in sub-sub-sections, you are able to use
359	\c \\paragraph, which takes the same arguments.
360
361	\note Before and after each of the commands above, you need to have an empty
362		line so as to provide readability. It is not necessary to indent
363		sections and subsections more than the normal two spaces, as long as you
364		keep the section markers clear.
365
366	\warning If you are entering the realm of subsections and sub-subsections,
367		think about the nature of your page. Either it needs to be split up into
368		multiple pages, or what you're writing is too complex and would be
369		better off as a big tutorial on the Haiku website.
370
371	If you are creating multiple pages that are related, you will be able to
372	structure them in a tree by using the \c \\subpage command. This will rank
373	the different pages in a tree structure. It will put a link in the place of
374	the command, so you should place it at the top of the parent place and use
375	it as an index.
376
377	\subsection commands_grouping  Member Grouping Commands
378
379	Doxygen makes it possible to group certain members together. It is used
380	in the BString class for example, where the members are grouped by what kind
381	of operation they perform, such as appending, finding, etc. Defining groups
382	is currently not as powerful as it could be, but if you use it inside
383	classes, you will be fine if you follow the instructions presented in
384	this section.
385
386	\note If you are looking on how to add classes to kits, see
387		\ref commands_miscellaneous and have a look at the \c \\ingroup command.
388
389	Groups of members are preceded by a block that describes what the group is
390	about. You are required to give each group of members at least a name. Have
391	a look at the example:
392
393\verbatim
394/*!
395    \name Appending Methods
396
397    These methods append things to the object.
398*/
399
400
401//! \@{
402
403
404... methods ...
405
406
407//! \@}
408
409\endverbatim
410
411	The block preceding the block opening marker, <tt>//! \@{</tt>, contains a
412	\c \\name command and a paragraph that gives a description. The header
413	block can be as long or short as you want, but please don't make it too
414	long. See the \ref style section on how to effectively write group headers.
415	The members that you want to belong to the group are between the group
416	opening and closing markers.
417
418	\note Group headers don't have a \c \\brief description.
419
420	\subsection commands_miscellaneous Miscellaneous Commands
421
422	There are some commands that don't fit into the categories above, but that
423	you will end up using every now and then. This section will describe those
424	commands.
425
426	The first one is \c \\n. This commands sort of belongs to the category of
427	markup commands. It basically forces a newline. Because Doxygen parses
428	paragraphs as a single contiguous entity, it's not possible to mark up the
429	text using carriage returns in the documentation. \c \\n forces a newline in
430	the output. So in HTML it will be translated into a \c \<br\\\>.
431
432	Sometimes there are some parts of the API that you don't want to be visible.
433	Since Doxygen extracts all the public and protected members from a class,
434	and virtually every member from a file, you might want to force it to hide
435	certain things. If so, use the \c \\internal command. If you place this just
436	after the block marker, the command will be hidden from documentation. Any
437	further documentation or remarks you put inside the block will not be
438	visible in the final documentation.
439
440	Images can be a valuable addition to documentation. To include ones you
441	made, use the \c \\image command. It has the following prototype:
442	<tt>\\image \<format\> \<file\></tt>. The format is currently fixed at
443	\c html. The file refers to the filename relative to the location of the
444	documentation file. Any images you want to add should be in the same
445	location as the dox file, so only the file name will suffice.
446
447	Modules are defined in the main book, and you can add classes to them by
448	using the \c \\ingroup command. This commands adds the class to the module
449	and groups it on a separate page. At this moment, the group handling has yet
450	to be finalized. For now, add the classes to the kit they belong in. In the
451	future this might change.
452
453	Finally, it is a good idea to link between parts of the documentation. There
454	are two commands for that. The first one is \c \\ref, which enable you to
455	refer to pages, sections, etc. that you created yourself. The second one is
456	\c \\link which refers to members. The first one is takes one word as an
457	argument, the name of the section, and it inserts a link with the name of
458	the title. \c \\link is more complex. It should always be accompanied by \c
459	\\endlink. The first word between the two commands is the object that is
460	referred to, and the rest is the link text.
461
462	\section style Writing Guidelines
463
464	This final section will present guidelines for the actual writing of the
465	documentation. Both the structure of the documentation, which sections to
466	use when, and the style of the writing will be discussed. Before diverging
467	into the requirements for file and class descriptions, member descriptions
468	and pages, there are some general remarks that apply to all types of
469	documentation.
470
471	First of all, everything you write should be in <em>proper English
472	sentences</em>. Spelling, grammar, punctuation, make sure you adhere to the
473	standards. It also means the following:
474	- It means that every sentence should at least have a
475		subject and a verb (unless it's an imperative statement).
476	- Also use the proper terminology. Remember, you are dealing with C++
477		here, which means you should use the right names. So use \b method
478		instead of function, and data member instead of variable (where
479		appropriate).
480	- Avoid in-formalism. Avoid constructs like 'if you want to
481		disconnect the object', but rather use 'to disconnect the object'. Avoid
482		familiarizes, or jokes.
483
484	\remarks It isn't the goal to create dry, legal-style documentation. Just
485		try to find a balance. Read through documentation that's already been
486		approved to get a hint of what you should be aiming for.
487	\remarks If you are having a problem with phrasing certain things, put it
488		down in such a way that it says everything it needs to. A proofreader
489		might then be able to rephrase it to a better style.
490
491	Throughout the documentation you might want to provide hints, warnings or
492	remarks that might interrupt the flow of the text, or that need to visually
493	stand out from the rest. Doxygen provides commands for paragraphs that
494	display remarks, warnings, notes and points of attention. You can use these
495	commands in case you meet one or more of the following requirements:
496	- The point is for a specific audience, such as beginners in the Haiku API.
497		Notes on what to read first, or mistakes that may be made by beginners
498		will not be for the entire audience, and such should be separated. These
499		kinds of notes should be at the end of blocks.
500	- The point needs to visually stand out. This is especially the case with
501		remarks, but could also apply for other types.
502	- The point is not completely relevant to the text and therefore should be
503		separated so that it doesn't interrupt the main flow.
504
505	This listing shows which one to use for which situation:
506	- \c \\attention
507		- Used when the developer is bound to make a mistake, when the API is
508			ambiguous. The difference between this and a warning is that
509			warnings warn about things that are the developers fault, and
510			attention blocks warn about things that might go wrong
511			because of the way the API is	structured.
512		- Used to warn for abuse of the API that might be caused by the way the
513			internals of the system are structured.
514	- \c \\warning
515		- Used to warn developers about using the API in a certain way. Warnings
516			apply especially to new developers that aren't completely familiar
517			with the API and that might want to abuse it. For example, the
518			thread safety of BString requires a warning.
519	- \c \\note
520		- Used to place references to other documentation that might not be
521			directly related to the text. For example, BLooper will have a
522			direct reference to BHandler in the class description, but
523			BMessenger will be mentioned in a note because it does not directly
524			influence the use of the class.
525		- Can also be used for useful hints or notes that somehow need to stand
526			out from the rest of the text.
527	- \c \\remarks
528		- Remarks are small notes that would interrupt the flow of the text. For
529			example, if you in a text ignore a certain condition that is so
530			extremely rare and uncommon, you can put a remark at the end of the
531			text to tell that you have been lying.
532		- Remarks interact with the text whereas notes add something unmentioned
533			to it.
534
535	\subsection style_files File Descriptions
536
537	The design of Doxygen makes it very file oriented, and this might come off
538	as inconvenient. At the moment, how to actually group the documentation is
539	still under debate, but it does not change the requirement that a header
540	needs to be documented before the members of that header can be documented.
541	As such, the first documentation block in your \c dox file will be the block
542	that describes the header. Examples:
543
544\verbatim
545/*!
546    \file String.h
547    \brief Defines the BString class and global operators and functions for
548           handling strings.
549*/
550
551
552/*!
553    \file SupportDefs.h
554    \brief Defines basic types and definitions for the Haiku API.
555*/
556\endverbatim
557
558	The first statement defines what the block is about, namely the header file.
559	The second element is the \c \\brief remark on what it contains. The first
560	file defines the BString class and some global operators. You can see that
561	reflected in the description. SupportDefs.h does not define classes, but
562	rather a range of different functions and defines, so the text refers to
563	that.
564
565	\remarks \\brief documentation for files is about what it \e implements, as
566		header files are passive (whereas members and functions are active).
567		Thus, use the third person form of the verb.
568
569	\subsection style_classes Class Descriptions
570
571	Classes are the basic building blocks in the Haiku API and as such have
572	extensive documentation. This section will go over the actual class
573	description. This section will present a list of items you should think
574	about when writing the class description. This doesn't mean you'll have
575	to include every item, it merely serves as a guiding principle that helps
576	organise your thoughts. Have a look at the list:
577
578	-# The \c \\brief description is \b obligatory. This description describes
579		what it is. For example, BDataIO: "Abstract interface for objects that
580		provide read and write access to data." Note that this description is
581		not a full sentence, but it does end with a period.
582	-# One or more paragraphs that give a broad overview of what the class can
583		do. Describe things like what it works on, when you want to use it, what
584		advantage it might give over other directly related alternatives. Also
585		describe if a class is made to be derived from, and if so, how. Make
586		sure that a developer in the first few paragraphs can judge if what he
587		wants to do can be done with this class.
588	-# One or more paragraphs that show how this class ties in with the rest
589		of the kit or the API. What objects does it work with, how it interacts
590		with the servers, etcetera.
591	-# One or more paragraphs that give a concrete example or use case. Keep it
592		tidy and self contained. If you use code examples, make sure your
593		examples adhere to Haiku's coding guidelines. Remember, an example can
594		illustrate better than a few paragraphs of text.
595	-# End with a list of references to other classes, functions, pages, etc.
596		that might be of interest to the reader.
597
598	When documenting classes, don't be to exhaustive. Avoid becoming a tutorial
599	or a complete guide. This documentation is for reference only. If you want
600	to enlighten the reader on bigger subjects, consider writing a separate
601	documentation page that connects the different points you want to make.
602
603	Also, you don't have to put in any groupings of members in class
604	descriptions. If you want to do that, physically divide the members up in
605	groups. Look at the \ref commands_grouping for the actual commands, and at
606	\ref style_groups for help on writing group headers.
607
608	\subsection style_members Members and Functions
609
610	Members and functions share the same basic Doxygen syntax, and they can be
611	documented in a similar way. That's why this section deals with them
612	together. Documenting members is probably the main thing you'll do when
613	writing the actual documentation. There are some guidelines as to how, but
614	the actual implementation probably differs per class. Keep the following
615	points in mind:
616
617	-# To repeat a very important fact, the first line is a \c \\fn line. This
618		line needs to match the declaration, which is in the source file. This
619		means that for members, also the class name and the scope indicator (::)
620		should be present. Also note that this line doesn't have to adhere to
621		the 80 column width limit.
622	-# The first command is always the \c \\brief command. Give a short and
623		clear description. The description starts with a capital letter and ends
624		with a dot. Don't write the description saying what the method does,
625		like "Starts the timer", but rather as what it will do: "Start the
626		timer." -# If the brief description doesn't cover all of what the method
627		or function does, then you can add a few paragraphs that explain it in
628		more depth. Don't be too verbose, and use an example to illustrate
629		points. Point out any potential misunderstandings or problems you expect
630		developers to have, but don't repeat the class documentation too much.
631	-# You are obliged to then document all the parameters. Use the \c \\param
632		command for that. For the description, use a short phrase such as "The
633		offset (zero based) where to begin the move." Note the capital and the
634		dot.
635	-# If the function is non-void, then you'll have to specify what it will
636		return. In case of fixed values, have a look at \c \\retval. You'll use
637		this one when the return type is a bool or a status_t. In case of
638		something else, use \c \\return. You can also combine these two. For
639		example, a method that returns a length (positive) or an error code
640		(negative).
641	-# Use \c \\see if you have any references to other methods, classes or
642		global functions. At least document all the overloaded methods. Also add
643		methods that do the opposite of this method, or methods that are
644		intimately related.
645
646	In case of overloaded members, you'll need to make a decision. If you need
647	to copy too much information, you might resort to putting it in one
648	paragraph with the text "This is an overloaded member function, and differs
649	from \<name\> only by the type of parameter it takes." That will keep the
650	copying down and will point developers right to the place where they can get
651	more documentation.
652
653	Again, like class descriptions, you'll have to find a good middle-ground
654	between too much information, and too little. Again, write for the broadest
655	audience possible, and resort to notes and warnings for specialised
656	audiences.
657
658	\subsection style_variables Enumerations, Variables and Defines
659
660	This section helps you document (member) variables and defines that define
661	constants, as well as enumerations and their values. If you need to document
662	a \c \#define macro that takes arguments, have a look at \ref style_members
663
664	The \c \\brief description of all these types follow a similar structure.
665	They are a short phrase that mention what the variable contains. Example:
666
667\verbatim
668/*!
669    \var char* BString::fPrivateData
670    \brief BString's storage for data.
671
672    This member is deprecated and might even become \c private in future
673    releases.
674
675    If you are planning to derive from this object and you want to manipulate
676    the raw string data, please have a look at LockBuffer() and UnlockBuffer().
677*/
678\endverbatim
679
680	The variables you are going to encounter are either \c public or
681	\c protected member variables, or global variables that have a certain
682	significance. In the case of member variables, you'll need to document what
683	they mean and how the developer should manipulate them. If the class is one
684	that is meant to be derived from, make sure that in the description of the
685	variable you mention how it interacts with the others, and how the developer
686	should make sure that the internal coherence of the data and code members of
687	the inherited class is maintained.
688
689	Global variables will mostly be constants. If so, document what they stand
690	for and what they might be used for, as well as which classes and functions
691	depend on that constant. If the variable is meant to be changed by the
692	developer, explain what values are valid and which functions and classes
693	depend on this variable.
694
695	Defines are usually used as message constants. Give a short description of
696	what the message constant stands for, and where it might be send from and
697	where it might be received.
698
699	Enumerations can either be anonymous or named. In case of the latter, you
700	can give a description of the enumeration in a documentation block that
701	starts with an \c \\enum command, followed by the name of the enumeration.
702	If the enumeration is within the scope of a class, prepend the classname and
703	the scope indicator. In case of an anonymous enum, you can only document the
704	individual members (which you should do for the named enumerations as well),
705	which can be done within code blocks that start with the \c \\var command.
706	Doxygen will know that it's an enumeration value, don't worry about mixups.
707	If the enumeration value is within a class, prepend the classname and scope
708	indicator. Give a short description of the value, which methods react to
709	it, where it might be used, etcetera. Don't go as far as to copy information
710	too much. For example, if you use an enumeration in only one class and you
711	document the possible values there, then don't do that again for the
712	enumeration documentation: rather just refer to it. That sort of
713	documentation belongs to the class description, not to the enumeration.
714
715	\subsection style_groups Groups
716
717	If you subdivide members of classes into groups, you have the ability to
718	apply some general information that will be listed above the listing of the
719	members in that group. See the section \ref commands_grouping on how to
720	define groups. This section is on what to put in the header block.
721
722	First of all, it's probably a good idea to give your group a name. This name
723	will be printed as a title and will enhance the clarity of what the group
724	contains. If you put the \c \\name command as the first command of a group,
725	the rest of the words on that line will be used as the title. You should
726	choose simple titles of no more than three words.
727
728	It's possible to add one or two paragraphs of information. These paragraphs
729	should contain some quick notes on which of the members in that group to use
730	for what purpose. See it as a quick subdivision that a developer could use
731	as a guide to see which method he actually wants to use. Don't go on
732	describing the methods in detail though, that's what the member
733	documentation is about. Have a look at the example:
734
735\verbatim
736/*!
737    \name Comparison Methods
738
739    There are two different comparison methods. First of all there is the whole
740    range of operators that return a boolean value, secondly there are methods
741    that return an integer value, both case sensitive and case insensitive.
742
743    There are also global comparison operators and global compare functions.
744    You might need these in case you have a sort routine that takes a generic
745    comparison function, such as BList::SortItems().
746
747    See the String.h documentation file to see the specifics, as they are
748    basically the same as implemented in this class.
749*/
750\endverbatim
751
752	Straight, to the point, gives no more information than necessary. Divides
753	the members up into two groups and refers to other functions the developer
754	might be looking for. The hard limit is two (short) paragraphs. Using more
755	will not improve clarity.
756*/
757