Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ Parts parts(Element element) {
default -> {
if (tag.getKind() == DocTree.Kind.HIDDEN) {
hidden = true;
} else if (tag instanceof ErroneousTree erroneous) {
// A block tag javadoc could not parse, such as @throws without a type. It has no
// tag name.
problem(
ctx,
Report.Problem.MALFORMED,
tag,
"Malformed documentation: " + erroneous.getBody());
} else if (tag instanceof UnknownBlockTagTree unknown
&& customTags.containsKey(unknown.getTagName())) {
var custom = customTags.get(unknown.getTagName());
Expand Down
27 changes: 27 additions & 0 deletions doclet/src/test/java/dev/elide/doclet/ProblemsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,33 @@ void categoryCanStayAnErrorUnderAWarningDefault(@TempDir Path directory) throws
assertEquals(1, result.errors().size(), result::toString);
}

@Test
void malformedBlockTagIsAProblem(@TempDir Path directory) throws Exception {
var sources =
Map.of(
"shelf/Shelf.java",
"""
package shelf;

/**
* A shelf.
*
* @throws
*/
public interface Shelf {}
""");
var failed = Javadoc.run(directory.resolve("error"), sources, List.of());
assertFalse(failed.ok());
assertEquals(1, failed.errors().size(), failed::toString);
assertTrue(failed.errors().get(0).endsWith("[malformed]"), failed::toString);

var lenient =
Javadoc.run(
directory.resolve("warning"), sources, List.of("--problems", "malformed=warning"));
assertTrue(lenient.ok(), lenient::toString);
assertTrue(lenient.model().contains("A shelf."), lenient::toString);
}

@Test
void unknownCategoryIsRejected(@TempDir Path directory) throws Exception {
var result = Javadoc.run(directory, SOURCES, List.of("--problems", "bogus=warning"));
Expand Down
Loading