Update the API guidelines to make them more consistent with the coding
guidelines. Three new guidelines: - Commas between names and email adresses in header blocks. - Indent with tabs (with lenght 4) - Two whitelines between blocks git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21832 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+264
-244
@@ -1,89 +1,91 @@
|
||||
/*
|
||||
* Copyright 2007 Haiku Inc. All rights reserved.
|
||||
* Copyright 2007 Niels Sascha Reedijk. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Niels Sascha Reedijk <[email protected]>
|
||||
* Niels Sascha Reedijk, [email protected]
|
||||
* Proofreaders:
|
||||
* Alan Smale <[email protected]>
|
||||
* Alan Smale, [email protected]
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\page apidoc Documenting the API
|
||||
|
||||
This article explains how to document the API. Its intended audience are the
|
||||
Haiku developers who want to document their own classes, and also the members
|
||||
of the API Documentation team who want to brush up the documentation.
|
||||
Haiku developers who want to document their own classes, and also the
|
||||
members of the API Documentation team who want to brush up the
|
||||
documentation.
|
||||
|
||||
This document is divided into three sections. \ref formalrequirements
|
||||
describes the demands that are made from the markup and spacing of the files.
|
||||
\ref commands describes the subset of Doxygen commands the Haiku API
|
||||
documentation uses, and which commands are used in which situation. \ref style
|
||||
describes the required style and structure of the documentation.
|
||||
|
||||
If you are a developer and you want to prepare the first version of the
|
||||
describes the demands that are made from the markup and spacing of the
|
||||
files. \ref commands describes the subset of Doxygen commands the Haiku API
|
||||
documentation uses, and which commands are used in which situation. \ref
|
||||
style describes the required style and structure of the documentation. If
|
||||
you are a developer and you want to prepare the first version of the
|
||||
documentation for the API documentation team to go over, have a good look at
|
||||
the formal requirements and the Doxygen commands. In addition, have a quick
|
||||
glance at how to write member and class documentation, since you'll need to
|
||||
know which information is mandatory for the documentation. Aspiring members or
|
||||
members of the API documentation team should read the third section carefully,
|
||||
and should also check out some of the finished documentation to get a good
|
||||
grip on the actual tone, style and contents of the documentation.
|
||||
know which information is mandatory for the documentation. Aspiring members
|
||||
or members of the API documentation team should read the third section
|
||||
carefully, and should also check out some of the finished documentation to
|
||||
get a good grip on the actual tone, style and contents of the documentation.
|
||||
|
||||
\section formalrequirements Formal Requirements
|
||||
|
||||
This section describes formal requirements, such as location and naming of
|
||||
the files, the header blocks of files, what blocks of documentation look like
|
||||
and how to put delimiters to separate different 'blocks' in your source file.
|
||||
the files, the header blocks of files, what blocks of documentation look
|
||||
like and how to put delimiters to separate different 'blocks' in your source
|
||||
file.
|
||||
|
||||
\subsection formalrequirements_location Location of the Documentation Source
|
||||
|
||||
Doxygen, the tool that we use to generate the marked up documentation, has an
|
||||
ingenious parser that is able to scan through both header and source files
|
||||
making it possible to document the API directly in the headers or the source.
|
||||
However, the Haiku project have decided not to put the documentation in either
|
||||
location, and opt for the third option Doxygen provides: to put the
|
||||
documentation into separate files.
|
||||
Doxygen, the tool that we use to generate the marked up documentation, has
|
||||
an ingenious parser that is able to scan through both header and source
|
||||
files making it possible to document the API directly in the headers or the
|
||||
source. However, the Haiku project have decided not to put the documentation
|
||||
in either location, and opt for the third option Doxygen provides: to put
|
||||
the documentation into separate files.
|
||||
|
||||
\note The reasons to not put the documentation in the header files are
|
||||
twofold. First of all, it would add unnecessary cruft to the headers that
|
||||
the compiler will needlessly have to parse. File access and speed isn't BeOS
|
||||
and Haiku's best quality. The second reason is that the system headers are
|
||||
included throughout the tree. It's a waste of electricity to have everybody
|
||||
recompile the entire tree if someone fixes a typo in the documentation.
|
||||
Likewise, the reason to not put the documentation in the source code is that
|
||||
it unnecessarily clutters up that file. By not using direct documentation we
|
||||
lose some advantages, like the fact that developers might be inclined to
|
||||
update the documentation quicker if they change a method, but as you will
|
||||
see we'll have some methods in place to prevent that to a certain extent.
|
||||
|
||||
twofold. First of all, it would add unnecessary cruft to the headers
|
||||
that the compiler will needlessly have to parse. File access and speed
|
||||
isn't BeOS and Haiku's best quality. The second reason is that the
|
||||
system headers are included throughout the tree. It's a waste of
|
||||
electricity to have everybody recompile the entire tree if someone fixes
|
||||
a typo in the documentation. Likewise, the reason to not put the
|
||||
documentation in the source code is that it unnecessarily clutters up
|
||||
that file. By not using direct documentation we lose some advantages,
|
||||
like the fact that developers might be inclined to update the
|
||||
documentation quicker if they change a method, but as you will see we'll
|
||||
have some methods in place to prevent that to a certain extent.
|
||||
There are a few aspects to the naming and locations of files:
|
||||
-# Most important, documentation files \b mirror header files. This not only
|
||||
means that they get the same name, but also that the order of the methods,
|
||||
variables, functions, etc. will have to be the same.
|
||||
-# The root directory of the public API headers is at \c /trunk/headers/os.
|
||||
In a similar vein, the root of the documentation files is at
|
||||
\c /trunk/src/documentation/haiku_book. The subdirectory structure, or
|
||||
the division of kits, will also be replicated.
|
||||
-# The name of the files is the same as the base of the header files, with
|
||||
the \c dox extension. So \c Something.h becomes \c Something.dox. Note
|
||||
the case!
|
||||
-# Most important, documentation files \b mirror header files. This
|
||||
not only means that they get the same name, but also that the order
|
||||
of the methods, variables, functions, etc. will have to be the same.
|
||||
-# The root directory of the public API headers is at \c
|
||||
/trunk/headers/os. In a similar vein, the root of the documentation
|
||||
files is at \c /trunk/src/documentation/haiku_book. The subdirectory
|
||||
structure, or the division of kits, will also be replicated.
|
||||
-# The name of the files is the same as the base of the header files,
|
||||
with the \c dox extension. So \c Something.h becomes \c
|
||||
Something.dox. Note the case!
|
||||
|
||||
\subsection formalrequirements_headerblock The Header Block
|
||||
|
||||
Every documentation file will begin with the header block. It's basically a
|
||||
copyright block, with a reference to the author(s) and against which revision
|
||||
the documentation was written.
|
||||
copyright block, with a reference to the author(s) and against which
|
||||
revision the documentation was written.
|
||||
|
||||
\verbatim
|
||||
/*
|
||||
* Copyright 2007 Haiku Inc. All rights reserved.
|
||||
* Copyright 2007 Niels Sascha Reedijk. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Niels Sascha Reedijk <[email protected]>
|
||||
* Niels Sascha Reedijk, [email protected]
|
||||
* Proofreaders:
|
||||
* Alan Smale <[email protected]>
|
||||
* Alan Smale, [email protected]
|
||||
* Corresponds to:
|
||||
* /trunk/headers/os/support/String.h rev 19731
|
||||
* /trunk/src/kits/support/String.cpp rev 19731
|
||||
@@ -91,15 +93,18 @@
|
||||
\endverbatim
|
||||
|
||||
The example above has a few elements that you should take note of:
|
||||
-# The header is put in a standard C comment, which is enclosed between
|
||||
\c /* and \c *\/.
|
||||
-# The header is put in a standard C comment, which is enclosed between \c
|
||||
/* and \c *\/.
|
||||
-# Every line starts with a whitespace and an asterix, followed by another
|
||||
space. If the text is part of a category, such as <tt>Authors</tt>, put
|
||||
three spaces after the delimiter.
|
||||
-# We start with a copyright notice. The first line is empty, then the
|
||||
copyright notice, then the line on \e MIT, followed by an empty line.
|
||||
-# The first line is empty, then we get to the copyright notice. You may
|
||||
either retain the copyright yourself, or you can attribute to to Haiku
|
||||
Inc. It's your choice. The next line is the \e MIT licence notice,
|
||||
followed by an empty line.
|
||||
-# Then there is a label <tt>Authors:</tt>, which is followed by
|
||||
lines with names and email addresses between brackets.
|
||||
lines with names and email addresses. The latter one is optional, but
|
||||
recommended.
|
||||
-# In the same vein there is the label <tt>Proofreaders:</tt> in case the
|
||||
file has been proofread.
|
||||
-# The final part is underneath the label <tt>Corresponds to:</tt>.
|
||||
@@ -110,19 +115,22 @@
|
||||
|
||||
\subsection formalrequirements_blocks Blocks
|
||||
|
||||
Blocks are the basic units of documentation for Doxygen. At first it will feel
|
||||
like overkill to use blocks, but realize that Doxygen was initially designed
|
||||
to operate on header and source files, and then the blocks of documentation
|
||||
would be before the definition or declaration of the methods, functions,
|
||||
etcetera. Doxygen is used to operating on blocks, and that's why we need to
|
||||
reproduce them in our \c dox files.
|
||||
Blocks are the basic units of documentation for Doxygen. At first it will
|
||||
feel like overkill to use blocks, but realize that Doxygen was initially
|
||||
designed to operate on header and source files, and then the blocks of
|
||||
documentation would be before the definition or declaration of the methods,
|
||||
functions, etcetera. Doxygen is used to operating on blocks, and that's why
|
||||
we need to reproduce them in our \c dox files.
|
||||
|
||||
Blocks should adhere to the following standards:
|
||||
-# All blocks open with \c /*! and close with \c * /
|
||||
-# The documentation is placed in between these markers.
|
||||
-# All the contents in between the markers is indented by two spaces.
|
||||
-# The maximum width of the contents between blocks is 80 columns. <em>Try not
|
||||
to cross this limit</em>, because it will severely limit readability.
|
||||
-# All the contents in between the markers is indented by tabs. The tab
|
||||
length should be four.
|
||||
-# Between blocks, there should be two empty lines.
|
||||
-# The maximum width of the contents between blocks is 80 columns. <em>Try
|
||||
not to cross this limit</em>, because it will severely limit
|
||||
readability.
|
||||
|
||||
Example:
|
||||
\verbatim
|
||||
@@ -138,34 +146,34 @@
|
||||
\endverbatim
|
||||
|
||||
\note Doxygen also allows the use of single line comments, starting with
|
||||
\c //!, however, we won't use these \b except for group markers, which you
|
||||
can read more about in the next section.
|
||||
\c //!, however, we won't use these \b except for group markers, which
|
||||
you can read more about in the next section.
|
||||
|
||||
\subsection formalrequirements_delimiters Delimiters
|
||||
|
||||
Many of the header files in the Haiku API just document one class or one group
|
||||
of functions. However, there be a time when you come across a more complex
|
||||
header and for the sake of clarity in your \c dox file you want to mark the
|
||||
sections. Use the standard delimiter marker for this, which consists of five
|
||||
slashes, a space, the title of the section, a space and another five slashes.
|
||||
Like this: <tt>///// Global Functions /////</tt>.
|
||||
Many of the header files in the Haiku API just document one class or one
|
||||
group of functions. However, there be a time when you come across a more
|
||||
complex header and for the sake of clarity in your \c dox file you want to
|
||||
mark the sections. Use the standard delimiter marker for this, which
|
||||
consists of five slashes, a space, the title of the section, a space and
|
||||
another five slashes. Like this: <tt>///// Global Functions /////</tt>.
|
||||
|
||||
\note This is only for the source files and for you as documenter. It will
|
||||
not show up in the actual generated documentation!
|
||||
|
||||
\section commands Doxygen Commands
|
||||
|
||||
This section describes all the Doxygen commands that will be used in the Haiku
|
||||
API documentation. As a rule, Doxygen commands start with a backslash (\\) and
|
||||
are followed by whitespace (such as a space or a newline), with the exception
|
||||
of group markers; this is discussed in more detail later on. The commands can
|
||||
be divided into several categories, which are described in the following
|
||||
subsections.
|
||||
This section describes all the Doxygen commands that will be used in the
|
||||
Haiku API documentation. As a rule, Doxygen commands start with a backslash
|
||||
(\\) and are followed by whitespace (such as a space or a newline), with the
|
||||
exception of group markers; this is discussed in more detail later on. The
|
||||
commands can be divided into several categories, which are described in the
|
||||
following subsections.
|
||||
|
||||
\note This section does not discuss which commands you should actually use
|
||||
in documentation. See the next section on \ref style
|
||||
for that. This section merely explains the different groupings and
|
||||
syntaxes of commands.
|
||||
in documentation. See the next section on \ref style for that. This
|
||||
section merely explains the different groupings and syntaxes of
|
||||
commands.
|
||||
|
||||
Most commands accept an argument. Arguments can be one of these three types:
|
||||
- \<single_word\> - The argument is a single word.
|
||||
@@ -174,10 +182,10 @@
|
||||
ended by an empty line, or if another command that defines a \ref
|
||||
commands_sections sections is found. Note that if you use commands that
|
||||
work on a paragraph and you split it over multiple lines (because of the
|
||||
maximum line width of 80 characters or because it looks better), you will
|
||||
have to indent subsequent lines that belong to the paragraph with two more
|
||||
spaces, making the total of four. This is to visually distinguish
|
||||
paragraphs for other documenters.
|
||||
maximum line width of 80 characters or because it looks better), you
|
||||
will have to indent subsequent lines that belong to the paragraph with
|
||||
two more spaces, making the total of four. This is to visually
|
||||
distinguish paragraphs for other documenters.
|
||||
|
||||
\subsection commands_definitions Block Definitions
|
||||
|
||||
@@ -190,23 +198,25 @@
|
||||
Tells Doxygen that the following section is going to be on the class as
|
||||
specified by \a name.
|
||||
- \c \\fn (function declaration) \n
|
||||
This block is going to be about the function that corresponds to the given
|
||||
declaration. Please note that the declaration is what you find in the source
|
||||
file, so if class members are declared, the classname and the scope operator,
|
||||
\c ::, are to be added as well. Modifiers such as \c const should be
|
||||
included.
|
||||
This block is going to be about the function that corresponds to the
|
||||
given declaration. Please note that the declaration is what you find in
|
||||
the source file, so if class members are declared, the classname and the
|
||||
scope operator, \c ::, are to be added as well. Modifiers such as \c
|
||||
const should be included.
|
||||
- \c \\var (variable declaration) \n
|
||||
This block is going to be about the variable indicated by the declaration.
|
||||
This means basically that data members of a class should have the classname
|
||||
and the scope operator as well.
|
||||
This block is going to be about the variable indicated by the
|
||||
declaration. This means basically that data members of a class should
|
||||
have the classname and the scope operator as well.
|
||||
- \c \\typedef (typedef declaration) \n
|
||||
This block is going to be about the typedef indicated by the declaration.
|
||||
Copy the declaration exactly, including the leading \c typedef keyword.
|
||||
This block is going to be about the typedef indicated by the
|
||||
declaration. Copy the declaration exactly, including the leading \c
|
||||
typedef keyword.
|
||||
- \c \\struct \<name\> \n
|
||||
Tells Doxygen the section is going to be on the \c struct indicated by
|
||||
\a name.
|
||||
- \c \\def \<name\> \n
|
||||
This block is going to be about the \c \#define with the identifier \a name.
|
||||
This block is going to be about the \c \#define with the identifier \a
|
||||
name.
|
||||
- \c \\page \n
|
||||
This block represents a page. See the section on \ref commands_pages for
|
||||
detailed information on pages.
|
||||
@@ -214,13 +224,13 @@
|
||||
\subsection commands_sections Sections in Member Documentation
|
||||
|
||||
If you have a look at the output that Doxygen generates, you can see that
|
||||
there are recurring sections in the documentation. Documentation that belongs
|
||||
to a certain section should be placed after a command that marks the start
|
||||
of that section. All the commands take a paragraph as answer. A paragraph
|
||||
ends with a whitespace, or with a command that marks a new section. Note that
|
||||
this list only shows the syntax of the commands. For the semantics, have a
|
||||
look at the next section on style. In member documentation you can use the
|
||||
following:
|
||||
there are recurring sections in the documentation. Documentation that
|
||||
belongs to a certain section should be placed after a command that marks the
|
||||
start of that section. All the commands take a paragraph as answer. A
|
||||
paragraph ends with a whitespace, or with a command that marks a new
|
||||
section. Note that this list only shows the syntax of the commands. For the
|
||||
semantics, have a look at the next section on style. In member documentation
|
||||
you can use the following:
|
||||
|
||||
- \c \\brief {brief description} \n
|
||||
This is the only \b mandatory section. Every member should have at least
|
||||
@@ -238,8 +248,8 @@
|
||||
This section contains references to other parts of the documentation.
|
||||
|
||||
There are also a number of things that can be used in pages and member
|
||||
documentation. See the style section to find out the appropriate situations in
|
||||
which to use them.
|
||||
documentation. See the style section to find out the appropriate situations
|
||||
in which to use them.
|
||||
|
||||
- \c \\note {text}
|
||||
- \c \\attention {text}
|
||||
@@ -251,12 +261,12 @@
|
||||
Sometimes you might require certain text to have a special markup, to make
|
||||
words stand out, but also if you want to have example code within the
|
||||
documentation you'll need a special markup. Doxygen defines three types of
|
||||
commands. There are commands that work on single words, commands that work on
|
||||
longer phrases and commands that define blocks. Basically, the single letter
|
||||
commands are commands that work on a the next word. If you need to mark
|
||||
multiple words or sentences, use the HTML-style commands. Finally, for blocks
|
||||
of code or blocks of text that need to be in "typewriter" font, use the block
|
||||
commands. Have a look at the following listing:
|
||||
commands. There are commands that work on single words, commands that work
|
||||
on longer phrases and commands that define blocks. Basically, the single
|
||||
letter commands are commands that work on a the next word. If you need to
|
||||
mark multiple words or sentences, use the HTML-style commands. Finally, for
|
||||
blocks of code or blocks of text that need to be in "typewriter" font, use
|
||||
the block commands. Have a look at the following listing:
|
||||
|
||||
- \c \\a \n
|
||||
Use to refer to parameters or arguments in a running text, for example
|
||||
@@ -269,12 +279,12 @@
|
||||
a monospace, or typewriter, font. There are a few options
|
||||
- \c \\c for single words.
|
||||
- \c \<tt\> and \c \<\\tt\> for multiple words or phrases
|
||||
- The commands \c \\verbatim and \c \\endverbatim. Everything between these
|
||||
two commands will be put in a distinct block that stands out from the rest
|
||||
of the text.
|
||||
- The commands \c \\verbatim and \c \\endverbatim. Everything between
|
||||
these two commands will be put in a distinct block that stands out
|
||||
from the rest of the text.
|
||||
- The commands \c \\code and \c \\endcode do the same, but Doxygen will
|
||||
parse the contents and try to mark up the code to make it look a little bit
|
||||
nicer.
|
||||
parse the contents and try to mark up the code to make it look a
|
||||
little bit nicer.
|
||||
- <em>Emphasis</em>
|
||||
- \c \\e for single words.
|
||||
- \c \<em\> and \c \<\\em\> for phrases.
|
||||
@@ -294,23 +304,23 @@
|
||||
\ref commands_miscellaneous for \c \\ref). After you've defined the block
|
||||
to be a page, you can start writing the contents.
|
||||
|
||||
For more complicated pages, you might want to divide the page up in sections.
|
||||
Use the \c \\section command to define a new section. It takes the same
|
||||
arguments as \c \\page, namely the \c \<name\> and the <tt>(title)</tt>. If
|
||||
you need a deeper hierarchy you may use \c \\subsection and
|
||||
\c \\subsubsection, again, both with the same syntax. If you need to
|
||||
For more complicated pages, you might want to divide the page up in
|
||||
sections. Use the \c \\section command to define a new section. It takes the
|
||||
same arguments as \c \\page, namely the \c \<name\> and the
|
||||
<tt>(title)</tt>. If you need a deeper hierarchy you may use \c \\subsection
|
||||
and \c \\subsubsection, again, both with the same syntax. If you need to
|
||||
distinguish between sections in subsubsections, you are able to use
|
||||
\c \\paragraph, which takes the same arguments.
|
||||
|
||||
\note Before and after each of the commands above, you need to have an empty
|
||||
line so as to provide readability. It is not necessary to indent sections
|
||||
and subsections more than the normal two spaces, as long as you keep the
|
||||
section markers clear.
|
||||
line so as to provide readability. It is not necessary to indent
|
||||
sections and subsections more than the normal two spaces, as long as you
|
||||
keep the section markers clear.
|
||||
|
||||
\warning If you are entering the realm of subsections and sub-subsections,
|
||||
think about the nature of your page. Either it needs to be split up into
|
||||
multiple pages, or what you're writing is too complex and would be better
|
||||
off as a big tutorial on the Haiku website.
|
||||
multiple pages, or what you're writing is too complex and would be
|
||||
better off as a big tutorial on the Haiku website.
|
||||
|
||||
If you are creating multiple pages that are related, you will be able to
|
||||
structure them in a tree by using the \c \\subpage command. This will rank
|
||||
@@ -323,8 +333,9 @@
|
||||
Doxygen makes it possible to group certain members together. It is used
|
||||
in the BString class for example, where the members are grouped by what kind
|
||||
of operation they perform, such as appending, finding, etc. Defining groups
|
||||
is currently not as powerful as it could be, but if you use it inside classes,
|
||||
you will be fine if you follow the instructions presented in this section.
|
||||
is currently not as powerful as it could be, but if you use it inside
|
||||
classes, you will be fine if you follow the instructions presented in
|
||||
this section.
|
||||
|
||||
\note If you are looking on how to add classes to kits, see
|
||||
\ref commands_miscellaneous and have a look at the \c \\ingroup command.
|
||||
@@ -340,6 +351,7 @@
|
||||
These methods append things to the object.
|
||||
*/
|
||||
|
||||
|
||||
//! \@{
|
||||
|
||||
... names of the methods ...
|
||||
@@ -348,11 +360,11 @@
|
||||
\endverbatim
|
||||
|
||||
The block preceding the block opening marker, <tt>//! \@{</tt>, contains a
|
||||
\c \\name command and a paragraph that gives a description. The header block
|
||||
can be as long or short as you want, but please don't make it too long. See
|
||||
the \ref style section on how to effectively write group headers. The
|
||||
members that you want to belong to the group are between the group opening
|
||||
and closing markers.
|
||||
\c \\name command and a paragraph that gives a description. The header
|
||||
block can be as long or short as you want, but please don't make it too
|
||||
long. See the \ref style section on how to effectively write group headers.
|
||||
The members that you want to belong to the group are between the group
|
||||
opening and closing markers.
|
||||
|
||||
\note Group headers don't have a \c \\brief description.
|
||||
|
||||
@@ -373,15 +385,15 @@
|
||||
and virtually every member from a file, you might want to force it to hide
|
||||
certain things. If so, use the \c \\internal command. If you place this just
|
||||
after the block marker, the command will be hidden from documentation. Any
|
||||
further documentation or remarks you put inside the block will not be visible
|
||||
in the final documentation.
|
||||
further documentation or remarks you put inside the block will not be
|
||||
visible in the final documentation.
|
||||
|
||||
Images can be a valuable addition to documentation. To include ones you made,
|
||||
use the \c \\image command. It has the following prototype:
|
||||
Images can be a valuable addition to documentation. To include ones you
|
||||
made, use the \c \\image command. It has the following prototype:
|
||||
<tt>\\image \<format\> \<file\></tt>. The format is currently fixed at
|
||||
\c html. The file refers to the filename relative to the location of the
|
||||
documentation file. Any images you want to add should be in the same location
|
||||
as the dox file, so only the file name will suffice.
|
||||
documentation file. Any images you want to add should be in the same
|
||||
location as the dox file, so only the file name will suffice.
|
||||
|
||||
Modules are defined in the main book, and you can add classes to them by
|
||||
using the \c \\ingroup command. This commands adds the class to the module
|
||||
@@ -390,21 +402,21 @@
|
||||
future this might change.
|
||||
|
||||
Finally, it is a good idea to link between parts of the documentation. There
|
||||
are two commands for that. The first one is \c \\ref, which enable you to refer
|
||||
to pages, sections, etc. that you created yourself. The second one is \c \\link
|
||||
which refers to members. The first one is takes one word as an argument, the
|
||||
name of the section, and it inserts a link with the name of the title. \c \\link
|
||||
is more complex. It should always be accompanied by \c \\endlink. The first
|
||||
word between the two commands is the object that is referred to, and the
|
||||
rest is the link text.
|
||||
are two commands for that. The first one is \c \\ref, which enable you to
|
||||
refer to pages, sections, etc. that you created yourself. The second one is
|
||||
\c \\link which refers to members. The first one is takes one word as an
|
||||
argument, the name of the section, and it inserts a link with the name of
|
||||
the title. \c \\link is more complex. It should always be accompanied by \c
|
||||
\\endlink. The first word between the two commands is the object that is
|
||||
referred to, and the rest is the link text.
|
||||
|
||||
\section style Writing Guidelines
|
||||
|
||||
This final section will present guidelines for the actual writing of the
|
||||
documentation. Both the structure of the documentation, which sections to use
|
||||
when, and the style of the writing will be discussed. Before diverging into
|
||||
the requirements for file and class descriptions, member descriptions and
|
||||
pages, there are some general remarks that apply to all types of
|
||||
documentation. Both the structure of the documentation, which sections to
|
||||
use when, and the style of the writing will be discussed. Before diverging
|
||||
into the requirements for file and class descriptions, member descriptions
|
||||
and pages, there are some general remarks that apply to all types of
|
||||
documentation.
|
||||
|
||||
First of all, everything you write should be in <em>proper English
|
||||
@@ -413,18 +425,19 @@
|
||||
- It means that every sentence should at least have a
|
||||
subject and a verb (unless it's an imperative statement).
|
||||
- Also use the proper terminology. Remember, you are dealing with C++
|
||||
here, which means you should use the right names. So use \b method instead
|
||||
of function, and data member instead of variable (where appropriate).
|
||||
- Avoid informalism. Avoid constructs like 'if you want to disconnect the
|
||||
object', but rather use 'to disconnect the object'. Avoid familiarisms, or
|
||||
jokes.
|
||||
here, which means you should use the right names. So use \b method
|
||||
instead of function, and data member instead of variable (where
|
||||
appropriate).
|
||||
- Avoid informalism. Avoid constructs like 'if you want to
|
||||
disconnect the object', but rather use 'to disconnect the object'. Avoid
|
||||
familiarisms, or jokes.
|
||||
|
||||
\remarks It isn't the goal to create dry, legal-style documentation. Just
|
||||
try to find a balance. Read through documentation that's already been
|
||||
approved to get a hint of what you should be aiming for.
|
||||
\remarks If you are having a problem with phrasing certain things, put it
|
||||
down in such a way that it says everything it needs to. A proofreader might
|
||||
then be able to rephrase it to a better style.
|
||||
down in such a way that it says everything it needs to. A proofreader
|
||||
might then be able to rephrase it to a better style.
|
||||
|
||||
Throughout the documentation you might want to provide hints, warnings or
|
||||
remarks that might interrupt the flow of the text, or that need to visually
|
||||
@@ -432,9 +445,9 @@
|
||||
display remarks, warnings, notes and points of attention. You can use these
|
||||
commands in case you meet one or more of the following requirements:
|
||||
- The point is for a specific audience, such as beginners in the Haiku API.
|
||||
Notes on what to read first, or mistakes that may be made by beginners will
|
||||
not be for the entire audience, and such should be separated. These kinds of
|
||||
notes should be at the end of blocks.
|
||||
Notes on what to read first, or mistakes that may be made by beginners
|
||||
will not be for the entire audience, and such should be separated. These
|
||||
kinds of notes should be at the end of blocks.
|
||||
- The point needs to visually stand out. This is especially the case with
|
||||
remarks, but could also apply for other types.
|
||||
- The point is not completely relevant to the text and therefore should be
|
||||
@@ -443,40 +456,41 @@
|
||||
This listing shows which one to use for which situation:
|
||||
- \c \\attention
|
||||
- Used when the developer is bound to make a mistake, when the API is
|
||||
ambiguous. The difference between this and a warning is that warnings warn
|
||||
about things that are the developers fault, and attention blocks warn
|
||||
about things that might go wrong because of the way the API is structured.
|
||||
ambiguous. The difference between this and a warning is that
|
||||
warnings warn about things that are the developers fault, and
|
||||
attention blocks warn about things that might go wrong
|
||||
because of the way the API is structured.
|
||||
- Used to warn for abuse of the API that might be caused by the way the
|
||||
internals of the system are structured.
|
||||
- \c \\warning
|
||||
- Used to warn developers about using the API in a certain way. Warnings
|
||||
apply especially to new developers that aren't completely familiar with
|
||||
the API and that might want to abuse it. For example, the thread safety
|
||||
of BString requires a warning.
|
||||
apply especially to new developers that aren't completely familiar
|
||||
with the API and that might want to abuse it. For example, the
|
||||
thread safety of BString requires a warning.
|
||||
- \c \\note
|
||||
- Used to place references to other documentation that might not be
|
||||
directly related to the text. For example, BLooper will have a direct
|
||||
reference to BHandler in the class description, but BMessenger will be
|
||||
mentioned in a note because it does not directly influence the use of
|
||||
the class.
|
||||
directly related to the text. For example, BLooper will have a
|
||||
direct reference to BHandler in the class description, but
|
||||
BMessenger will be mentioned in a note because it does not directly
|
||||
influence the use of the class.
|
||||
- Can also be used for useful hints or notes that somehow need to stand
|
||||
out from the rest of the text.
|
||||
- \c \\remarks
|
||||
- Remarks are small notes that would interrupt the flow of the text. For
|
||||
example, if you in a text ignore a certain condition that is so extremely
|
||||
rare and uncommon, you can put a remark at the end of the text to tell
|
||||
that you have been lying.
|
||||
- Remarks interact with the text whereas notes add something unmentioned to
|
||||
it.
|
||||
example, if you in a text ignore a certain condition that is so
|
||||
extremely rare and uncommon, you can put a remark at the end of the
|
||||
text to tell that you have been lying.
|
||||
- Remarks interact with the text whereas notes add something unmentioned
|
||||
to it.
|
||||
|
||||
\subsection style_files File Descriptions
|
||||
|
||||
The design of Doxygen makes it very file oriented, and this might come off as
|
||||
inconvenient. At the moment, how to actually group the documentation is still
|
||||
under debate, but it does not change the requirement that a header needs to
|
||||
be documented before the members of that header can be documented. As such,
|
||||
the first documentation block in your \c dox file will be the block that
|
||||
describes the header. Examples:
|
||||
The design of Doxygen makes it very file oriented, and this might come off
|
||||
as inconvenient. At the moment, how to actually group the documentation is
|
||||
still under debate, but it does not change the requirement that a header
|
||||
needs to be documented before the members of that header can be documented.
|
||||
As such, the first documentation block in your \c dox file will be the block
|
||||
that describes the header. Examples:
|
||||
|
||||
\verbatim
|
||||
/*!
|
||||
@@ -485,6 +499,7 @@
|
||||
handling strings.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file SupportDefs.h
|
||||
\brief Defines basic types and definitions for the Haiku API.
|
||||
@@ -495,25 +510,26 @@
|
||||
The second element is the \c \\brief remark on what it contains. The first
|
||||
file defines the BString class and some global operators. You can see that
|
||||
reflected in the description. SupportDefs.h does not define classes, but
|
||||
rather a range of different functions and defines, so the text refers to that.
|
||||
rather a range of different functions and defines, so the text refers to
|
||||
that.
|
||||
|
||||
\remarks \\brief documentation for files is about what it \e implements, as
|
||||
header files are passive (whereas members and functions are active). Thus,
|
||||
use the third person form of the verb.
|
||||
header files are passive (whereas members and functions are active).
|
||||
Thus, use the third person form of the verb.
|
||||
|
||||
\subsection style_classes Class Descriptions
|
||||
|
||||
Classes are the basic building blocks in the Haiku API and as such have
|
||||
extensive documentation. This section will go over the actual class
|
||||
description. This section will present a list of items you should think about
|
||||
when writing the class description. This doesn't mean you'll have to include
|
||||
every item, it merely serves as a guiding principle that helps organise your
|
||||
thoughts. Have a look at the list:
|
||||
description. This section will present a list of items you should think
|
||||
about when writing the class description. This doesn't mean you'll have
|
||||
to include every item, it merely serves as a guiding principle that helps
|
||||
organise your thoughts. Have a look at the list:
|
||||
|
||||
-# The \c \\brief description is \b obligatory. This description describes
|
||||
what it is. For example, BDataIO: "Abstract interface for objects that
|
||||
provide read and write access to data." Note that this description is not
|
||||
a full sentence, but it does end with a period.
|
||||
provide read and write access to data." Note that this description is
|
||||
not a full sentence, but it does end with a period.
|
||||
-# One or more paragraphs that give a broad overview of what the class can
|
||||
do. Describe things like what it works on, when you want to use it, what
|
||||
advantage it might give over other directly related alternatives. Also
|
||||
@@ -524,29 +540,30 @@
|
||||
of the kit or the API. What objects does it work with, how it interacts
|
||||
with the servers, etcetera.
|
||||
-# One or more paragraphs that give a concrete example or use case. Keep it
|
||||
tidy and self contained. If you use code examples, make sure your examples
|
||||
adhere to Haiku's coding guidelines. Remember, an example can illustrate
|
||||
better than a few paragraphs of text.
|
||||
-# End with a list of references to other classes, functions, pages, etc. that
|
||||
might be of interest to the reader.
|
||||
tidy and self contained. If you use code examples, make sure your
|
||||
examples adhere to Haiku's coding guidelines. Remember, an example can
|
||||
illustrate better than a few paragraphs of text.
|
||||
-# End with a list of references to other classes, functions, pages, etc.
|
||||
that might be of interest to the reader.
|
||||
|
||||
When documenting classes, don't be to exhaustive. Avoid becoming a tutorial
|
||||
or a complete guide. This documentation is for reference only. If you want to
|
||||
enlighten the reader on bigger subjects, consider writing a separate
|
||||
or a complete guide. This documentation is for reference only. If you want
|
||||
to enlighten the reader on bigger subjects, consider writing a separate
|
||||
documentation page that connects the different points you want to make.
|
||||
|
||||
Also, you don't have to put in any groupings of members in class descriptions.
|
||||
If you want to do that, physically divide the members up in groups. Look at
|
||||
the \ref commands_grouping for the actual commands, and at \ref style_groups
|
||||
for help on writing group headers.
|
||||
Also, you don't have to put in any groupings of members in class
|
||||
descriptions. If you want to do that, physically divide the members up in
|
||||
groups. Look at the \ref commands_grouping for the actual commands, and at
|
||||
\ref style_groups for help on writing group headers.
|
||||
|
||||
\subsection style_members Members and Functions
|
||||
|
||||
Members and functions share the same basic Doxygen syntax, and they can be
|
||||
documented in a similar way. That's why this section deals with them together.
|
||||
Documenting members is probably the main thing you'll do when writing the
|
||||
actual documentation. There are some guidelines as to how, but the actual
|
||||
implementation probably differs per class. Keep the following points in mind:
|
||||
documented in a similar way. That's why this section deals with them
|
||||
together. Documenting members is probably the main thing you'll do when
|
||||
writing the actual documentation. There are some guidelines as to how, but
|
||||
the actual implementation probably differs per class. Keep the following
|
||||
points in mind:
|
||||
|
||||
-# To repeat a very important fact, the first line is a \c \\fn line. This
|
||||
line needs to match the declaration, which is in the source file. This
|
||||
@@ -556,31 +573,33 @@
|
||||
-# The first command is always the \c \\brief command. Give a short and
|
||||
clear description. The description starts with a capital letter and ends
|
||||
with a dot. Don't write the description saying what the method does,
|
||||
like "Starts the timer", but rather as what it will do: "Start the timer."
|
||||
-# If the brief description doesn't cover all of what the method or function
|
||||
does, then you can add a few paragraphs that explain it in more depth. Don't
|
||||
be too verbose, and use an example to illustrate points. Point out any
|
||||
potential misunderstandings or problems you expect developers to have, but
|
||||
don't repeat the class documentation too much.
|
||||
like "Starts the timer", but rather as what it will do: "Start the
|
||||
timer." -# If the brief description doesn't cover all of what the method
|
||||
or function does, then you can add a few paragraphs that explain it in
|
||||
more depth. Don't be too verbose, and use an example to illustrate
|
||||
points. Point out any potential misunderstandings or problems you expect
|
||||
developers to have, but don't repeat the class documentation too much.
|
||||
-# You are obliged to then document all the parameters. Use the \c \\param
|
||||
command for that. For the description, use a short phrase such as "The
|
||||
offset (zero based) where to begin the move." Note the capital and the dot.
|
||||
offset (zero based) where to begin the move." Note the capital and the
|
||||
dot.
|
||||
-# If the function is non-void, then you'll have to specify what it will
|
||||
return. In case of fixed values, have a look at \c \\retval. You'll use
|
||||
this one when the return type is a bool or a status_t. In case of something
|
||||
else, use \c \\return. You can also combine these two. For example, a
|
||||
method that returns a length (positive) or an error code (negative).
|
||||
this one when the return type is a bool or a status_t. In case of
|
||||
something else, use \c \\return. You can also combine these two. For
|
||||
example, a method that returns a length (positive) or an error code
|
||||
(negative).
|
||||
-# Use \c \\see if you have any references to other methods, classes or
|
||||
global functions. At least document all the overloaded methods. Also add
|
||||
methods that do the opposite of this method, or methods that are intimately
|
||||
related.
|
||||
methods that do the opposite of this method, or methods that are
|
||||
intimately related.
|
||||
|
||||
In case of overloaded members, you'll need to make a decision. If you need to
|
||||
copy too much information, you might resort to putting it in one paragraph
|
||||
with the text "This is an overloaded member function, and differs from
|
||||
\<name\> only by the type of parameter it takes." That will keep the copying
|
||||
down and will point developers right to the place where they can get more
|
||||
documentation.
|
||||
In case of overloaded members, you'll need to make a decision. If you need
|
||||
to copy too much information, you might resort to putting it in one
|
||||
paragraph with the text "This is an overloaded member function, and differs
|
||||
from \<name\> only by the type of parameter it takes." That will keep the
|
||||
copying down and will point developers right to the place where they can get
|
||||
more documentation.
|
||||
|
||||
Again, like class descriptions, you'll have to find a good middle-ground
|
||||
between too much information, and too little. Again, write for the broadest
|
||||
@@ -591,7 +610,7 @@
|
||||
|
||||
This section helps you document (member) variables and defines that define
|
||||
constants, as well as enumerations and their values. If you need to document
|
||||
a \c \#define macro that takes arguments, have a look at \ref style_members .
|
||||
a \c \#define macro that takes arguments, have a look at \ref style_members
|
||||
|
||||
The \c \\brief description of all these types follow a similar structure.
|
||||
They are a short phrase that mention what the variable contains. Example:
|
||||
@@ -601,10 +620,11 @@
|
||||
\var char* BString::fPrivateData
|
||||
\brief BString's storage for data.
|
||||
|
||||
This member is deprecated and might even become \c private in future releases.
|
||||
This member is deprecated and might even become \c private in future
|
||||
releases.
|
||||
|
||||
If you are planning to derive from this object and you want to manipulate the
|
||||
raw string data, please have a look at LockBuffer() and UnlockBuffer().
|
||||
If you are planning to derive from this object and you want to manipulate
|
||||
the raw string data, please have a look at LockBuffer() and UnlockBuffer().
|
||||
*/
|
||||
\endverbatim
|
||||
|
||||
@@ -627,28 +647,28 @@
|
||||
what the message constant stands for, and where it might be send from and
|
||||
where it might be received.
|
||||
|
||||
Enumerations can either be anonymous or named. In case of the latter, you can
|
||||
give a description of the enumeration in a documentation block that starts
|
||||
with an \c \\enum command, followed by the name of the enumeration. If the
|
||||
enumeration is within the scope of a class, prepend the classname and the
|
||||
scope indicator. In case of an anonymous enum, you can only document the
|
||||
Enumerations can either be anonymous or named. In case of the latter, you
|
||||
can give a description of the enumeration in a documentation block that
|
||||
starts with an \c \\enum command, followed by the name of the enumeration.
|
||||
If the enumeration is within the scope of a class, prepend the classname and
|
||||
the scope indicator. In case of an anonymous enum, you can only document the
|
||||
individual members (which you should do for the named enumerations as well),
|
||||
which can be done within code blocks that start with the \c \\var command.
|
||||
Doxygen will know that it's an enumeration value, don't worry about mixups.
|
||||
If the enumeration value is within a class, prepend the classname and scope
|
||||
indicator. Give a short description of the value, which methods react to it,
|
||||
where it might be used, etcetera. Don't go as far as to copy information too
|
||||
much. For example, if you use an enumeration in only one class and you
|
||||
indicator. Give a short description of the value, which methods react to
|
||||
it, where it might be used, etcetera. Don't go as far as to copy information
|
||||
too much. For example, if you use an enumeration in only one class and you
|
||||
document the possible values there, then don't do that again for the
|
||||
enumeration documentation: rather just refer to it. That sort of documentation
|
||||
belongs to the class description, not to the enumeration.
|
||||
enumeration documentation: rather just refer to it. That sort of
|
||||
documentation belongs to the class description, not to the enumeration.
|
||||
|
||||
\subsection style_groups Groups
|
||||
|
||||
If you subdivide members of classes into groups, you have the ability to apply
|
||||
some general information that will be listed above the listing of the members
|
||||
in that group. See the section \ref commands_grouping on how to define groups.
|
||||
This section is on what to put in the header block.
|
||||
If you subdivide members of classes into groups, you have the ability to
|
||||
apply some general information that will be listed above the listing of the
|
||||
members in that group. See the section \ref commands_grouping on how to
|
||||
define groups. This section is on what to put in the header block.
|
||||
|
||||
First of all, it's probably a good idea to give your group a name. This name
|
||||
will be printed as a title and will enhance the clarity of what the group
|
||||
@@ -658,10 +678,10 @@
|
||||
|
||||
It's possible to add one or two paragraphs of information. These paragraphs
|
||||
should contain some quick notes on which of the members in that group to use
|
||||
for what purpose. See it as a quick subdivision that a developer could use as
|
||||
a guide to see which method he actually wants to use. Don't go on describing
|
||||
the methods in detail though, that's what the member documentation is about.
|
||||
Have a look at the example:
|
||||
for what purpose. See it as a quick subdivision that a developer could use
|
||||
as a guide to see which method he actually wants to use. Don't go on
|
||||
describing the methods in detail though, that's what the member
|
||||
documentation is about. Have a look at the example:
|
||||
|
||||
\verbatim
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user