Reader throws AssertionError when parsing malformed @see tag
jhameier opened this issue · 2 comments
So I found that using an @see tag will fail to match the the linkPattern in the LinkParser class if it contains a period at the end.
This may not necessarily be a bug since I don't believe that a comment type tag should end in a period, though the documentation is somewhat sparse and other tag types do not fail but I'm pointing this out for good measure.
Exception in thread "main" java.lang.AssertionError: SeeAlso not recognized as string literal, HTML link or Javadoc link
at com.github.therapi.runtimejavadoc.internal.parser.SeeAlsoParser.parseSeeAlso(SeeAlsoParser.java:27)
at com.github.therapi.runtimejavadoc.internal.parser.JavadocParser.parseMethodJavadoc(JavadocParser.java:66)
at com.github.therapi.runtimejavadoc.internal.JsonJavadocReader.readMethodDoc(JsonJavadocReader.java:67)
at com.github.therapi.runtimejavadoc.internal.JsonJavadocReader.readMethodDocs(JsonJavadocReader.java:57)
at com.github.therapi.runtimejavadoc.internal.JsonJavadocReader.readClassJavadoc(JsonJavadocReader.java:28)
at com.github.therapi.runtimejavadoc.RuntimeJavadoc.parseJavadocResource(RuntimeJavadoc.java:102)
at com.github.therapi.runtimejavadoc.RuntimeJavadoc.getJavadoc(RuntimeJavadoc.java:85)
at com.github.therapi.runtimejavadoc.RuntimeJavadoc.getJavadoc(RuntimeJavadoc.java:37)
at example.JavadocReader.printClassJavadocClass(JavadocReader.java:16)
at example.JavadocReader.main(JavadocReader.java:12)
/**
* This is a test inner class level javadoc. // this shouldn't throw an assertion error
*/
public static class InnerTestClass {
/**
* This is a test inner class method level javadoc.
*
* @param string a string input. // this will not throw assertion error
*
* @return the length of the string. // this will not throw assertion error
*/
public int stringLength(String string) {
return string.length();
}
/**
* @see InnerTestClass#stringLength(String). // this WILL throw assertion error
*/
public void testSeeWithPeriod() {}
}
Thank you for tracking this down and reporting the issue.
That @see
tag with the dot at the end is malformed. Here's the specification for a valid @see
value: https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#see
Even though it's malformed, the reader probably shouldn't throw an exception. Perhaps the scribe should log a warning for invalid tags, and either omit the tag or treat it like an OtherJavadoc
.
Fixed by dropping malformed tags.