Packages:
phpDocumentor
HTML_TreeMenu
Converters
Cpdf
XML_Beautifier
Smarty
Tutorials/Manuals:
Package-level:
- phpDocumentor Guide to Creating Fantastic Documentation
- phpDocumentor Quickstart
- Source code for sample1.php
- Source code for sample2.php
- Source code for sample3.php
- phpDocumentor Tutorial
- Documentable PHP Elements
- phpDocumentor Tutorials
- phpDocumentor Manual
- phpDocumentor tags
- @abstract
- @access
- @author
- @category
- @copyright
- @deprecated
- @example
- @final
- @filesource
- @global
- @ignore
- @internal
- @license
- @link
- @method
- @name
- @package
- @param
- @property
- @return
- @see
- @since
- @static
- @staticvar
- @subpackage
- @todo
- @tutorial
- @uses
- @var
- @version
- phpDocumentor Inline tags
- inline {@example}
- inline {@id}
- inline {@internal}}
- inline {@inheritdoc}
- inline {@link}
- inline {@source}
- inline {@toc}
- inline {@tutorial}
- phpDocumentor tags
- phpDocumentor Quickstart
Files:
subpackage DescHTML
subpackage DocBlockTags
subpackage Errors
subpackage InlineTags
subpackage Links
subpackage ParserData
subpackage ParserDocBlock
subpackage ParserElements
subpackage Parsers
subpackage setup
subpackage Tutorial
subpackage WordParsers
Prev | Next |
Elements of PHP source that phpDocumentor can automatically document
Authors:
by Joshua Eichorn
by Gregory Beaver by Chuck Burgess
Table of Contents
- Introduction to Documentable Elements
Procedural Elements
include/require/include_once/require_once statements
define statements
function declarations
global variables
Class Elements
DocBlock inheritance
class variables
class methods
Introduction to Documentable Elements
phpDocumentor is capable of automatically documenting include statements, define statements, functions, procedural pages, classes, class variables, and class methods.
Procedural Elements
From phpDocumentor's perspective, the basic container for procedural elements [as in real life] is the file that contains them. To reflect this, it is possible to document information about the entire contents of a file. This is accomplished through the use of a page-level DocBlock [see DocBlocks for basic information on what a DocBlock is]. A page-level DocBlock is the only DocBlock that cannot precede the element that it is documenting, as there is no way to precede a file. To solve this issue, the way phpDocumentor finds a page-level DocBlock is to parse the first DocBlock in a file as the page-level DocBlock, with certain conditions.
This last example has one DocBlock, and it is the first DocBlock in a file, but it is not a Page-level DocBlock. How can phpDocumentor tell the difference between a Page-level DocBlock and any other DocBlock? Simple:
In phpDocumentor version 1.2.2, a Page-level DocBlock is the first DocBlock in a file if it contains a @package tag. However, this example will raise a warning like WARNING in test.php on line 8: Page-level DocBlock precedes "define almost", use another DocBlock to document the source element. You can eliminate the warning by adding documentation to the define as follows:
Now, the page has its documentation, and the define has its own documentation.
So, a DocBlock is a page-level DocBlock IF AND ONLY IF it is both:
The first DocBlock in a file
One of:
Contains a @package tag
Immediately followed by another DocBlock for any documentable PHP element this is deprecated, always use a @package tag
A Page-level DocBlock may have any of the standard phpDocumentor Tags [see Standard phpDocumentor Tags] plus the following tags:
@package
@subpackage
phpDocumentor will not document a file like the first example, there must be at least one documentable PHP element in the file. |
include/require/include_once/require_once statements
phpDocumentor extracts the filename and attempts to link to documentation for that filename if possible. Include statements may only have any of the Standard phpDocumentor Tags
phpDocumentor will attempt to locate the included file in the list of files parsed, and if found will make a link to that file's documentation.
define statements
A define statement's DocBlock may have any of the standard phpDocumentor Tags [see Standard phpDocumentor Tags] plus the following tag:
@name
function declarations
A function's DocBlock may have any of the standard phpDocumentor Tags [see Standard phpDocumentor Tags] plus the following tags:
@global
@param
@return
@staticvar
inline {@source}
global variables
A global variable's DocBlock may have any of the standard phpDocumentor Tags [see Standard phpDocumentor Tags] plus the following tag:
@name
Class Elements
A class's DocBlock may have any of the standard phpDocumentor Tags [see Standard phpDocumentor Tags] plus the following tags:
@abstract
@package
@subpackage
@static
DocBlock inheritance
New in version 1.2.0, DocBlock's are inherited by child classes, variables, and methods. There are a few simple rules for inheritance:
tags @author, @version, and @copyright are automatically inherited unless explicitly specified in the DocBlock
As in previous versions, @package and @subpackage are inherited unless explicitly specified in the DocBlock. We recommend that you explicitly use @package and @subpackage for every class to avoid problems with name conflicts that may arise
If there is no short description, the short description will be inherited.
If there is no long description, the long description will be inherited.
If there is a long description, and you still want to inherit the parent's description, use inline {@inheritdoc}
/**
* short desc
*
* long desc
* @package test
* @author me
* @version 1.0
* @abstract
* @copyright never
*/
class parclass
{
}
// inherits entire DocBlock minus @abstract
class child1 extends parclass
{
}
// inherits DocBlock minus @abtract, short desc
/**
* overriding short desc
*/
class child2 extends parclass
{
}
// inherits @author, @version, @copyright, @package
/**
* overriding short desc
*
* overriding long desc
*/
class child3 extends parclass
{
}
// inherits @version, @copyright, @package
/**
* overriding short desc
*
* overriding long desc
* @author you
*/
class child4 extends parclass
{
}
class variables
A class variable's DocBlock may have any of the standard phpDocumentor Tags [see Standard phpDocumentor Tags] plus the following tag:
@var
class methods
A method's DocBlock may have any of the standard phpDocumentor Tags [see Standard phpDocumentor Tags] plus the following tags:
@abstract
@global
@param
@return
@static
@staticvar
inline {@source}
Prev | Up | Next |
phpDocumentor Tutorial | phpDocumentor Tutorial | phpDocumentor Tutorials |
Documentation generated on Mon, 11 Mar 2019 15:50:05 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.