improved handling of @see tags - SWIG no longer crashes if right brace is missing
This commit is contained in:
parent
2df4449e3b
commit
a2a345be39
3 changed files with 39 additions and 12 deletions
|
|
@ -57,6 +57,9 @@ void backslashB()
|
||||||
/**
|
/**
|
||||||
* Backslash e at end of \e line froze SWIG \e
|
* Backslash e at end of \e line froze SWIG \e
|
||||||
* with old comment parser.
|
* with old comment parser.
|
||||||
|
*
|
||||||
|
* @see MyClass::fun(char,
|
||||||
|
* float)
|
||||||
*/
|
*/
|
||||||
void backslashC()
|
void backslashC()
|
||||||
{}
|
{}
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,7 @@ public class doxygen_misc_constructs_runme {
|
||||||
wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.backslashC()",
|
wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.backslashC()",
|
||||||
" Backslash e at end of <i>line</i> froze SWIG\n" +
|
" Backslash e at end of <i>line</i> froze SWIG\n" +
|
||||||
" <i>with</i> old comment parser.\n" +
|
" <i>with</i> old comment parser.\n" +
|
||||||
|
" @see MyClass#fun(char,float)\n" +
|
||||||
"");
|
"");
|
||||||
|
|
||||||
// and ask the parser to check comments for us
|
// and ask the parser to check comments for us
|
||||||
|
|
|
||||||
|
|
@ -56,11 +56,9 @@ void JavaDocConverter::fillStaticTables() {
|
||||||
*
|
*
|
||||||
* entities must be translated - remain in Java, something meaningfull in Python (<, ...)
|
* entities must be translated - remain in Java, something meaningfull in Python (<, ...)
|
||||||
*
|
*
|
||||||
* - OK enum inside class is missing comment
|
|
||||||
* - crash if link in @see tag is split to two lines
|
* - crash if link in @see tag is split to two lines
|
||||||
* - whitespaces in tests
|
* - whitespaces in tests
|
||||||
* - Python
|
* - Python
|
||||||
* - OK '\' not representing doxygen commands
|
|
||||||
* - add comments also to auto-generated methods lilke equals(), delete() in Java,
|
* - add comments also to auto-generated methods lilke equals(), delete() in Java,
|
||||||
* and methods for std::vector(), ...
|
* and methods for std::vector(), ...
|
||||||
*/
|
*/
|
||||||
|
|
@ -517,7 +515,7 @@ string JavaDocConverter::convertLink(string linkObject) {
|
||||||
// find the params in function in linkObject (if any)
|
// find the params in function in linkObject (if any)
|
||||||
size_t lbracePos = linkObject.find('(', 0);
|
size_t lbracePos = linkObject.find('(', 0);
|
||||||
size_t rbracePos = linkObject.find(')', 0);
|
size_t rbracePos = linkObject.find(')', 0);
|
||||||
if (lbracePos == string::npos && rbracePos == string::npos && lbracePos >= rbracePos)
|
if (lbracePos == string::npos || rbracePos == string::npos || lbracePos >= rbracePos)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
string paramsStr = linkObject.substr(lbracePos + 1, rbracePos - lbracePos - 1);
|
string paramsStr = linkObject.substr(lbracePos + 1, rbracePos - lbracePos - 1);
|
||||||
|
|
@ -621,18 +619,43 @@ void JavaDocConverter::handleTagSee(DoxygenEntity& tag, std::string& translatedC
|
||||||
if (!tag.entityList.size())
|
if (!tag.entityList.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// tag.entity list contains contents of the @see paragraph. It should contain
|
||||||
|
// one link (references) to method with or without parameters. Doxygen supports
|
||||||
|
// arbitrary text and types mixed, but this feature is not supported here.
|
||||||
|
// :: or # may be used as a separator between class name and method name.
|
||||||
list<DoxygenEntity>::iterator it;
|
list<DoxygenEntity>::iterator it;
|
||||||
|
string methodRef;
|
||||||
for (it = tag.entityList.begin(); it!=tag.entityList.end(); it++) {
|
for (it = tag.entityList.begin(); it!=tag.entityList.end(); it++) {
|
||||||
if (it->typeOfEntity == "plainstd::endl")
|
if (it->typeOfEntity == "plainstd::endl") {
|
||||||
handleNewLine(*it, translatedComment, dummy);
|
// handleNewLine(*it, translatedComment, dummy);
|
||||||
if (it->typeOfEntity != "plainstd::string")
|
|
||||||
continue;
|
continue;
|
||||||
translatedComment += "@see ";
|
}
|
||||||
string linkObject = convertLink(it->data);
|
|
||||||
if (!linkObject.size())
|
// restore entities which may be used in C++ type declaration
|
||||||
linkObject = it->data;
|
if (it->typeOfEntity == "&") {
|
||||||
translatedComment += linkObject;
|
methodRef += '&';
|
||||||
|
} else if (it->typeOfEntity == "<") {
|
||||||
|
methodRef += '<';
|
||||||
|
} else if (it->typeOfEntity == ">") {
|
||||||
|
methodRef += '>';
|
||||||
|
} else {
|
||||||
|
methodRef += it->data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// replace :: with #, but only if it appears before left brace
|
||||||
|
size_t lbrace = methodRef.find('(');
|
||||||
|
size_t dblColon = methodRef.find("::");
|
||||||
|
if (dblColon < lbrace) {
|
||||||
|
methodRef = methodRef.substr(0, dblColon) + '#' + methodRef.substr(dblColon + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
translatedComment += "@see ";
|
||||||
|
string linkObject = convertLink(methodRef);
|
||||||
|
if (!linkObject.size()) {
|
||||||
|
linkObject = methodRef;
|
||||||
|
}
|
||||||
|
translatedComment += linkObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue