java object-oriented API documentation generated 11_JavaDoc

1. JavaDoc Overview

Java JavaDoc is carrying a tool, which can be extracted from the source code classes, methods, attributes, etc. Note forming a source and supporting API help documentation. In other words, as long as a specific set of tags to annotate in the preparation of the program, after the program is completed, it can form a development program through the Javadoc documentation at the same time.

There are three Java annotation method: // single-line comment, / * multiline comment * / and / ** documentation comment * /, which is the third special JavaDoc design, can be built-in JDK JavaDoc tool support and treatment. We can implement the Java files generated by Eclipse API documentation.

2. Document Format comments

Javadoc-generated documentation in HTML format, and these javadoc HTML format identifier is not added, but we wrote up the time to write comments. When the document notes, we should be rational use of block tags to add annotation information, commonly used in the block tag include:

  • @author indicate the development of this type of module

  • @version marked version of the class module

  • @see reference turn, is related topics

  • @param a method described in the parameters

  • described method @return return value

  • @exception to throw an exception explained

[Example] Use Case documentation comment block mark achieved

/**
 * Student类
 * @author 程序猿
 * @version 2.3.1
 */
public class Student {
	/**
	 * 学生名字
	 */
	private String name;
	/**
	 * 学生姓名
	 */
	private int age;
	/**
	 * 无参构造方法
	 */
	public Student() {}
	/**
	 * 有参构造方法
	 * @param name 学生姓名
	 * @param age 学生年龄
	 */
	public Student(String name, int age) {
		this.name = name;
		setAge(age);
	}
	/**
	 * name属性的get方法
	 * @return 返回学生的姓名
	 */
	public String getName() {
		return name;
	}
	/**
	 * name属性的set方法
	 * @param name 需要赋值的姓名
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * age属性的get方法
	 * @return 返回学生的年龄
	 */
	public int getAge() {
		return age;
	}
	/**
	 * age属性的set方法
	 * @param age 需要赋值的年龄
	 */
	public void setAge(int age) {
		// 在赋值之前先判断年龄是否合法
		if (age > 130 || age < 0) {
			this.age = 0; // 不合法赋默认值0
		} else {
			this.age = age; 
		}
	}
	/**
	 * 输出学生信息
	 */
	void show() { 
		System.out.println("name: " + name + " age: " + age);
	}
}

3.Eclipse generated API documentation

Export (Export) -> find Javadoc in java -> set various options -> set the parameter list in the console.

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

ps: For the latest free documentation and instructional videos, please add QQ group (627,407,545) receive.

Published 55 original articles · won praise 0 · Views 799

Guess you like

Origin blog.csdn.net/zhoujunfeng121/article/details/104600336