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

@ -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)"]

View file

@ -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>";
}

View file

@ -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&);

View file

@ -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)

View file

@ -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);