Command-line method:
in the Phpdocumentor directory, the input phpdoc–h gets a detailed parameter list, with several important parameters as follows:
-f file name to be parsed, multiple files separated by commas
-D directories to parse, multiple directories separated by commas
The storage path of the document generated by-t
-O Output document format, structure is output format: Converter name: Template directory.
For example: Phpdoc-o html:frames:earthli-f test.php-t Docs
Web Interface Generation
in the new Phpdoc, in addition to generating documents at the command line, you can also manipulate the documentation on the client browser by placing the contents of the Phpdocumentor in the Apache directory so that it can be accessed through the browser, and then the following interface is displayed:
Click the Files button to select the php file or folder you want to process, and you can also ignore the processing of some files by specifying the file to ignore under this interface.
Then click the Output button to select the location and format of the generated document.
Finally click Create,phpdocumentor will automatically start to generate the document, the bottom will show the progress and status of the build, if successful, will show
Total documentation time:1 seconds
Done
Operation completed!!
We can then view the generated document, and if it is in PDF format, the name defaults to Documentation.pdf.
Add a specification comment to your PHP code
Phpdocument is a document generated from the comments in your source code, so the process of annotating your program is the process of documenting it.
From this point of view, Phpdoc prompted you to develop good programming habits, as far as possible use of specifications, clear text for your program to make comments, and more or less also avoid the subsequent preparation of documents and document updates are not synchronized with some of the problems.
In Phpdocumentor, comments are divided into document and non-document comments.
A document annotation is a multiline comment that is placed in front of a particular keyword, which is a keyword that can be phpdoc analyzed, such as Class,var, and is available in Appendix 1.
Comments that are not in front of the keyword or that are not canonical are referred to as Phpdoc comments and will not be parsed by the analysis and will not appear in the API text that you produce.
How to write a document comment:
All of the documentation comments are a multiline comment started by/**, called DocBlock in Phpdocumentor, and DocBlock refers to the Help information written by a software developer about a keyword. So that other people can know through it the specific purpose of this keyword, how to use. Phpdocumentor stipulates that a DocBlock contains the following information:
1. Functional Description Area
2. Detailed Description Area
3. Tagged tag
the first line of the document annotation is the functional description area, which is typically a concise description of the function of the class, method, or function, and the body of the feature brief is displayed in the indexed area in the resulting document. The contents of a feature description area can be passed through a blank line or. To end
.
is a blank line after the functional description area, followed by a detailed description area. This section is mainly about the function of your API, use, if possible, can also use examples, etc. In this section, you should highlight the usual uses of your API functions or methods, usage, and indicate whether it is cross-platform (if it is involved), you need to differentiate yourself from the common information about the platform-related information, usually in a separate line, and then write notes on a particular platform or special information, this information should be sufficient so that your readers can write the appropriate test information, such as boundary conditions, parameter ranges, breakpoints, and so on.
Then it is also a blank line, followed by the document tag tag, indicating some technical information, mainly the invocation of the parameter type, the return value extremely type, the inheritance relation, the related method/function and so on.
Tags such as <b> <code> can also be used in
documentation comments, please refer to Appendix two for more information.
An example of a document annotation
/**
* Function Add, achieve two number of addition
*
* A simple addition calculation, the function receives two numbers A, B, returns their and C
*
* @param int addends
* @param int summand
* @return Integer
*/
function Add ($a, $b)
{
return $a + $b;
}
generate documentation as follows:
ADD
integer Add (int $a, int $b)
[Line 45]
function Add to achieve the addition of two numbers
Constants A simple addition calculation, the function accepts two numbers A, B, returns their and C
Parameters
int $a-addends
int $b-Summand
Document Tags:
the document tag is used to refer to keywords that the tag can be decorated with, or other document tags.
all document tags are preceded by @ at the end of each line. If the mark in the middle of a passage comes out @, the mark will be ignored as plain content.
@access
Use range: Class,function,var,define,module
This tag is used to indicate access rights for a keyword: private, public, or proteced
@author
indicates the author
@copyright
Use range: Class,function,var,define,module,use
Specify copyright Information
@deprecated
Use range: Class,function,var,define,module,constent,global,include
indicate unused or deprecated keywords
@example
the tag to parse a piece of file content and highlight them. Phpdoc will attempt to read the contents of the file from the file path that is marked
@const
Use range: Define
is used to indicate define constants in PHP
@final
Use range: Class,function,var
indicates that the keyword is a final class, method, property, and prohibits derivation and modification.
@filesource
and example are similar, except that the tag will directly read the contents of the currently parsed PHP file and display it.
@global
indicates the global variable referenced in this function
@ingore
Used to ignore the specified keyword in the document
@license
the corresponds to the <a> in the HTML tag, first the URL, and then the content to be displayed
such as <a href= "http://www.baidu.com" > Baidu </a>
can write @license http://www.baidu.com Baidu
@link
similar to license
But you can also refer to any one of the keywords in the document through link
@name
Specifies an alias for the keyword.
@package
Usage: page-level-> define,function,include
class-Level->class,var,methods
is used to logically divide one or several keywords into one group.
@abstrcut
indicates that the current class is an abstract class
@param
Indicates the parameters of a function
@return
indicates the return point of a method or function
@static
indicates that the closed word is static.
@var
indicates the variable type
@version
indicates version information
@todo
Identify areas that should be improved or not implemented
@throws
indicates a possible error exception that may be thrown by this function, which occurs extremely
mentioned above, ordinary document tag tags must be at the beginning of each line at the @ mark, in addition, there is a tag called inline tag, expressed in {@}, specifically include the following:
{@link}
usage with @link
{@source}
Displays the contents of a function or method
Some annotation specifications
A. Annotations must be
/**
* XXXXXXX
*/
The form
B. For functions that reference global variables, you must use the glboal tag.
C. For variables, the type must be marked with VAR (int,string,bool ...). )
D. Functions must indicate their parameters and return values through param and returns tags
E. For the occurrence of two or more than two keywords, to pass Ingore ignored redundant, only one can
F. Where other functions or classes are invoked, link or other tags are linked to the appropriate section to facilitate the reading of documents.
G. Use of non-document annotations where necessary to improve code readability.
H. Descriptive content as concise as possible, using phrases rather than sentences.
I. Global variables, static variables and constants must be indicated with the corresponding markup
Summarize
Phpdocumentor is a very powerful automated document generation tool that helps us write specification annotations, generate Easy-to-understand, structured documents, and help with our code upgrades, maintenance, and handover.
For more detailed instructions on phpdocumentor, you can go to its official website
Two examples:
instance One
Example Two