问题
I'm doing some experiments with Doclets. I'm using Java 7 and Maven.
My pom.xml is:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>betlista</groupId>
<artifactId>tests-javadoc</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>tools</artifactId>
<version>1.5.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</project>
My doclet is:
package betlista.tests.javadoc;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.MethodDoc;
import com.sun.javadoc.RootDoc;
public class MyDoclet {
public static boolean start(RootDoc root) {
ClassDoc[] classes = root.classes();
for (ClassDoc classDoc : classes) {
processClass(classDoc);
}
return true;
}
private static void processClass(ClassDoc classDoc) {
MethodDoc[] methods = classDoc.methods();
for (MethodDoc methodDoc : methods) {
processMethod(methodDoc);
}
}
private static void processMethod(MethodDoc methodDoc) {
System.out.println(methodDoc);
}
public static void main(String[] args) {
String[] params = new String[] {
"-private",
//"-docletpath", "c:\\betlista\\CAMS\\SVN\\cams\\trunk\\CamsSwaggerGenerator\\target\\classes",
"-doclet", "betlista.tests.javadoc.MyDoclet",
"-sourcepath", "C:\\betlista\\other\\sts_3.6.1_e4.4_ws\\tests-javadoc\\src\\main\\java",
"betlista.tests.javadoc"
};
com.sun.tools.javadoc.Main.execute(params);
}
}
and my class I'm trying to process with doclet is
package betlista.tests.javadoc;
/**
* My perfect class
*
* @author me
*/
public class ClassToProcess {
/**
* My cool method.
*/
private void foo() {
}
}
According to my understanding "My cool method." should be a first sentence, but in debug there is a null
value when I have breakpoint in MyDoclet's processMethod()
:
Some ideas what I missed?
note: I just tried with
<version>1.7.0</version>
and no change...
回答1:
You missed the point after the class description.
来源:https://stackoverflow.com/questions/27440798/doclet-firstsentence-is-null