PHP Code Documentation
The API documentation of Contrexx is automatically generated based on its PHP source code using the documentation tool phpDocumentor 2. To ensure that the generation of the documentation works flawlessly, the whole source of Contrexx has to be documented properly. This is done using so-called DocBlocks.
Refer to the documentation of phpDocumentor 2 on how to properly document the PHP source code.
See also Wikipedia article about PHPDoc.
Guidelines
- First, Study the introduction What is a DocBlock?
- Then use at least the mandatory Tags as listed below to properly document the code
- Add useful (see Best practices for writing code comments) inline code documentation
Example
Example file-level-, exception- & class-DocBlock for a class of component Config
:
Mandatory tags
File-level / namespace / class / interface / trait
property / constant
require(_once) / include(_once)
@ignore
(as all classes should get loaded by the ClassLoader anyway)
Note
Add comment about the specific reason why a require(_once) / include(_once) has been used*
function (including methods)
Recommended / useful tags
@todo
@deprecated
@see
@uses
@since
If the structural element is public, then use this tag to document the cloudrexx release since this feature became available@inheritDoc
See section #Inheritance below
all other tags are nice to have and should be set where useful (for example author of a function if not the same as the author of the class)
Inheritance
phpDocumentor does automatically inherit all documentation of parent elements (see Inheritance at phpDocumentor). So in theory no additional documentation is required on inherited elements (classes, interfaces, methodes, etc.). However to indicate a local element as documented we shall do so by adding a DocBlock as follows:
However, if the local element has been modified and must therefore be documented, we do only have to document the changed parts of it (@param
, @global
, @return
and @throws
) and if required the description itself. For the description, the special inline tag {@inheritDoc}
can be used to import the description of the parents DocBlock. Example: