Skip to content

Commit

Permalink
Write override method documentation
Browse files Browse the repository at this point in the history
See: #13
  • Loading branch information
matshou committed Mar 12, 2021
1 parent 9c58622 commit ce78853
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
21 changes: 21 additions & 0 deletions src/main/java/io/cocolabs/pz/zdoc/doc/detail/MethodDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,27 @@ private static String parseMethodComments(Element element) {
commentBuilder.append('\n').append(commentBlocks.get(i).text());
}
}
// include override method documentation
boolean lastElementOverrideLabel = false;
for (Element blockListElement : element.getAllElements())
{
String tagName = blockListElement.tagName();
if (blockListElement.className().equals("overrideSpecifyLabel"))
{
if (commentBuilder.length() > 0) {
commentBuilder.append('\n');
}
commentBuilder.append(blockListElement.text());
lastElementOverrideLabel = true;
}
else if (lastElementOverrideLabel)
{
if (tagName.equals("dd")) {
commentBuilder.append('\n').append(blockListElement.text());
}
lastElementOverrideLabel = false;
}
}
String result = commentBuilder.toString();
if (!result.isEmpty()) {
Logger.debug("Parsed detail comment: \"" + result + "\"");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,12 @@ void shouldParseValidMethodDetailCommentBlocks() {

List<JavaMethod> entries = detail.getEntries();
String[] expectedComments = new String[]{
"This is a single-line block comment",
"This is a multi\nline block comment",
"", "", "", "", "",
"This is a single-line block comment\nSpecified by:\nbegin in class BaseCommand",
"This is a multi\nline block comment\nSpecified by:\nDoesInstantly in class BaseCommand",
"Specified by:\ninit in class BaseCommand",
"Specified by:\nIsFinished in class BaseCommand",
"Specified by:\nupdate in class BaseCommand",
"", "Specified by:\ngetColor in class BaseCommand",
"This method is annotated as @Deprecated"
};
Assertions.assertEquals(expectedComments.length, entries.size());
Expand Down

0 comments on commit ce78853

Please sign in to comment.