是否有Java注释来生成参数文档?

时间:2015-07-20 22:21:06

标签: java documentation javadoc embedded-documents

像hadoop这样的项目有很多parameters,但所有文档都是从xml手动生成的,而不是来自code

是否有办法使用可以生成此文档的注释执行某些操作?

  public static final String MAP_SORT_SPILL_PERCENT = "mapreduce.map.sort.spill.percent";

  <name>mapreduce.map.sort.spill.percent</name>
  <value>0.80</value>
  <description>The soft limit in the serialization buffer. Once reached, a
  thread will begin to spill the contents to disk in the background. Note that
  collection will not block if this threshold is exceeded while a spill is
  already in progress, so spills may be larger than this threshold when it is
  set to less than .5</description>

1 个答案:

答案 0 :(得分:0)

您可以使用@param javadoc标记在代码中生成参数信息,例如this example from the wikipedia page

/**
 * Short one line description.                           
 *
 * @param  variable Description text text text.         
 * @return Description text text text.
 */    
public int methodName (...) {
    // method body with a return statement
}

这就是Oracle如何为Java生成官方文档(example)