Javadoc annotation usage

Source: Internet
Author: User
Tags list of attributes

Javadoc annotation usage

 

Read: http://blog.163.com/hui_san/blog/static/5710286720104191100389/ 

  1. Java documentation

    // Comment a row
    /* ...... */Annotate several rows
    /**... */Annotate several rows,And writeJavadoc documentation

    The multiple lines of such annotation are usually written as follows:

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

    Javadoc-D file storage directory-author-version source file name. Java
    This command compiles a file named "source file name. java "and store the generated documents in the directory specified by" document storage directory ". In the generated documents, index.html is the homepage of the document. -Author and-Version options can be omitted.

    Ii. Document comment format

    1.Format document and document comments

    The generated documents are in HTML format, and the identifiers in HTML format are not added by javadoc, but written when writing comments.
    For example, if you want to change the row, you do not need to input a carriage return, but write <br>. If you want to segment, you should write <p> before the segment.
    The body of the document comment is not directly copied to the output file (the HTML file of the document), but read each line and delete leading * signs and spaces before * signs, enter the document. For example

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

    2.Document comments
    Example:

    /**
    * Show
    Method description.
    * <P> detailed description of the show method first line <br>
    * The second line of the show method is described in detail.
    * @ Param B true indicates display, and false indicates hidden.
    * @ Return no return value

    */

    Public
    Void show (Boolean B ){
    Frame. Show (B );
    }

    The first part is a brief description. In this document, there is a list of attributes and methods first, and then detailed descriptions are provided one by one.

    The description is written at the beginning of a document comment, before the first vertex ). In other words, it is to use the first vertex to separate the comments of the document. It is a brief description, followed by the second part and the third part.

    The second part is the detailed description. This section describes the attributes or methods in detail. There are no special requirements on the format. It can contain several periods.

    * Brief description of the show method.
    * <P> detailed description of the show method first line <br>
    * The second line of the show method is described in detail.

    The description is also included. Remember this.

    The third part is the special description section. This part includes version description, parameter description, and return value description.
    * @ Param B true indicates display, and false indicates hidden.
    * @ Return no return value


    3. Mark with javadoc
    The javadoc tag consists of "@" and its subsequent tag types and special annotation references.
    The javadoc labels are as follows:
    @ Author indicates the author of The development class module

    @ Version indicates the version of the module.

    @ See references, that is, related topics

    @ Param description of a parameter in the other method

    @ Return description of the return value of the Method

    @ Exception describes possible exceptions thrown by methods.

    @ Author name
    @ Version
    @ Author can be used multiple times to specify multiple authors. Each author in the generated document is separated by a comma. @ Version can also be used multiple times, only valid for the first time

    Use @ Param, @ return, and @ exception to describe the method
    These three tags are only used for methods. @ Param describes the parameters of the method, @ return describes the return value of the method, and @ exception describes the exceptions that may be thrown by the method. Their syntax is as follows:
    @ Param parameter name parameter description
    @ Return value description
    @ Exception Class Name Description

    4. javadoc command
    Usage:
    Javadoc [Options] [packagenames] [sourcefiles]

    Option:

    -Public: Only public classes and members are displayed.

    -Protected: displays the protected/public class and members (default)
    -Package: displays package/protected/public class and members.

    -Private: displays all classes and members.

    -D <directory> target directory of the output file

    -Version contains @ version segments

    -Author contains @ author segments

    -Splitindex divides the index into one file corresponding to each letter.

    -Windowtitle <text> the browser window title of the document

    You can specify a package list or a list of source program files when compiling a document using javadoc. For example, there are two classes in classpath:

    Fancy. Editor
    Fancy. Test
    Fancy. Editor. ecommand
    Fancy. Editor. eDocument
    Fancy. Editor. eview

    You can directly compile the class:
    Javadoc fancy \ test. Java fancy \ editor. Java fancy \ editor \ ecommand. Java fancy \ editor \ eDocument. Java fancy \ editor \ eview. Java

    The package name can also be used as the compilation parameter, for example, javadoc fancy. Editor.
    Let's take a look at the differences between the two methods.

    So far, javadoc has been briefly introduced. To use it well, you need to use it more. For more information, see the standard Java code.(See the SRC Source File package in the JDK installation directory)

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.