顯示具有 API 文件 標籤的文章。 顯示所有文章
顯示具有 API 文件 標籤的文章。 顯示所有文章

2015年11月2日 星期一

自動產生Java API 文件檔

這超好用
就算不是在寫公用API
也可以寫給自己用
可以自動產生網頁版的API文件
這裡示範一個簡單的用法:

1. 使用 /** --*/ 為程式碼下注解
示範用類別:
package learning.test;

import java.util.ArrayList;

public class InventorySystem {
 /** 道具欄的總格數 */
 int totalGrid;
 /** 物品儲存List */
 ArrayList&ltObject&gt al;

 /** 建構函式 */
 public InventorySystem(int totalGrid) {
  super();
  this.totalGrid = totalGrid;
  al = new ArrayList&ltObject&gt(totalGrid);
 }

 /** 將物品放入道具欄 */
 public static boolean putItem(Object item) {
  return true;
 }

 /** 藉由物品id取得物品 */
 public static Object getItemObjectById(int id) {
  return new Object();
 }

 /** 藉由物品id取得物品數量 */
 public static int getItemNumberById(int id) {
  return 520;
 }
}

2.Eclipse 上選Project -> Generate Javadoc