diff options
author | Marko Klopcic <markok3.14@gmail.com> | 2013-03-17 20:09:34 +0100 |
---|---|---|
committer | Marko Klopcic <markok3.14@gmail.com> | 2013-03-17 20:09:34 +0100 |
commit | 4663fce63cc9a4a0222f80304f7acc15ed695c30 (patch) | |
tree | 2313e615985cc5160c4ed5d9daf73b6208bd747a | |
parent | 4e2c1e3ac36b5750c1bc84ceeb6af146e0987595 (diff) | |
download | swig-4663fce63cc9a4a0222f80304f7acc15ed695c30.tar.gz |
fixed bug in handling of ref tag in Java, added handling in Python
8 files changed, 72 insertions, 27 deletions
diff --git a/Examples/test-suite/doxygen_translate_all_tags.i b/Examples/test-suite/doxygen_translate_all_tags.i index 9fc25416f..d1319840f 100644 --- a/Examples/test-suite/doxygen_translate_all_tags.i +++ b/Examples/test-suite/doxygen_translate_all_tags.i @@ -277,7 +277,9 @@ int func07(int a) * * \publicsection * - * \ref someAnchor Anchor description + * \ref someAnchor "Anchor description" + * + * \ref someAnchor not quoted text is not part of ref tag * * \ref someAnchor * diff --git a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java index 50c36b6f7..da05d51f6 100644 --- a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java +++ b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java @@ -111,10 +111,11 @@ public class doxygen_translate_all_tags_runme { " @param a the first param\n"); wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func08(int)", - "<a id=\"#someAnchor\"></a>\n" + + "<a id=\"someAnchor\"></a>\n" + "Text after anchor.\n" + - "<i>Anchor description</i>\n" + - "<i>someAnchor</i>\n" + + "<a href="someAnchor">Anchor description</a>\n" + + "<a href="someAnchor">someAnchor</a>\n" + + "<a href="someAnchor">someAnchor</a>\n" + " Remarks: Some remark text \n" + " Remarks: Another remarks section \n" + " @return Whatever \n" + diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index 051a9a51e..65c74b2ba 100755 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -230,6 +230,12 @@ r""" commentVerifier.check(doxygen_translate_all_tags.func08.__doc__, r""" + Text after anchor. + + 'Anchor description' + 'someAnchor' + 'someAnchor' + Remarks: Some remark text Another remarks section diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 08dae5a86..57a0c5bd0 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -693,11 +693,23 @@ int DoxygenParser::addCommandUnique(const std::string &theCommand, return 0; } DoxygenEntityList aNewList; - TokenListCIt endOfLine = getOneLine(tokList); - if (endOfLine != m_tokenListIt) { - aNewList = parse(endOfLine, tokList); - } aNewList.push_front(DoxygenEntity("plainstd::string", name)); + // TokenListCIt endOfLine = getOneLine(tokList); + // if (endOfLine != m_tokenListIt) { + // aNewList = parse(endOfLine, tokList); + //} + TokenListCIt tmpIt = m_tokenListIt; + std::string refTitle = getNextWord(); + // If title is following the ref tag, it must be quoted. Otherwise + // doxy puts link on ref id. + if (refTitle.size() > 1 && refTitle[0] == '"') { + // remove quotes + refTitle = refTitle.substr(1, refTitle.size() - 2); + aNewList.push_back(DoxygenEntity("plainstd::string", refTitle)); + } else { + // no quoted string is following, so we have to restore iterator + m_tokenListIt = tmpIt; + } doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \subpage <name> ["(text)"] diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index f9d27c84c..b0a18b991 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -409,7 +409,7 @@ void JavaDocConverter::handleTagAnchor(DoxygenEntity& tag, std::string& translatedComment, std::string &) { - translatedComment += "<a id=\"#" + translateSubtree(tag) + "\"></a>"; + translatedComment += "<a id=\"" + translateSubtree(tag) + "\"></a>"; } @@ -455,7 +455,15 @@ void JavaDocConverter::handleNewLine(DoxygenEntity&, std::string& translatedComment, std::string&) { - translatedComment += "\n * "; + // <br> tag is added, because otherwise to much text is joined + // into same paragraph by javadoc. For example, doxy list: + // - item one + // - item two + // becomes one paragraph with surrounding text without newlines. + // This way we get to many empty lines in javadoc output, but this + // is still better than joined lines. Possibility for improvements + // exists. + translatedComment += "<br>\n * "; } void JavaDocConverter::handleTagChar(DoxygenEntity& tag, @@ -608,24 +616,17 @@ void JavaDocConverter::handleTagRef(DoxygenEntity& tag, std::string&) { std::string dummy; -// translatedComment += "1111"; if (!tag.entityList.size()) return; -// translatedComment += "2222"; - //if (!paramExists(tag.entityList.begin()->data)) -// return; - - // we don't translate to link, since \page is not supported in Java, but we - // make text in italic, so that reader at least knows what to look at. - // translatedComment += "<i>"; - // tag.entityList.pop_front(); - // translatedComment += translateSubtree(tag); - // translatedComment += "</i>"; + + // we translate to link, although \page is not supported in Java, but + // reader at least knows what to look at. Also for \anchor tag on the same + // page this link works. string anchor = tag.entityList.begin()->data; tag.entityList.pop_front(); - string anchorText = translateSubtree(tag); - if (anchorText.find_first_not_of(" \t") == string::npos) { - anchorText = anchor; + string anchorText = anchor; + if (!tag.entityList.empty()) { + anchorText = tag.entityList.begin()->data; } translatedComment += "<a href=\"#" + anchor + "\">" + anchorText + "</a>"; } diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index b0355e9c2..78bf6bb88 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -131,8 +131,7 @@ protected: */ void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /* - * Writes text of \ref tag in italic. Does not produce link, because javadoc - * does not support page and section tags. + * Writes link for \ref tag. */ void handleTagRef(DoxygenEntity& tag, std::string& translatedComment, std::string&); diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 4346fb99c..5a1bbbc6f 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -134,6 +134,7 @@ void PyDocConverter::fillStaticTables() tagHandlers["par"] = make_pair(&PyDocConverter::handleTagPar, ""); tagHandlers["param"] = make_pair(&PyDocConverter::handleTagParam, ""); tagHandlers["tparam"] = make_pair(&PyDocConverter::handleTagParam, ""); + tagHandlers["ref"] = make_pair(&PyDocConverter::handleTagRef, ""); // this command just prints it's contents // (it is internal command of swig's parser, contains plain text) tagHandlers["plainstd::string"] = make_pair( @@ -416,6 +417,25 @@ void PyDocConverter::handleTagParam(DoxygenEntity& tag, handleParagraph(tag, translatedComment, dummy); } + +void PyDocConverter::handleTagRef(DoxygenEntity& tag, + std::string& translatedComment, + std::string&) +{ + std::string dummy; + if (!tag.entityList.size()) + return; + + string anchor = tag.entityList.begin()->data; + tag.entityList.pop_front(); + string anchorText = anchor; + if (!tag.entityList.empty()) { + anchorText = tag.entityList.begin()->data; + } + translatedComment += "'" + anchorText + "'"; +} + + void PyDocConverter::handleTagWrap(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index ec831a1a2..e0ac9cbc0 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -108,7 +108,11 @@ protected: * Format nice param description with type information */ void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); - + /* + * Writes text for \ref tag. + */ + void handleTagRef(DoxygenEntity& tag, std::string& translatedComment, std::string&); + /* Handles HTML tags recognized by Doxygen, like <A ...>, <ul>, <table>, ... */ void handleDoxyHtmlTag(DoxygenEntity& tag, std::string& translatedComment, std::string &arg); |