java docs,如何使用Java生成javadocs?

这篇博客探讨了如何在不依赖IDE的情况下,用Java代码编译项目,并在编译过程中自动创建Javadoc。作者提到了Apache Ant和Apache Maven作为替代方案,它们都内置了生成Javadoc的功能。此外,还展示了使用Java Doclet API手动生成Javadoc的示例代码。
摘要由CSDN通过智能技术生成

I'm writing a Java app that will let me compile a Java project based solely on it's file structure so that I can write code and compile without an IDE. The problem that I'm currently having is that I would like to automatically generate the javadoc while I'm compiling, though while Java 6 supplies a JavaCompiler object to work with, I can't find a way to use the javadoc command.

How can I generate the javadoc html for my projects using Java code?

解决方案

Just in case you weren't aware both Apache Ant and Apache Maven are tools that exist to accomplish a similar goal to what you are writing (compiling without an IDE).

Both of them have built in support for generating javadoc. Ant syntax looks like this:

defaultexcludes="no"

destdir="${web-javadoc}"

author="true"

version="true"

use="true"

windowtitle="IMP: Integrated Mechanisms Program"

overview="${source}/overview.html"

classpathref="debug.classpath"

stylesheetfile="${javadoc-theme}/stylesheet.css"

/>

If you really want to generate it on your own you want to use the Doclet API

import com.sun.javadoc.*;

public class ListClass {

public static boolean start(RootDoc root) {

ClassDoc[] classes = root.classes();

for (int i = 0; i < classes.length; ++i) {

System.out.println(classes[i]);

}

return true;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值