In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what is the method of Doc document annotation in Java program", the content is simple and easy to understand, clear organization, I hope to help you solve doubts, let Xiaobian lead you to study and learn "what is the method of Doc document annotation in Java program" this article bar.
Java supports three types of comments: single-line comments, multi-line comments, and document comments. Let's see what they look like.
//single-line comment
/*
multiline comments
*/
/**
*@...
*....
* Document comments
*/
Perhaps many new people do not understand, what is the use of writing these comments?
In fact, because the amount of beginner code is small, no comments can also be quickly found, modified
As the code grows, comments are a good thing, not only for clarity, but also for the convenience of the people you're working with.
Remember, break the bad habit of not writing comments!!!
So, here's our topic today: What is Doc comment?
Javadoc is a technology provided by Sun Corporation, which extracts class, method, member and other comments from program source code to form an API help document matching with source code. In other words, as long as the program is written with a specific set of tags for comments, after the program is written, Javadoc can also form the development documentation of the program.
javadoc command is used to generate API documentation, using the command line in the target file directory input javadoc + filename.java
These complex theories do not have to be entangled, but cultivate an idea, to understand, to understand, to go deep, to change it, to understand it, to cling to the theory is ineffective!
We write code, there are norms, if you write code can run, but a mess, no one wants to use, because it is difficult to maintain, so code is not just a simple program, in the network world, I prefer to call it a work of art, need your careful engraving
Some might say, isn't that just a comment? what's the big deal
However, this Doc comment is not the same as the other two comments. Comments are also standardized!
Doc Comment Specification
Format:
Document annotations written on classes are generally divided into three sections:
A brief description of the function of the class, usually in one sentence or paragraph, ending with a full stop
A: B: A: A: B: A: A: B: B: A: B: B: A: B: A: B: B:
The third paragraph: document annotation, used to mark the author, creation time, reference class and other information
Here I want to expand a little knowledge, our Doc comments can use the Dos command or IDE tools to generate a Doc document, this document is HTML language to run through, so in the comments inside can be accompanied by some simple HTML code, such as the following
newline
segment
(written before paragraph)
Put an example style diagram:
Use of @ symbol
When we write Doc comments,/** After entering directly, it will automatically generate the comment frame behind, and part of the @ symbol, so what is the use of these @ symbols?
tag description example @author identifies the author of a class, commonly used in class comments @author description@deprecated Designates an out-of-date class or member, indicating that the class or method is not recommended @deprecated description{@docRoot} indicates the path to the root directory of the current document Directory Path@exception may throw exception description, commonly used in method comments @exception exception-name explanation{@inheritDoc} Comments inherited from the immediate parent class Inherits a comment from the immediate surperclass. {@link} Insert a link to another topic {@link name text}{@linkplain} Insert a link to another topic, but the link displays plain text fonts Inserts an in-line link to another topic.@ param Description of a method parameter, generally used for method comments @ am parameter-name explanation@return Description of return value type, generally used for method comments, cannot appear in reconstruction method @return explanation@see Specify a link to another topic @see anchor@serial Description a serialized attribute @serial description@serialData Description data written via writeObject() and writeExternal() methods @serialData description@serialField Description an ObjectStreamField component @ serialField name type description@since @since release@throws and @exception tag.The @throws tag has the same meaning as the @exception tag. {@value} displays the value of a constant, which must be a static property. Displays the value of a constant, which must be a static field.@ version Specifies the version of the class, typically used for class annotation @version info
The part behind @ me here is English, you can write Chinese, such as @author Xiaojian
How to generate Doc documents
As we said above, if you write Doc comments, you can generate a Doc document in HTML format, so how do we generate it?
First: Dos command generation
javadoc [options] [packagenames] [sourcefiles]
Description of format:
options indicates options for Javadoc command;
packagenames represents the package name;
sourcefiles indicates the source file name;
Enter javadoc -help in cmd (command prompt) to see Javadoc usage and options (if JDK is configured). Here are some common options for Javadoc command:
Name Description-public Show only public classes and members-protected Show protected/public classes and members (default)-package Show package/protected/public classes and members-private Show all classes and members-d Output destination directory for file-version Contains @version segment-author Contains @author segment-splitindex Divides index into files for each letter-windowtitle Browser window title for document
Doc generation is cumbersome and slow, so is there any other way?
Second: IDE Tool Generation
We can use Eclipse or IDEA to generate, Eclipse I do not use, with IDEA to show you about it!
In JavaDoc inside the tool, after entering it, it is like this.
Output directory must be selected, otherwise it cannot be generated
Note that, because Java encoding is different from IDEA encoding, so in the other command parameter column, fill in the following content
-encoding utf8 -docencoding utf8 -charset utf8
After it was created, it was like this.
The above is "Java program Doc document annotation method is what" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.