mirror of https://github.com/swig/swig
Fix Java doxygen:notranslate for single line comments
Remove extra generated line
This commit is contained in:
parent
57f7070406
commit
d22ecafb36
|
@ -2,6 +2,7 @@
|
|||
|
||||
%include "doxygen_basic_translate.h"
|
||||
%feature("doxygen:notranslate") function;
|
||||
%feature("doxygen:notranslate") function1;
|
||||
%feature("doxygen:notranslate") function2;
|
||||
%feature("doxygen:notranslate") function3;
|
||||
%feature("doxygen:notranslate") function4;
|
||||
|
@ -25,6 +26,11 @@ int function()
|
|||
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
|
||||
* very very very very very long comment string.
|
||||
|
|
|
@ -61,8 +61,7 @@ public class doxygen_basic_notranslate_runme {
|
|||
" \n" +
|
||||
"");
|
||||
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)",
|
||||
" \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" +
|
||||
" \n" +
|
||||
"");
|
||||
wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function1()",
|
||||
" Single line comment ");
|
||||
wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function2()",
|
||||
" \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
|
||||
System.exit(parser.check(wantedComments));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ The comment text
|
|||
\sa function2"""
|
||||
)
|
||||
|
||||
comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function1),
|
||||
r"""Single line comment """
|
||||
)
|
||||
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
|
||||
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 indent = 0;
|
||||
bool singleLineComment = idx == string::npos;
|
||||
// Detect indentation.
|
||||
// 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
|
||||
// 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) {
|
||||
size_t nonspaceIdx = doc.find_first_not_of(" \t", idx + 1);
|
||||
if (nonspaceIdx != string::npos) {
|
||||
|
@ -767,7 +769,8 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) {
|
|||
size_t nonspaceEndIdx = translatedStr.find_last_not_of(" \t");
|
||||
if (nonspaceEndIdx != string::npos) {
|
||||
if (translatedStr[nonspaceEndIdx] != '\n') {
|
||||
translatedStr += '\n';
|
||||
if (!singleLineComment)
|
||||
translatedStr += '\n';
|
||||
} else {
|
||||
// remove trailing spaces
|
||||
translatedStr = translatedStr.substr(0, nonspaceEndIdx + 1);
|
||||
|
|
Loading…
Reference in New Issue