Fix Java doxygen:notranslate for single line comments
Remove extra generated line
This commit is contained in:
parent
57f7070406
commit
d22ecafb36
4 changed files with 17 additions and 4 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
%include "doxygen_basic_translate.h"
|
%include "doxygen_basic_translate.h"
|
||||||
%feature("doxygen:notranslate") function;
|
%feature("doxygen:notranslate") function;
|
||||||
|
%feature("doxygen:notranslate") function1;
|
||||||
%feature("doxygen:notranslate") function2;
|
%feature("doxygen:notranslate") function2;
|
||||||
%feature("doxygen:notranslate") function3;
|
%feature("doxygen:notranslate") function3;
|
||||||
%feature("doxygen:notranslate") function4;
|
%feature("doxygen:notranslate") function4;
|
||||||
|
|
@ -25,6 +26,11 @@ int function()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Single line comment */
|
||||||
|
void function1()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A test of a very very very very very very very very very very very very very very very very
|
* A test of a very very very very very very very very very very very very very very very very
|
||||||
* very very very very very long comment string.
|
* very very very very very long comment string.
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,7 @@ public class doxygen_basic_notranslate_runme {
|
||||||
" \n" +
|
" \n" +
|
||||||
"");
|
"");
|
||||||
wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function5(int)",
|
wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function5(int)",
|
||||||
" This is a post comment. \n" +
|
" This is a post comment. ");
|
||||||
"");
|
|
||||||
wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function7(doxygen_basic_notranslate.SWIGTYPE_p_p_p_Shape)",
|
wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function7(doxygen_basic_notranslate.SWIGTYPE_p_p_p_Shape)",
|
||||||
" \n" +
|
" \n" +
|
||||||
" Test for a parameter with difficult type\n" +
|
" Test for a parameter with difficult type\n" +
|
||||||
|
|
@ -88,6 +87,8 @@ public class doxygen_basic_notranslate_runme {
|
||||||
" @param a Some parameter, default is 42\n" +
|
" @param a Some parameter, default is 42\n" +
|
||||||
" \n" +
|
" \n" +
|
||||||
"");
|
"");
|
||||||
|
wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function1()",
|
||||||
|
" Single line comment ");
|
||||||
wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function2()",
|
wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function2()",
|
||||||
" \n" +
|
" \n" +
|
||||||
" A test of a very very very very very very very very very very very very very very very very\n" +
|
" A test of a very very very very very very very very very very very very very very very very\n" +
|
||||||
|
|
@ -98,4 +99,4 @@ public class doxygen_basic_notranslate_runme {
|
||||||
// and ask the parser to check comments for us
|
// and ask the parser to check comments for us
|
||||||
System.exit(parser.check(wantedComments));
|
System.exit(parser.check(wantedComments));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ The comment text
|
||||||
\sa function2"""
|
\sa function2"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function1),
|
||||||
|
r"""Single line comment """
|
||||||
|
)
|
||||||
comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function2),
|
comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function2),
|
||||||
r"""A test of a very very very very very very very very very very very very very very very very
|
r"""A test of a very very very very very very very very very very very very very very very very
|
||||||
very very very very very long comment string."""
|
very very very very very long comment string."""
|
||||||
|
|
|
||||||
|
|
@ -718,10 +718,12 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) {
|
||||||
|
|
||||||
size_t idx = doc.find('\n');
|
size_t idx = doc.find('\n');
|
||||||
size_t indent = 0;
|
size_t indent = 0;
|
||||||
|
bool singleLineComment = idx == string::npos;
|
||||||
// Detect indentation.
|
// Detect indentation.
|
||||||
// The first line in comment is the one after '/**', which may be
|
// The first line in comment is the one after '/**', which may be
|
||||||
// spaces and '\n' or the text. In any case it is not suitable to detect
|
// spaces and '\n' or the text. In any case it is not suitable to detect
|
||||||
// indentation, so we have to skip the first '\n'.
|
// indentation, so we have to skip the first '\n'.
|
||||||
|
// However, if there is just one line, then use that line to detect indentation.
|
||||||
if (idx != string::npos) {
|
if (idx != string::npos) {
|
||||||
size_t nonspaceIdx = doc.find_first_not_of(" \t", idx + 1);
|
size_t nonspaceIdx = doc.find_first_not_of(" \t", idx + 1);
|
||||||
if (nonspaceIdx != string::npos) {
|
if (nonspaceIdx != string::npos) {
|
||||||
|
|
@ -767,7 +769,8 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) {
|
||||||
size_t nonspaceEndIdx = translatedStr.find_last_not_of(" \t");
|
size_t nonspaceEndIdx = translatedStr.find_last_not_of(" \t");
|
||||||
if (nonspaceEndIdx != string::npos) {
|
if (nonspaceEndIdx != string::npos) {
|
||||||
if (translatedStr[nonspaceEndIdx] != '\n') {
|
if (translatedStr[nonspaceEndIdx] != '\n') {
|
||||||
translatedStr += '\n';
|
if (!singleLineComment)
|
||||||
|
translatedStr += '\n';
|
||||||
} else {
|
} else {
|
||||||
// remove trailing spaces
|
// remove trailing spaces
|
||||||
translatedStr = translatedStr.substr(0, nonspaceEndIdx + 1);
|
translatedStr = translatedStr.substr(0, nonspaceEndIdx + 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue