commands \f? (LateX formulas) are no longer ignored - formulas are copied literally to Java comments

This commit is contained in:
Marko Klopcic 2013-01-28 20:07:36 +01:00
commit 2df4449e3b
5 changed files with 33 additions and 44 deletions

View file

@ -59,9 +59,9 @@ public class doxygen_translate_all_tags_runme {
wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func04(int)",
" @exception SuperError \n" +
" \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" +
" \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" +
" \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" +
" \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" +
" \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" +
" \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" +
" This will only appear in hmtl \n");
wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func05(int)",

View file

@ -6,8 +6,14 @@
const char *CMD_HTML_ONLY = "htmlonly";
// doxy commands are not processed inside this block
const char *CMD_VERBATIM = "verbatim";
const char *CMD_LATEX_1 = "f$";
const char *CMD_LATEX_2 = "f{";
const char *CMD_LATEX_3 = "f[";
const char *CMD_END_HTML_ONLY = "endhtmlonly";
const char *CMD_END_VERBATIM = "endverbatim";
const char *CMD_END_LATEX_1 = "f$";
const char *CMD_END_LATEX_2 = "f}";
const char *CMD_END_LATEX_3 = "f]";
const char *sectionIndicators[] = {
"attention", "author", "authors", "brief", "bug", "cond", "date",

View file

@ -234,44 +234,6 @@ std::string DoxygenParser::getNextWord() {
return "";
}
/* TODO remove this m.
std::string DoxygenParser::getNextWordInComment() {
while (m_tokenListIt != m_tokenList.end() && (m_tokenListIt->m_tokenType == PLAINSTRING || m_tokenListIt->m_tokenType == END_LINE)) {
// handle quoted strings as words
if (m_tokenListIt->m_tokenString[0] == '"'
&& m_tokenListIt->m_tokenString[m_tokenListIt->m_tokenString.size() - 1] != '"') {
string word = m_tokenListIt->m_tokenString + " ";
while (true) {
string nextWord = getNextWord();
if (nextWord.empty()) {// maybe report unterminated string error
return word;
}
word += nextWord;
if (word[word.size() - 1] == '"') { // strip quotes
return word.substr(1, word.size() - 2);
}
word += " ";
}
}
string tokenStr = trim(m_tokenListIt->m_tokenString);
m_tokenListIt++;
if (!tokenStr.empty()) {
return tokenStr;
}
} * else if (nextToken.m_tokenType == END_LINE) {
// this handles cases when command is the last item in line, for example:
// * This method returns line number \c
// * relative to paragraph.
m_tokenListIt++;
return getNextWord();
} *
return "";
} */
DoxygenParser::TokenListCIt DoxygenParser::getOneLine(const TokenList &tokList) {
@ -315,7 +277,6 @@ std::string DoxygenParser::getStringTilEndCommand(const std::string & theCommand
string description;
while (m_tokenListIt != tokList.end()) {
//TODO: it won't output doxygen commands, need a way to fix it
if (m_tokenListIt->m_tokenType == PLAINSTRING) {
description += m_tokenListIt->m_tokenString;
} else if (m_tokenListIt->m_tokenType == END_LINE) {
@ -1137,7 +1098,8 @@ size_t DoxygenParser::processVerbatimText(size_t pos, const std::string &line)
size_t endOfWordPos = line.find_first_not_of("abcdefghijklmnopqrstuvwxyz$[]{}", pos);
string cmd = line.substr(pos, endOfWordPos - pos);
if (cmd == CMD_END_HTML_ONLY || cmd == CMD_END_VERBATIM) {
if (cmd == CMD_END_HTML_ONLY || cmd == CMD_END_VERBATIM ||
cmd == CMD_END_LATEX_1 || cmd == CMD_END_LATEX_2 || cmd == CMD_END_LATEX_3) {
m_isVerbatimText = false;
addDoxyCommand(m_tokenList, cmd);
} else {
@ -1196,7 +1158,8 @@ size_t DoxygenParser::processNormalComment(size_t pos, const std::string &line)
size_t endOfWordPos = line.find_first_not_of("abcdefghijklmnopqrstuvwxyz$[]{}", pos);
string cmd = line.substr(pos , endOfWordPos - pos);
addDoxyCommand(m_tokenList, cmd);
if (cmd == CMD_HTML_ONLY || cmd == CMD_VERBATIM) {
if (cmd == CMD_HTML_ONLY || cmd == CMD_VERBATIM ||
cmd == CMD_LATEX_1 || cmd == CMD_LATEX_2 || cmd == CMD_LATEX_3) {
m_isVerbatimText = true;
} else {
// skip any possible spaces after command, because some commands have parameters,

View file

@ -147,6 +147,12 @@ void JavaDocConverter::fillStaticTables() {
tagHandlers["remarks"] = make_pair(&JavaDocConverter::handleTagMessage, "Remarks: ");
tagHandlers["todo"] = make_pair(&JavaDocConverter::handleTagMessage, "TODO: ");
tagHandlers["verbatim"] = make_pair(&JavaDocConverter::handleTagExtended, "literal");
// \f commands output literal Latex formula, which is still better than nothing.
tagHandlers["f$"] = make_pair(&JavaDocConverter::handleTagVerbatim, "");
tagHandlers["f["] = make_pair(&JavaDocConverter::handleTagVerbatim, "");
tagHandlers["f{"] = make_pair(&JavaDocConverter::handleTagVerbatim, "");
tagHandlers["warning"] = make_pair(&JavaDocConverter::handleTagMessage, "Warning: ");
// this command just prints it's contents
// (it is internal command of swig's parser, contains plain text)
@ -413,6 +419,14 @@ void JavaDocConverter::handlePlainString(DoxygenEntity& tag, std::string& transl
}
void JavaDocConverter::handleTagVerbatim(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
translatedComment += arg + " ";
for (DoxygenEntityListCIt it = tag.entityList.begin(); it != tag.entityList.end(); it++) {
translatedComment += it->data;
}
}
void JavaDocConverter::handleTagExtended(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
std::string dummy;
translatedComment += "{@" + arg + " ";

View file

@ -55,6 +55,12 @@ protected:
*/
typedef void (JavaDocConverter::*tagHandler)(DoxygenEntity &tag,
std::string &translatedComment, std::string &arg);
/**
* Copies verbatim args of the tag to output, used for commands like \f$, ...
*/
void handleTagVerbatim(DoxygenEntity& tag, std::string& translatedComment, std::string &arg);
/*
* Wrap the command data with the html tag
* arg - html tag, with no braces