Java documentation and javadoc
In addition to the bag, Java document is also a very important concept in Java programming. The Java document is the help document for the Java program. In general, let's write a help documentation and use tool javadoc to generate a corresponding document. Javadoc is a document generating tool provided by JDK. It uses Java Compile Javac to grammarize the declaration and document comments in the program code source file, and generate a set of HTML documents by default to describe classes, internal classes, interfaces, Construction functions, methods and domains. Javadoc comments start with "", end with " /", can contain normal text, HTML tag, and Javadoc tags. Javadoc only handles the comments before the class / interface definition, method, domain, and constructors before the source file, ignore the comments of other places.
Master Javadoc
Now let's use a routine to illustrate the meaning of the Javadoc mark:
/ My Javadoc test procedure - javadoctest b> @ Author Warton2003 Xi'an
test font> < - here can embed HTML this sentence is html Note -> @ Version 0.1 2004/01/01 / public class javadoctest / in main Use string @ See # mainjava.lang.string / static string sdisplay / Show javadoc test @ param args command line parameters @ Return no return value / public static void main String args sdisplay = "javadoc test" system.out.println sdisplay
In this Java program, a large number of Javadoc tags, text, and HTML tags are used. Javadoc marks start with "/ ", indicating that these are comments for Java code. The mark started by "@" is JavaDoc tag.
The Javadoc marks have two: Standalone tags and inline tags. Independent markers are those common tags, such as @ param, @ return, and @Author, etc.; another type of tag is the inline mark This tag is used in the form of @ tag it allows developers to create hyperlinks The comment section is linked to other Javadoc pages or elsewhere on this page.
Tip: Using Javadoc tags correctly in the Java source program is a very necessary annotation habit, will help Javadoc automatically generate a complete format API document with source code files.
OK, then let's take a look at how Javadoc generates a beautiful document! Save the above code to JavadOCtest.java and compile.
Run: javadoc -private -d doc -author -version javadoCtest.java
At this time, the Javadoc program generates a doc directory based on Javadoctest.java, there are many HTML files, which are the API help document generated by Javadoc.
Javadoc command line syntax
The light will not use the functions provided by Javadoc, and it must be used with its command line. Finally, introduce you to the simple javadoc command.
Javadoc's command line syntax is as follows:
Javadoc Options PackageNames SourceFiles @files Tip: For general applications, we only need to use the command lines such as Javadoc Yourjavafile.java to help documents. If you need to customize the help document, you will use the parameters. In general, you can use the Javadoc Help command to view Javadoc's help documentation. In short, Javadoc provides a full-specific API document function. In software project management and development, Javadoc can not only reduce the amount of document work at the time of development, but also improve efficiency, but also very beneficial to future modifications and maintenance.
Some detailed descriptions of Javadoc tags:
@Author Specifies the "Author" item in the document, you can specify multiple authors. In the left code, an HTML tag is added behind the AUTHOR to link the URL.
is HTML tag, < ----> is HTML annotation.
@Version Specify version information.
@see tags are more complicated. @see "String" Adds a text item for "String" and does not generate any links. @see Label uses the HTML tag to generate a link. @see package.class # member label.
@Param tag used to describe parameters.
The @returN tag is used to describe the return value.
@LINK is the inline mark, the usual format of the inline marker is: @linkpackage.class#member label
Tip: Label is the text in the middle of the comment, and package.class # metore points to a specific class or method. Here are some examples:
Link to the properties of the same class, use: @ link # key
Link to the same class, use: @ link # getcomponentatatt GetComponentat
Link to other classes, use @ linkjava.util.map Map