libSBML 5.3.0 Python API

Coding conventions for libSBML

The following is a collection of guidelines for libSBML authors and other interested persons to follow when writing libSBML code and documenting it.

General guidelines
Summary of commonly-used Doxygen commands in libSBML
Guidelines for documenting .h files
Guidelines for documenting .cpp files

LibSBML's application programming interface (API) is documented using a combination of tools: for C++, C and Python, we use the open-source software tool Doxygen, written by Dimitri van Heesch, and for the Java API, we use Javadoc. In addition to these main tools, we use several scripts to massage the output of SWIG to produce better documentation. The guidelines presented in this section are oriented towards explaining how to organize code comments such that Doxygen can produce good output, yet simultaneously make the comments in the code be readable on their own.

General guidelines

Summary of commonly-used Doxygen commands in libSBML

The following is a summary of the doxygen commands we have found useful so far in documenting libSBML. This is only intended as a quick orientation; they are illustrated in the other sections below, and the complete details of their definitions and use can be found online at the Doxygen website.

Command Meaning

@file Defines the name of the current file.

@brief Provides a one-sentence description of the entity being described (a file, a class, etc.).

@author Names the author of the entity being described (a file, a class, etc.).

@c Puts the following word in typewriter ("code") font. To style more than one word, use <code>the words</code>. If you need to put something that contains HTML tags in typewriter font, use the <code>the words</code> form, and use the HTML character codes &lt; and&gt; to embed the openening '<' and '>' characters inside the words.

@em Puts the following word in italic font, for emphasis. To put multiple words in italics, use <em>the words</em>.

@n Forces a newline, like HTML's <br>.

@p Puts the following word in typewriter ("code") font. This form is preferred when the word is a parameter to a method or function.

@li Starts (or continues) a bullet list. You can insert the first @li in a comment, and the item will continue until a paragraph break or the next @li command. (Note: even though Doxygen will also recognize hyphens at the beginning of a line as starting a list item, avoid using that approach in favor of the @li command.

@class Declares that the following documentation block refers to the named class. Useful only when the block does not immediately precede the class definition (e.g., when it's at the beginning of the file).

@param Declares a parameter to a method or function. The first word following @param will be the name of the parameter, and the rest of the text (up to a period or blank) will be used as the description.

@return Declares the return value from a method or function.

@see Formats a reference to another entity in the documentation. Commonly used to refer to related classes or methods.

@note Formats the following paragraph with the heading "Note:". Useful to call out something special about a class, function, file or other entity, such as a behavior that should be brought to the attention of users or a note about API changes compared to previous versions of the software or SBML. As a convention, please put @note blocks at the end of a documentation block, for uniformity in the API documentation.

@warning Formats the following paragraph with the heading "Warning:". This is a stronger statement than @note, and is useful to call attention to backward-incompatible changes or potentially error-provoking situations. As a convention, please put @warning blocks at the end of a documentation block, for uniformity in the API documentation.

@bug Formats the following paragraph with the heading "Bugs:". Useful to indicate that something is known to be a problem in some part of the code. As a convention, please put @bug blocks at the end of a documentation block, for uniformity in the API documentation.

Many HTML commands will work in comments for Doxygen. For example, a common one is the a tag for linking text to a URL, as in <a href="http://sbml.org">home page</a>.

Guidelines for documenting .h files

It is important to note that the documentation of global functions, variables, typedefs, and enums will only be included in the output of Doxygen if the file they are in is documented as well.

Guidelines for documenting .cpp files

The .cpp files can be handled very similarly to the .h files described above. You may use the same header template shown in the previous section about .h files, and all the same guidelines apply.

The principal difference is that it is not necessary to repeat the class description placed in the .h file, nor indeed is it necessary to copy or recreate the documentation of class methods. As already mentioned, when the API manual is generated by Doxygen, it will use the comments from the .h file as the source of the documentation for the class and methods.

However, it is important to document functions, because these are not defined by the .h files. This is especially important for the C wrappers around the C++ methods. All the same documentation conventions described so far apply to describing functions. The following example provides an illustration:

/**
 * Creates a new CompartmentType with the given @p id and @p name attribute
 * values.
 *
 * In SBML Level 2 and beyond, the identifier attribute of a
 * CompartmentType is required to have a value, but the name is optional.
 * Programs calling this function can legitimately use an empty string for
 * the @p name parameter.
 *
 * @param sid the value to assign as the identifier of this CompartmentType
 * @param name the value to assign as the name of this CompartmentType
 *
 * @return a pointer to the newly created CompartmentType_t structure.
 */
LIBSBML_EXTERN
CompartmentType_t *
CompartmentType_createWith (const char *sid, const char *name);

Miscellaneous Doxygen notes




HTML documentation generated on Tue Dec 20 01:39:47 2011 using Doxygen 1.6.3.