Doclet: firstSentence is null

天涯浪子 提交于 2019-12-13 05:19:27

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!