fixed bug in handling of ref tag in Java, added handling in Python

This commit is contained in:
Marko Klopcic 2013-03-17 20:09:34 +01:00
commit 4663fce63c
8 changed files with 71 additions and 26 deletions

View file

@ -277,7 +277,9 @@ int func07(int a)
* *
* \publicsection * \publicsection
* *
* \ref someAnchor Anchor description * \ref someAnchor "Anchor description"
*
* \ref someAnchor not quoted text is not part of ref tag
* *
* \ref someAnchor * \ref someAnchor
* *

View file

@ -111,10 +111,11 @@ public class doxygen_translate_all_tags_runme {
" @param a the first param\n"); " @param a the first param\n");
wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func08(int)", 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" + "Text after anchor.\n" +
"<i>Anchor description</i>\n" + "<a href="someAnchor">Anchor description</a>\n" +
"<i>someAnchor</i>\n" + "<a href="someAnchor">someAnchor</a>\n" +
"<a href="someAnchor">someAnchor</a>\n" +
" Remarks: Some remark text \n" + " Remarks: Some remark text \n" +
" Remarks: Another remarks section \n" + " Remarks: Another remarks section \n" +
" @return Whatever \n" + " @return Whatever \n" +

View file

@ -230,6 +230,12 @@ r"""
commentVerifier.check(doxygen_translate_all_tags.func08.__doc__, commentVerifier.check(doxygen_translate_all_tags.func08.__doc__,
r""" r"""
Text after anchor.
'Anchor description'
'someAnchor'
'someAnchor'
Remarks: Some remark text Remarks: Some remark text
Another remarks section Another remarks section

View file

@ -693,11 +693,23 @@ int DoxygenParser::addCommandUnique(const std::string &theCommand,
return 0; return 0;
} }
DoxygenEntityList aNewList; DoxygenEntityList aNewList;
TokenListCIt endOfLine = getOneLine(tokList);
if (endOfLine != m_tokenListIt) {
aNewList = parse(endOfLine, tokList);
}
aNewList.push_front(DoxygenEntity("plainstd::string", name)); 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)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} }
// \subpage <name> ["(text)"] // \subpage <name> ["(text)"]

View file

@ -409,7 +409,7 @@ void JavaDocConverter::handleTagAnchor(DoxygenEntity& tag,
std::string& translatedComment, std::string& translatedComment,
std::string &) 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,
std::string&) 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, void JavaDocConverter::handleTagChar(DoxygenEntity& tag,
@ -608,24 +616,17 @@ void JavaDocConverter::handleTagRef(DoxygenEntity& tag,
std::string&) std::string&)
{ {
std::string dummy; std::string dummy;
// translatedComment += "1111";
if (!tag.entityList.size()) if (!tag.entityList.size())
return; 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 // we translate to link, although \page is not supported in Java, but
// make text in italic, so that reader at least knows what to look at. // reader at least knows what to look at. Also for \anchor tag on the same
// translatedComment += "<i>"; // page this link works.
// tag.entityList.pop_front();
// translatedComment += translateSubtree(tag);
// translatedComment += "</i>";
string anchor = tag.entityList.begin()->data; string anchor = tag.entityList.begin()->data;
tag.entityList.pop_front(); tag.entityList.pop_front();
string anchorText = translateSubtree(tag); string anchorText = anchor;
if (anchorText.find_first_not_of(" \t") == string::npos) { if (!tag.entityList.empty()) {
anchorText = anchor; anchorText = tag.entityList.begin()->data;
} }
translatedComment += "<a href=\"#" + anchor + "\">" + anchorText + "</a>"; translatedComment += "<a href=\"#" + anchor + "\">" + anchorText + "</a>";
} }

View file

@ -131,8 +131,7 @@ protected:
*/ */
void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Writes text of \ref tag in italic. Does not produce link, because javadoc * Writes link for \ref tag.
* does not support page and section tags.
*/ */
void handleTagRef(DoxygenEntity& tag, std::string& translatedComment, void handleTagRef(DoxygenEntity& tag, std::string& translatedComment,
std::string&); std::string&);

View file

@ -134,6 +134,7 @@ void PyDocConverter::fillStaticTables()
tagHandlers["par"] = make_pair(&PyDocConverter::handleTagPar, ""); tagHandlers["par"] = make_pair(&PyDocConverter::handleTagPar, "");
tagHandlers["param"] = make_pair(&PyDocConverter::handleTagParam, ""); tagHandlers["param"] = make_pair(&PyDocConverter::handleTagParam, "");
tagHandlers["tparam"] = make_pair(&PyDocConverter::handleTagParam, ""); tagHandlers["tparam"] = make_pair(&PyDocConverter::handleTagParam, "");
tagHandlers["ref"] = make_pair(&PyDocConverter::handleTagRef, "");
// this command just prints it's contents // this command just prints it's contents
// (it is internal command of swig's parser, contains plain text) // (it is internal command of swig's parser, contains plain text)
tagHandlers["plainstd::string"] = make_pair( tagHandlers["plainstd::string"] = make_pair(
@ -416,6 +417,25 @@ void PyDocConverter::handleTagParam(DoxygenEntity& tag,
handleParagraph(tag, translatedComment, dummy); 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, void PyDocConverter::handleTagWrap(DoxygenEntity& tag,
std::string& translatedComment, std::string& translatedComment,
std::string &arg) std::string &arg)

View file

@ -108,7 +108,11 @@ protected:
* Format nice param description with type information * Format nice param description with type information
*/ */
void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); 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>, ... */ /* Handles HTML tags recognized by Doxygen, like <A ...>, <ul>, <table>, ... */
void handleDoxyHtmlTag(DoxygenEntity& tag, std::string& translatedComment, std::string &arg); void handleDoxyHtmlTag(DoxygenEntity& tag, std::string& translatedComment, std::string &arg);