Javadoc Annotation Specification

Source: Internet
Author: User

Part excerpt from: http://kelaocai.iteye.com/blog/227822

A. Java documentation

Comment Line
*/* ... * * Comment several lines
/** ... * * Comment several lines and write to Javadoc document

Usually the multiline notation of this comment is as follows:

/**
* .........
* .........
*/

javadoc-d Document storage directory-author-version source file name. java
This command compiles a Java source file named "source file name. Java" and stores the resulting document in the directory specified in the "document Directory" where the index.html is the first page of the document. -author and-version two options can be omitted.

Two. Format of document Annotations 1. Formatting of document and document annotations


The generated documents are in HTML format, and these HTML format identifiers are not Javadoc, but we write them when we write the comments.
For example, instead of typing in a carriage return, you need to change the line, but write <br>, and if you want to segment, write <p> before the paragraph.
The body of the document comment is not copied directly to the output file (the document's HTML file), but after each line is read, the leading * number and the previous space of the * number are deleted and then entered into the document. Such as

/**
* This was first line. <br>
This was second line. <br>
This was third line.
*/


2. Three parts of the documentation note

First examples are as follows

1 /** 2 * A brief description of the show method.3 * Detailed description of the <p>show method first line <br>4 * Detailed description of the Show method the second line5 * @paramb True indicates display, False indicates hidden6 * @returnno return value7 */ 8 9  Public voidShowBooleanb) {Ten     Frame.show (b); One}

The first part is a brief description. Document, for the properties and methods are all preceded by a list, followed by a detailed description of one
A brief description is written before the first dot (.) in a document comment, including the point number. In other words, the document comments are separated by the first dot, preceded by a brief description, followed by the second and third parts.

The second part is the detailed description section. This section describes the properties or methods in detail, there are no special requirements in the format, and can contain several dot numbers.
* A brief description of the show method.
* Detailed description of the <p>show method first line <br>
* Detailed description of the Show method the second line

A brief description is also therein. That's a point to remember.

The third part is the Special Description section. This section includes release notes, parameter descriptions, return value descriptions, and so on.
* @param b True indicates display, false means hidden
* @return No return value


Three. Using the Javadoc tag


The Javadoc tag consists of the tag type and the private comment reference followed by "@".
The Javadoc tags have the following:
@author identify the author of the development of such modules
@version indicate the version of the module
@see reference steering, i.e. related topics
@param a description of a parameter in the method
@return Description of the return value of the method
@exception description of the exceptions that the method might throw

@author Author name
@version version number
Where @author can be used multiple times to indicate multiple authors, separated by commas (,) between each author in the resulting document. @version can also be used multiple times, only for the first time valid

Instructions for using @param, @return, and @exception
These three tokens are used only for methods. @param describes the parameters of the method, @return describes the return value of the method, @exception describes the exception that the method might throw. Their syntax is as follows:
Parameter description of the @param argument name
@return Return Value Description
@exception Exception class name description

Four. Javadoc command


Usage:
Javadoc [Options] [packagenames] [SourceFiles]

Options:

-public Show only public classes and members
-protected display Protected/public classes and members (default)
-package displaying package/protected/public classes and members
-private Show all classes and members
-D <directory> destination directory for output files
-version contains @version segments
-author contains @author segments
-splitindex divides the index into one file per letter
-windowtitle <text> Document browser window title

Javadoc can be given a list of packages when compiling a document, or a list of source program files. For example, under CLASSPATH there are two packages of several classes as follows:

Fancy. Editor
Fancy. Test
Fancy.editor.ECommand
Fancy.editor.EDocument
Fancy.editor.EView

You can compile the class directly:
Javadoc Fancy\test.java Fancy\editor.java Fancy\editor\ecommand.java Fancy\editor\edocument.java fancy\editor\ Eview.java

V. Examples

Person.java

1  PackageCom.example.doc;2 /**3  * @authorWu Wang e-mail:[email protected]4  * @versioncreated: August 25, 2016 PM 7:26:445 * Class Description6  */7  Public classPerson {8 9     /** Ten * A brief description of the show method. One * Detailed description of the <p>show method first line <br> A * The detailed description of the Show method is the second line. -     * @paramb True indicates display, False indicates hidden. -     */  the      Public voidShowBooleanb) { -System.out.println ("An javadoc example."); -     }  -}

For the above Person.java file, run Javadoc Person.java command, will generate a lot of HTML files in the current directory, open the index.html file, you can see the following:

This concludes.

Javadoc Annotation Specification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.