This is a continuation of my previous post - Dolphin 8: new programming approaches, but with accent on proper code commenting. Proper code commenting allows to generate more structured, clean and easy to read programmers documentation.
We are using Doxygen to generate documentation from source code. This guide highlights useful Doxygen commands to use in PHP code comments to generate nice Dolphin programming documentation.
This is guideline for Dolphin developers, but it should be helpful for other developers who care about writing the proper comments in own code.
Make sure that every file has the following header:
<?php defined('BX_DOL') or die('hack attempt'); /** * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/ * CC-BY License - http://creativecommons.org/licenses/by/3.0/ * * @defgroup DolphinCore Dolphin Core * @{ */and the following footer (closing @defgroup definition):
/** @} */@defgroup can vary depending on particular files, refer to the next section for more info.
Use the following groups and subgroups in header of every file:
@defgroup DolphinCore Dolphin Core
@defgroup DolphinView Dolphin Core Representation classes @ingroup DolphinCore
@defgroup DolphinEndUser Dolphin Core End User Pages @ingroup DolphinCore
@defgroup DolphinStudio Dolphin Studio
@defgroup MyModule Full name of MyModule @ingroup DolphinModules
For lists use the following format:
My list: - one - two - threeso every list item must begin with dash (-)
For multi indented list use the following format:
- first - a - b - second - c - d
Code blocks must be enclosed in @code and @endcode tags.
For example:
@code echo "Hello World!"; @endcode
/** * My class * * My class desc goes here. * * @section example Example of usage: * @code * $o = new MyClass(); * @endcode * * @section alerts Alerts: * myalert - with the following parameters * - $iObjectId - my content id * - $iSenderId - user who performed an action with my content * */Standard sections are:
To make line break in documentation you need to insert double line break in the code.
For example, the following code:
My class code It is used for some purpose.will be transformed to:
My class codeIt is used for some purpose.So, to make proper formatting you need to write it the following way:
My class code It is used for some purpose.
Also you can use @n to force new line anywhere.
This is ready documentation pages, so you can add page comment block somewhere in the code and documentation page will be generated.
There are some predefined documentation pages where you can add content. For example "Objects" documentations page consists of references to all "Objects".
This is an example on how to add content to "Objects" documentation page:
/** * @page objects * @section comments Comments * @ref BxDolCmts */
make sure that functions/class methods comments have the following format:
/** * Description is here. * @param mixed $mixedData function data to process * @param int $iDataType function data type * @return abra kadabra */ function sample ($mixedData, $iDataType) { }
Class comment must have description of general class functionality and the following sections, if they have place
Refer to BxDolCmts class for examples.
Make sure that one string comments for class properties, defines and global variables are formatted like this:
define('BX_DATA_INT', 3); ///< integer date type define('BX_DATA_FLOAT', 4); ///< float date type define('BX_DATA_HTML', 5); ///< HTML date type
If one line comments are written using this format - then comment is included in autogenerated documentation.
where i know it is the intent to lighten the load on the dolphin environment, see more
define('BX_DATA_INT', 3); ///< integer date type
the weight of your comment is nearly equal to that of your required source?
source = 25 characters
comment = 24 characters
so with this concept you are increasing the file size on all declared variables and constants by nearly 100%
so lets look at even the use of the BX_ could you not write a constant that would prepend the BX_ and take out those three characters being declared each time?
or substitue see more
im asking a question, are you able to provide the answer?
How could he possibly know anything about it when you yourself just wrote it a few days ago.