Fix for newline handling in doxygen "///" style comments
Previously, the newlines in "///" doxygen comments were being stripped out, resulting in incorrect translation of the comments for Python and Java. During scanning, "///" comments are processed line by line, whereas "/*" style get processed as a block with newlines intact. The fix checks for the "///" style in scanner.c and manually adds a newline at the end of each comment line. Some extra logic is also added to properly handle empty "///" comments and ensure that a newline gets added for those, which would otherwise be skipped.
This commit is contained in:
parent
e4c38f0f67
commit
b93597b63b
1 changed files with 20 additions and 0 deletions
|
|
@ -433,6 +433,19 @@ static int yylook(void) {
|
|||
Scanner_locator(scan, cmt);
|
||||
}
|
||||
if (scan_doxygen_comments) { /* else just skip this node, to avoid crashes in parser module*/
|
||||
|
||||
int slashStyle = 0; /* Flag for "///" style doxygen comments */
|
||||
if (strncmp(loc, "///", 3) == 0) {
|
||||
slashStyle = 1;
|
||||
if (Len(cmt) == 3) {
|
||||
/* Modify to make length=4 to ensure that the empty comment does
|
||||
get processed to preserve the newlines in the original
|
||||
comments. */
|
||||
cmt = NewStringf("%s ", cmt);
|
||||
loc = Char(cmt);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for all possible Doxygen comment start markers while ignoring
|
||||
comments starting with a row of asterisks or slashes just as
|
||||
Doxygen itself does. */
|
||||
|
|
@ -461,6 +474,13 @@ static int yylook(void) {
|
|||
Setline(yylval.str, Scanner_start_line(scan));
|
||||
Setfile(yylval.str, Scanner_file(scan));
|
||||
} else {
|
||||
if (slashStyle) {
|
||||
/* Add a newline to the end of each doxygen "///" comment,
|
||||
since they are processed individually, unlike the
|
||||
slash-star style, which gets processed as a block with
|
||||
newlines included. */
|
||||
Append(yylval.str, "\n");
|
||||
}
|
||||
Append(yylval.str, str);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue