Command Line Method:
Enter
Phpdoc-H
A detailed parameter table is displayed. Several important parameters are as follows:
-F name of the file to be analyzed. Multiple files are separated by commas.
-D directory to be analyzed. multiple directories are separated by commas.
-T: storage path of the generated document
-O output file format. The structure is output format: converter name: Template directory.
Example: phpdoc-o html: frames: earthli-F test. php-T docs
Web Interface Generation
In the new phpdoc, in addition to generating documents under the command line, you can also generate documents on the client browser, the specific method is to put the content of phpdocumentor under the Apache directory so that it can be accessed through a browser. The following interface is displayed after access:
Click the files button and select the PHP file or folder to be processed. You can also specify the files
Ignore to ignore the processing of some files.
Click the output button to select the path and format of the generated document.
Finally, click Create. The phpdocumentor automatically starts generating the document. The progress and status of the generated document are displayed at the bottom.
Total documentation time: 1 seconds
Done
Operation completed !!
Then, we can use the generated document. If it is in the simplified format, it is named documentation.pdf.
Add standard comments to PHP code
Phpdocument is to generate a document from the comments of your source code. Therefore, the process of commenting your program is the process of compiling the document.
From this point on, phpdoc prompts you to develop good programming habits, try to use specifications, clear text for your program to make comments, at the same time, it also avoids the problem of non-sync preparation of documents and updates later.
In phpdocumentor, annotations are classified into document comments and non-document comments.
Document comments are multi-line comments placed before specific keywords. specific keywords refer to keywords that can be analyzed by phpdoc, such as class and var. For details, refer to Appendix 1.
Comments that are not preceded by keywords or are not standardized are called non-document comments. These comments will not be analyzed by phpdoc or appear in your generated API text.
How to Write document comments:
All document comments are a multi-line comments starting with/**, which is called docblock in phpdocumentor,
Docblock refers to the help information about a keyword written by software developers, so that others can know the specific purpose of this keyword and how to use it. Phpdocumentor specifies that a docblock contains the following information:
1. Function overview Area
2. Detailed description area
3. Tag
The first line of document comments is the function description area. The body is generally a concise description of the functions of this class, method, or function, the body of the function description is displayed in the index area in the generated document. The content in the function description area can be passed through an empty line or.
To end
There is a blank line behind the function description area, followed by a detailed description area ,.
This section describes in detail the functions and usage of your API. If possible, it can also be used as an example. In this section, you should focus on the common usage and usage of your API functions or methods, and specify whether it is cross-platform (if involved). For platform-related information, you need to treat it differently from general information. The common practice is to set up another line, and then write the precautions or special information on a specific platform. This information should be sufficient, this allows your readers to write test information, such as boundary conditions, parameter ranges, and breakpoints.
It is also a blank line, followed by the tag of the document, indicating some technical information, mainly the call parameter type, the return value is extremely type, inheritance relationship, related methods/functions.
For more information about document tagging, see Section 4: Document tagging.
For more information, see appendix 2.
Example of a document comment
/**
* Add the function to add two numbers.
*
* In a simple addition calculation, the function accepts two numbers A and B and Returns their and C
*
* @ Param int Addition
* @ Param int add count
* @ Return integer
*/
Function add ($ A, $ B)
{
Return $ A + $ B;
}
The generated document is as follows:
Add
Integer add (INT $ A, int $ B)
[Line 45]
Function add to add two numbers
Constants is a simple addition calculation. The function accepts two numbers A and B and Returns their and C
Parameters
• Int $ A-addend
• Int $ B-Number of added parts
Document Tag:
The scope of use of a document tag is a keyword that can be used to modify a document tag, or other document tag.
All document tags are in each line *
It starts. If @ is marked in the middle of a passage, the mark will be ignored as common content.
@ Access
Usage scope: Class, function, VAR, define, Module
Indicates the access permission for a keyword: private, public, or proteced.
@ Author
Specify author
@ Copyright
Usage scope: Class, function, VAR, define, module, use
Copyright information
@ Deprecated
Usage scope: Class, function, VAR, define, module, constent, global, include
Specify unnecessary or obsolete keywords
@ Example
This tag is used to parse the content of a file and highlight it. Phpdoc will try to read the file content from the file path marked
@ Const
Scope of use: Define
Used to specify the define constant in PHP
@ Final
Usage scope: Class, function, VAR
Specifies that a keyword is a final class, method, or attribute, and cannot be derived or modified.
@ Filesource
Similar to example, however, this tag will directly read and display the content of the currently resolved PHP file.
@ Global
Specifies the global variables referenced in this function.
@ Ingore
Used to ignore specified keywords in the document
@ License
It is equivalent to <A> in an HTML Tag, first the URL, and then the content to be displayed.
For example, <a href = "http://www.baidu.com"> Baidu </a>
Can write @ license http://www.baidu.com
Baidu
@ Link
Similar to license
However, you can refer to any keyword in the document through link.
@ Name
Specify an alias for the keyword.
@ Package
Scope of use: page-> define, function, include
Class-> class, VAR, Methods
It is used to logically group one or more keywords into one group.
@ Shortcut
Indicates that the current class is an abstract class.
@ Param
Specify the parameters of a function.
@ Return
Specifies the return value of a method or function.
@ Static
Indicates that the word is static.
@ VaR
Variable type
@ Version
Specify version information
@ Todo
Specify the areas to be improved or not implemented
@ Throws
Indicates the error exception that this function may throw.
As mentioned above, the mark of common documents must start with @ at the beginning of each line. In addition, there is also a Mark called inline tag, which is represented by {@}, including the following:
{@ Link}
Usage: @ Link
{@ Source}
Display the content of a function or Method
Some annotation specifications
A. The comment must be
/**
* Xxxxxxx
*/
Format
B. The glboal mark must be used for functions that reference global variables.
C. For variables, you must use VaR to mark their types (INT, String, bool ...)
D. The function must specify its parameters and return values through PARAM and return tags.
E. For keywords that appear twice or more times, ignore unnecessary keywords through ingore and retain only one keyword.
F. When other functions or classes are called, link or other markup should be used to link to the corresponding part for easy reading of the document.
G. Use non-document comments as necessary to improve ease of coding.
H. The descriptive content should be as concise as possible and use phrases instead of sentences as much as possible.
I. global variables, static variables and constants must be marked with corresponding descriptions
Summary
Phpdocumentor is a very powerful Automatic Document generation tool. It helps us write standard comments, generate easy-to-understand and well-structured documents, and upgrade and maintain our code, the handover and so on are of great help.
For more details about phpdocumentor, visit its official website.
Http://manual.phpdoc.org/check
Two examples:
Http://pear.php.net/package/PhpDocumentor/docs/latest/phpDocumentor/tutorial_sample2.pkg.html
Http://pear.php.net/package/PhpDocumentor/docs/latest/phpDocumentor/tutorial_sample3.pkg.html