Java注释写好了,如何提取出来生产说明文档呢?

 

public static final int ANOTHER_FOO_TYPE = 1;

  /**
   * The current foo type
   */
  private int type;

  /**
   * Constructs a Bar
   */
  public Bar() {
    type = FOO_TYPE;
  }

  /**
   * Returns current foo type
   * 
   * @return current foo type
   * @deprecated As of version 2.3, use {@link #getFoo() getFoo()}instead
   */
  public int foo() {
    return getFoo();
  }

  /**
   * Returns current foo type
   * 
   * @return current foo type
   * @since V2.3
   */
  public int getFoo() {
    return getFoo();
  }

  /**
   * Changes current foo type
   * 
   * @param type
   *            new type of foo
   * @throws IllegalArgumentException
   *             When type invalid
   */
  public void setFoo(int newValue) {
    if ((newValue != FOO_TYPE) && (newValue != ANOTHER_FOO_TYPE)) {
      throw new IllegalArgumentException("Bad type");
    }
    type = newValue;
  }

  /**
   * Placeholder method for see tags
   * 
   * @see Bar#FOO_TYPE
   * @see Bar#getFoo()
   * @see #getFoo()
   * @see "My Book"
   * @see jGuru 
   */
  public void myVoid() {
  }

}

1. 将java文件(名字JavadocDemo.java)放置在某一目录,如:"D:/doc";

2. 运行cmd,进入该目录,执行“javadoc JavadocDemo.java”即可生成HTML格式的说明文档。

3. JavaDoc工具的使用格式如下:

javadoc [选项][软件包名称][源文件][@file]

    上述格式中的@file指的是包含文件,为了简化JavaDoc命令,可以将需要生成文档的软件包名和源文件名放到一个文本文件中。例如,为了简化以下命令:

javadoc  -d  mydoc  test.Student  test.Teacher

    可以建立一个名称为myfile.txt的文件,内容如下:

mydoc text.Student

text.Teacher

    然后执行命令

javadoc -d mydoc @myfile.txt

你可能感兴趣的:(Java)