dnault / therapi-runtime-javadoc

Read Javadoc comments at run time.
Apache License 2.0
117 stars 19 forks source link

Constructor javadoc is missing when there is no class level java doc #41

Closed kirkch closed 3 years ago

kirkch commented 3 years ago

During testing, I noticed that I could retrieve the constructor java docs for

/**
 * abc
 */
public static class A {
    /**
     * Lorem ipsum dolor sit amet, consectetur adipiscing elit.
     */
    public A() {}
}

but not for

public static class A {
    /**
     * Lorem ipsum dolor sit amet, consectetur adipiscing elit.
     */
    public A() {}
}

The only difference in the two classes was whether they had javadocs at the class level. Running a debugger I can see that within RuntimeJavadoc.getJavadoc(Constructor); ClassJavadoc.getConstructors() returns an empty list.

While it is unusual for a constructor to have documentation and the class to not, it can still happen.

The problem appears to be located here, notice that it looks like the constructor check is .isArray() and will always return true.

https://github.com/dnault/therapi-runtime-javadoc/blob/6cfcb5a123b2ce116dfd4cd6d63a50889c369937/therapi-runtime-javadoc-scribe/src/main/java/com/github/therapi/runtimejavadoc/internal/JsonJavadocBuilder.java#L68