more refactoring, typedefs were introduced, DoxyCommandEnum moved to DoxygenParser
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13725 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c9eda79264
commit
46f2a16608
5 changed files with 227 additions and 132 deletions
|
|
@ -18,24 +18,6 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SIMPLECOMMAND,
|
|
||||||
COMMANDWORD,
|
|
||||||
COMMANDLINE,
|
|
||||||
COMMANDPARAGRAPH,
|
|
||||||
COMMANDENDCOMMAND,
|
|
||||||
COMMANDWORDPARAGRAPH,
|
|
||||||
COMMANDWORDLINE,
|
|
||||||
COMMANDWORDOWORDWORD,
|
|
||||||
COMMANDOWORD,
|
|
||||||
COMMANDERRORTHROW,
|
|
||||||
COMMANDUNIQUE,
|
|
||||||
END_LINE,
|
|
||||||
PARAGRAPH_END,
|
|
||||||
PLAINSTRING,
|
|
||||||
COMMAND
|
|
||||||
} DoxyCommandEnum;
|
|
||||||
|
|
||||||
class DoxygenEntity;
|
class DoxygenEntity;
|
||||||
|
|
||||||
typedef std::list <DoxygenEntity> DoxygenEntityList;
|
typedef std::list <DoxygenEntity> DoxygenEntityList;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
// Define static class members
|
// Define static class members
|
||||||
std::map<std::string, DoxyCommandEnum> DoxygenParser::doxygenCommands;
|
DoxygenParser::DoxyCommandsMap DoxygenParser::doxygenCommands;
|
||||||
std::set<std::string> DoxygenParser::doxygenSectionIndicators;
|
std::set<std::string> DoxygenParser::doxygenSectionIndicators;
|
||||||
|
|
||||||
const int TOKENSPERLINE = 8; //change this to change the printing behaviour of the token list
|
const int TOKENSPERLINE = 8; //change this to change the printing behaviour of the token list
|
||||||
|
|
@ -110,16 +110,19 @@ void DoxygenParser::printTree(const DoxygenEntityList &rootList) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int DoxygenParser::commandBelongs(const std::string &theCommand) {
|
int DoxygenParser::commandBelongs(const std::string &theCommand) {
|
||||||
std::string smallString = stringToLower(theCommand);
|
std::string smallString = stringToLower(theCommand);
|
||||||
//cout << " Looking for command " << theCommand << endl;
|
//cout << " Looking for command " << theCommand << endl;
|
||||||
std::map<std::string, DoxyCommandEnum>::iterator it;
|
std::map<std::string, DoxyCommandEnum>::iterator it =
|
||||||
it = doxygenCommands.find(smallString);
|
doxygenCommands.find(smallString);
|
||||||
if (it!=doxygenCommands.end())
|
if (it != doxygenCommands.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string DoxygenParser::getNextWord(const TokenList &tokList) {
|
std::string DoxygenParser::getNextWord(const TokenList &tokList) {
|
||||||
// MK Token nextToken = tokList.peek();
|
// MK Token nextToken = tokList.peek();
|
||||||
if (m_tokenListIt == m_tokenList.end()) {
|
if (m_tokenListIt == m_tokenList.end()) {
|
||||||
|
|
@ -703,7 +706,7 @@ int DoxygenParser::addCommandUnique(const std::string &theCommand,
|
||||||
TokenListCIt endCommand = tokList.end();
|
TokenListCIt endCommand = tokList.end();
|
||||||
|
|
||||||
// go through the commands and find closing endif or else or elseif
|
// go through the commands and find closing endif or else or elseif
|
||||||
for (TokenListCIt it = m_tokenListIt; it!=tokList.end(); it++) {
|
for (TokenListCIt it = m_tokenListIt; it != tokList.end(); it++) {
|
||||||
if (it->m_tokenType == COMMAND) {
|
if (it->m_tokenType == COMMAND) {
|
||||||
if (it->m_tokenString == "if" || it->m_tokenString == "ifnot")
|
if (it->m_tokenString == "if" || it->m_tokenString == "ifnot")
|
||||||
nestedCounter++;
|
nestedCounter++;
|
||||||
|
|
@ -742,9 +745,10 @@ int DoxygenParser::addCommand(const std::string &commandString,
|
||||||
const TokenList &tokList,
|
const TokenList &tokList,
|
||||||
DoxygenEntityList &doxyList) {
|
DoxygenEntityList &doxyList) {
|
||||||
|
|
||||||
std::string theCommand = stringToLower(commandString);
|
string theCommand = stringToLower(commandString);
|
||||||
|
|
||||||
if (theCommand == "plainstd::string") {
|
if (theCommand == "plainstd::string") {
|
||||||
std::string nextPhrase = getStringTilCommand(tokList);
|
string nextPhrase = getStringTilCommand(tokList);
|
||||||
if (noisy)
|
if (noisy)
|
||||||
cout << "Parsing plain std::string :" << nextPhrase << endl;
|
cout << "Parsing plain std::string :" << nextPhrase << endl;
|
||||||
doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase));
|
doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase));
|
||||||
|
|
@ -778,9 +782,12 @@ int DoxygenParser::addCommand(const std::string &commandString,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method converts TokenList to DoxygenEntryList.
|
||||||
|
*/
|
||||||
DoxygenEntityList DoxygenParser::parse(TokenListCIt endParsingIndex,
|
DoxygenEntityList DoxygenParser::parse(TokenListCIt endParsingIndex,
|
||||||
const TokenList &tokList,
|
const TokenList &tokList,
|
||||||
bool root) {
|
bool root) {
|
||||||
// if we are root, than any strings should be added as 'partofdescription', else as 'plainstd::string'
|
// if we are root, than any strings should be added as 'partofdescription', else as 'plainstd::string'
|
||||||
std::string currPlainstringCommandType = root ? "partofdescription" : "plainstd::string";
|
std::string currPlainstringCommandType = root ? "partofdescription" : "plainstd::string";
|
||||||
DoxygenEntityList aNewList;
|
DoxygenEntityList aNewList;
|
||||||
|
|
@ -812,22 +819,30 @@ DoxygenEntityList DoxygenParser::parse(TokenListCIt endParsingIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DoxygenEntityList DoxygenParser::createTree(const std::string &doxygenBlob, const std::string &fileName, int lineNumber) {
|
DoxygenEntityList DoxygenParser::createTree(const std::string &doxygenBlob,
|
||||||
TokenList tokList = tokenizeDoxygenComment(doxygenBlob, fileName, lineNumber);
|
const std::string &fileName,
|
||||||
if (noisy) {
|
int lineNumber) {
|
||||||
cout << "---TOKEN LIST---" << endl;
|
|
||||||
printList();
|
TokenList tokList = tokenizeDoxygenComment(doxygenBlob, fileName, lineNumber);
|
||||||
}
|
if (noisy) {
|
||||||
DoxygenEntityList rootList;
|
cout << "---TOKEN LIST---" << endl;
|
||||||
rootList = parse(tokList.end(), tokList, true);
|
printList();
|
||||||
if (noisy) {
|
}
|
||||||
cout << "PARSED LIST" << endl;
|
|
||||||
printTree(rootList);
|
DoxygenEntityList rootList = parse(tokList.end(), tokList, true);
|
||||||
}
|
|
||||||
return rootList;
|
if (noisy) {
|
||||||
|
cout << "PARSED LIST" << endl;
|
||||||
|
printTree(rootList);
|
||||||
|
}
|
||||||
|
return rootList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is one of the most important methods - it breaks the original
|
||||||
|
* doxygen comment into tokens.
|
||||||
|
*/
|
||||||
DoxygenParser::TokenList DoxygenParser::tokenizeDoxygenComment(const std::string &doxygenComment,
|
DoxygenParser::TokenList DoxygenParser::tokenizeDoxygenComment(const std::string &doxygenComment,
|
||||||
const std::string &fileName,
|
const std::string &fileName,
|
||||||
int fileLine) {
|
int fileLine) {
|
||||||
|
|
@ -842,13 +857,17 @@ DoxygenParser::TokenList DoxygenParser::tokenizeDoxygenComment(const std::string
|
||||||
while (true) {
|
while (true) {
|
||||||
isPlainString = false;
|
isPlainString = false;
|
||||||
pos = doxygenComment.find_first_of("\\@\t\n ", lastPos);
|
pos = doxygenComment.find_first_of("\\@\t\n ", lastPos);
|
||||||
if (pos == string::npos)
|
if (pos == string::npos) {
|
||||||
pos = doxygenComment.size();
|
pos = doxygenComment.size();
|
||||||
|
}
|
||||||
|
|
||||||
currentWord = doxygenComment.substr(lastPos, pos-lastPos);
|
currentWord = doxygenComment.substr(lastPos, pos-lastPos);
|
||||||
if (prevChar == '\n')
|
|
||||||
|
if (prevChar == '\n') {
|
||||||
|
|
||||||
tokList.push_back(Token(END_LINE, "\n"));
|
tokList.push_back(Token(END_LINE, "\n"));
|
||||||
else if (prevChar == '\\' || prevChar == '@') {
|
|
||||||
|
} else if (prevChar == '\\' || prevChar == '@') {
|
||||||
// it's a doxygen command
|
// it's a doxygen command
|
||||||
// hack to get commands like \\ or \@ or @\ or @@
|
// hack to get commands like \\ or \@ or @\ or @@
|
||||||
if (doxygenComment[pos] == '@' || doxygenComment[pos] == '\\') {
|
if (doxygenComment[pos] == '@' || doxygenComment[pos] == '\\') {
|
||||||
|
|
@ -871,22 +890,24 @@ DoxygenParser::TokenList DoxygenParser::tokenizeDoxygenComment(const std::string
|
||||||
// unknown commands are not translated - treated as literal string
|
// unknown commands are not translated - treated as literal string
|
||||||
tokList.push_back(Token(PLAINSTRING, currentWord));
|
tokList.push_back(Token(PLAINSTRING, currentWord));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (currentWord.size() && (currentWord[0] == '!' || currentWord[0] == '*' || currentWord[0] == '/')) {
|
} else if (currentWord.size() && (currentWord[0] == '!' || currentWord[0] == '*' || currentWord[0] == '/')) {
|
||||||
|
|
||||||
// check if it's one of the '!!!', '***', '///' of any length
|
// check if it's one of the '!!!', '***', '///' of any length
|
||||||
char c = currentWord[0];
|
char c = currentWord[0];
|
||||||
isPlainString = false;
|
isPlainString = false;
|
||||||
for (size_t i=0; i<currentWord.size(); i++)
|
for (size_t i = 0; i < currentWord.size(); i++)
|
||||||
if (currentWord[i] != c) {
|
if (currentWord[i] != c) {
|
||||||
isPlainString = true;
|
isPlainString = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
isPlainString = true;
|
isPlainString = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (isPlainString && currentWord.size())
|
if (isPlainString && currentWord.size()) {
|
||||||
tokList.push_back(Token(PLAINSTRING, currentWord));
|
tokList.push_back(Token(PLAINSTRING, currentWord));
|
||||||
|
}
|
||||||
|
|
||||||
prevChar = doxygenComment[pos];
|
prevChar = doxygenComment[pos];
|
||||||
lastPos = pos + 1;
|
lastPos = pos + 1;
|
||||||
|
|
@ -934,8 +955,6 @@ void DoxygenParser::printListError(int warningType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Swig_warning(warningType, m_fileName.c_str(),
|
Swig_warning(warningType, m_fileName.c_str(), curLine,
|
||||||
curLine,
|
"Doxygen parser warning: %s. \n", message.c_str());
|
||||||
"Doxygen parser warning: %s. \n",
|
|
||||||
message.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,55 +20,79 @@
|
||||||
class DoxygenParser {
|
class DoxygenParser {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** This class contains parts of Doxygen comment as a token. */
|
typedef enum {
|
||||||
class Token {
|
SIMPLECOMMAND,
|
||||||
public:
|
COMMANDWORD,
|
||||||
DoxyCommandEnum m_tokenType;
|
COMMANDLINE,
|
||||||
std::string m_tokenString; /* the data , such as param for @param */
|
COMMANDPARAGRAPH,
|
||||||
|
COMMANDENDCOMMAND,
|
||||||
Token(DoxyCommandEnum tType, std::string tString) :
|
COMMANDWORDPARAGRAPH,
|
||||||
m_tokenType(tType),
|
COMMANDWORDLINE,
|
||||||
m_tokenString(tString) {}
|
COMMANDWORDOWORDWORD,
|
||||||
|
COMMANDOWORD,
|
||||||
std::string toString() const {
|
COMMANDERRORTHROW,
|
||||||
|
COMMANDUNIQUE,
|
||||||
switch (m_tokenType) {
|
END_LINE,
|
||||||
case END_LINE:
|
PARAGRAPH_END,
|
||||||
return "{END OF LINE}";
|
PLAINSTRING,
|
||||||
case PARAGRAPH_END:
|
COMMAND
|
||||||
return "{END OF PARAGRAPH}";
|
} DoxyCommandEnum;
|
||||||
case PLAINSTRING:
|
|
||||||
return "{PLAINSTRING :" + m_tokenString + "}";
|
|
||||||
case COMMAND:
|
|
||||||
return "{COMMAND : " + m_tokenString + "}";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
typedef std::list<Token> TokenList;
|
|
||||||
typedef TokenList::const_iterator TokenListCIt;
|
|
||||||
typedef TokenList::iterator TokenListIt;
|
|
||||||
|
|
||||||
TokenList m_tokenList;
|
/** This class contains parts of Doxygen comment as a token. */
|
||||||
TokenListCIt m_tokenListIt;
|
class Token {
|
||||||
std::string m_fileName;
|
public:
|
||||||
int m_fileLineNo;
|
DoxyCommandEnum m_tokenType;
|
||||||
|
std::string m_tokenString; /* the data , such as param for @param */
|
||||||
|
|
||||||
|
Token(DoxyCommandEnum tType, std::string tString) :
|
||||||
|
m_tokenType(tType),
|
||||||
|
m_tokenString(tString) {}
|
||||||
|
|
||||||
|
std::string toString() const {
|
||||||
|
|
||||||
|
switch (m_tokenType) {
|
||||||
|
case END_LINE:
|
||||||
|
return "{END OF LINE}";
|
||||||
|
case PARAGRAPH_END:
|
||||||
|
return "{END OF PARAGRAPH}";
|
||||||
|
case PLAINSTRING:
|
||||||
|
return "{PLAINSTRING :" + m_tokenString + "}";
|
||||||
|
case COMMAND:
|
||||||
|
return "{COMMAND : " + m_tokenString + "}";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef std::list<Token> TokenList;
|
||||||
|
typedef TokenList::const_iterator TokenListCIt;
|
||||||
|
typedef TokenList::iterator TokenListIt;
|
||||||
|
|
||||||
|
TokenList m_tokenList;
|
||||||
|
TokenListCIt m_tokenListIt;
|
||||||
|
|
||||||
|
typedef std::map<std::string, DoxyCommandEnum> DoxyCommandsMap;
|
||||||
|
typedef DoxyCommandsMap::iterator DoxyCommandsMapIt;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Map of Doxygen commands to determine if a string is a
|
||||||
|
* command and how it needs to be parsed
|
||||||
|
*/
|
||||||
|
static DoxyCommandsMap doxygenCommands;
|
||||||
|
static std::set<std::string> doxygenSectionIndicators;
|
||||||
|
|
||||||
|
std::string m_fileName;
|
||||||
|
int m_fileLineNo;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Whether to print lots of debug info during parsing
|
* Whether to print lots of debug info during parsing
|
||||||
*/
|
*/
|
||||||
bool noisy;
|
bool noisy;
|
||||||
|
|
||||||
/*
|
|
||||||
* Map of Doxygen commands to determine if a string is a
|
|
||||||
* command and how it needs to be parsed
|
|
||||||
*/
|
|
||||||
static std::map<std::string, DoxyCommandEnum> doxygenCommands;
|
|
||||||
static std::set<std::string> doxygenSectionIndicators;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*Changes a std::string to all lower case
|
*Changes a std::string to all lower case
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -120,9 +120,19 @@ JavaDocConverter::JavaDocConverter(bool debugTranslator, bool debugParser)
|
||||||
fillStaticTables();
|
fillStaticTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent) {
|
|
||||||
|
/**
|
||||||
|
* Formats comment lines by inserting '\n *' at to long lines and tabs for
|
||||||
|
* indent. Currently it is disabled, which means original comment format is
|
||||||
|
* preserved. Experience shows, that this is usually better than breaking
|
||||||
|
* lines automatically, especially because original line endings are not removed,
|
||||||
|
* which results in short lines. To be useful, this function should have much
|
||||||
|
* better algorithm.
|
||||||
|
*/
|
||||||
|
std::string JavaDocConverter::formatCommand(std::string unformattedLine,
|
||||||
|
int indent) {
|
||||||
std::string formattedLines;
|
std::string formattedLines;
|
||||||
return unformattedLine;
|
return unformattedLine; // currently disabled
|
||||||
int lastPosition = 0;
|
int lastPosition = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int isFirstLine = 1;
|
int isFirstLine = 1;
|
||||||
|
|
@ -160,49 +170,70 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind
|
||||||
return formattedLines;
|
return formattedLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true, if the given parameter exists in the current node. If feature
|
||||||
|
* 'doxygen:nostripparams' is set, then this method always returns true.
|
||||||
|
*/
|
||||||
bool JavaDocConverter::paramExists(std::string param) {
|
bool JavaDocConverter::paramExists(std::string param) {
|
||||||
if (GetFlag(currentNode, "feature:doxygen:nostripparams"))
|
|
||||||
|
if (GetFlag(currentNode, "feature:doxygen:nostripparams")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ParmList *plist = CopyParmList(Getattr(currentNode, "parms"));
|
ParmList *plist = CopyParmList(Getattr(currentNode, "parms"));
|
||||||
Parm *p = NULL;
|
|
||||||
for (p = plist; p;) {
|
for (Parm *p = plist; p;) {
|
||||||
if (Getattr(p, "name") && Char(Getattr(p, "name")) == param)
|
|
||||||
|
if (Getattr(p, "name") && Char(Getattr(p, "name")) == param) {
|
||||||
return true;
|
return true;
|
||||||
/*
|
}
|
||||||
* doesn't seem to work always: in some cases (especially for 'self' parameters)
|
/* doesn't seem to work always: in some cases (especially for 'self' parameters)
|
||||||
* tmap:in is present, but tmap:in:next is not and so this code skips all the parameters
|
* tmap:in is present, but tmap:in:next is not and so this code skips all the parameters
|
||||||
*/
|
*/
|
||||||
//p = Getattr(p, "tmap:in") ? Getattr(p, "tmap:in:next") : nextSibling(p);
|
//p = Getattr(p, "tmap:in") ? Getattr(p, "tmap:in:next") : nextSibling(p);
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
Delete(plist);
|
Delete(plist);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string JavaDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) {
|
|
||||||
|
std::string JavaDocConverter::translateSubtree(DoxygenEntity &doxygenEntity) {
|
||||||
std::string translatedComment;
|
std::string translatedComment;
|
||||||
|
|
||||||
if (doxygenEntity.isLeaf)
|
if (doxygenEntity.isLeaf) {
|
||||||
return translatedComment;
|
return translatedComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DoxygenEntityListIt p = doxygenEntity.entityList.begin();
|
||||||
|
p != doxygenEntity.entityList.end(); p++) {
|
||||||
|
|
||||||
std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin();
|
|
||||||
while (p != doxygenEntity.entityList.end()) {
|
|
||||||
translateEntity(*p, translatedComment);
|
translateEntity(*p, translatedComment);
|
||||||
translateSubtree(*p);
|
translateSubtree(*p);
|
||||||
p++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return translatedComment;
|
return translatedComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JavaDocConverter::translateEntity(DoxygenEntity& tag, std::string& translatedComment) {
|
|
||||||
// check if we have needed handler and call it
|
/**
|
||||||
|
* Checks if a handler for the given tag exists, and calls it.
|
||||||
|
*/
|
||||||
|
void JavaDocConverter::translateEntity(DoxygenEntity &tag,
|
||||||
|
std::string &translatedComment) {
|
||||||
|
|
||||||
std::map<std::string, std::pair<tagHandler, std::string > >::iterator it;
|
std::map<std::string, std::pair<tagHandler, std::string > >::iterator it;
|
||||||
it = tagHandlers.find(tag.typeOfEntity);
|
it = tagHandlers.find(tag.typeOfEntity);
|
||||||
if (it!=tagHandlers.end())
|
|
||||||
|
if (it != tagHandlers.end()) {
|
||||||
(this->*(it->second.first))(tag, translatedComment, it->second.second);
|
(this->*(it->second.first))(tag, translatedComment, it->second.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handleTagHtml(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
|
void JavaDocConverter::handleTagHtml(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
|
||||||
if (tag.entityList.size()) { // do not include empty tags
|
if (tag.entityList.size()) { // do not include empty tags
|
||||||
std::string tagData = translateSubtree(tag);
|
std::string tagData = translateSubtree(tag);
|
||||||
|
|
@ -214,9 +245,13 @@ void JavaDocConverter::handleTagHtml(DoxygenEntity& tag, std::string& translated
|
||||||
translatedComment += "<" + arg + ">" + translateSubtree(tag) + "</" + arg + "> ";
|
translatedComment += "<" + arg + ">" + translateSubtree(tag) + "</" + arg + "> ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handleNewLine(DoxygenEntity&, std::string& translatedComment, std::string&) {
|
void JavaDocConverter::handleNewLine(DoxygenEntity&, std::string& translatedComment, std::string&) {
|
||||||
translatedComment += "\n * ";
|
translatedComment += "\n * ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handleTagChar(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
|
void JavaDocConverter::handleTagChar(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
|
||||||
// escape it if we need to, else just print
|
// escape it if we need to, else just print
|
||||||
if (arg.size())
|
if (arg.size())
|
||||||
|
|
@ -225,26 +260,35 @@ void JavaDocConverter::handleTagChar(DoxygenEntity& tag, std::string& translated
|
||||||
translatedComment += tag.typeOfEntity;
|
translatedComment += tag.typeOfEntity;
|
||||||
translatedComment += " ";
|
translatedComment += " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handles tags which are the same in Doxygen and Javadoc.
|
||||||
void JavaDocConverter::handleTagSame(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
|
void JavaDocConverter::handleTagSame(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
|
||||||
if (arg.size())
|
if (arg.size())
|
||||||
tag.typeOfEntity = arg;
|
tag.typeOfEntity = arg;
|
||||||
translatedComment += formatCommand(std::string("@" + tag.typeOfEntity + " " + translateSubtree(tag)), 2);
|
translatedComment += formatCommand(std::string("@" + tag.typeOfEntity + " " + translateSubtree(tag)), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handleParagraph(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
void JavaDocConverter::handleParagraph(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
||||||
translatedComment += formatCommand(translateSubtree(tag), 0);
|
translatedComment += formatCommand(translateSubtree(tag), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handlePlainString(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
void JavaDocConverter::handlePlainString(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
||||||
translatedComment += tag.data;
|
translatedComment += tag.data;
|
||||||
if (tag.data.size() && tag.data[tag.data.size()-1] != ' ')
|
if (tag.data.size() && tag.data[tag.data.size()-1] != ' ')
|
||||||
translatedComment += " ";
|
translatedComment += " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handleTagExtended(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
|
void JavaDocConverter::handleTagExtended(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
|
||||||
std::string dummy;
|
std::string dummy;
|
||||||
translatedComment += "{@" + arg + " ";
|
translatedComment += "{@" + arg + " ";
|
||||||
handleParagraph(tag, translatedComment, dummy);
|
handleParagraph(tag, translatedComment, dummy);
|
||||||
translatedComment += "}";
|
translatedComment += "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handleTagIf(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
|
void JavaDocConverter::handleTagIf(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
|
||||||
std::string dummy;
|
std::string dummy;
|
||||||
translatedComment += arg;
|
translatedComment += arg;
|
||||||
|
|
@ -254,11 +298,15 @@ void JavaDocConverter::handleTagIf(DoxygenEntity& tag, std::string& translatedCo
|
||||||
translatedComment += " {" + translateSubtree(tag) + "}";
|
translatedComment += " {" + translateSubtree(tag) + "}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handleTagMessage(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
|
void JavaDocConverter::handleTagMessage(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) {
|
||||||
std::string dummy;
|
std::string dummy;
|
||||||
translatedComment += formatCommand(arg, 0);
|
translatedComment += formatCommand(arg, 0);
|
||||||
handleParagraph(tag, translatedComment, dummy);
|
handleParagraph(tag, translatedComment, dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handleTagImage(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
void JavaDocConverter::handleTagImage(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
||||||
if (tag.entityList.size() < 2)
|
if (tag.entityList.size() < 2)
|
||||||
return;
|
return;
|
||||||
|
|
@ -282,6 +330,8 @@ void JavaDocConverter::handleTagImage(DoxygenEntity& tag, std::string& translate
|
||||||
translatedComment += " alt=\"" + title +"\"";
|
translatedComment += " alt=\"" + title +"\"";
|
||||||
translatedComment += " />";
|
translatedComment += " />";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handleTagPar(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
void JavaDocConverter::handleTagPar(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
||||||
std::string dummy;
|
std::string dummy;
|
||||||
translatedComment += "<p";
|
translatedComment += "<p";
|
||||||
|
|
@ -294,6 +344,7 @@ void JavaDocConverter::handleTagPar(DoxygenEntity& tag, std::string& translatedC
|
||||||
translatedComment += "</p>";
|
translatedComment += "</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handleTagParam(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
void JavaDocConverter::handleTagParam(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
||||||
std::string dummy;
|
std::string dummy;
|
||||||
if (!tag.entityList.size())
|
if (!tag.entityList.size())
|
||||||
|
|
@ -307,6 +358,7 @@ void JavaDocConverter::handleTagParam(DoxygenEntity& tag, std::string& translate
|
||||||
handleParagraph(tag, translatedComment, dummy);
|
handleParagraph(tag, translatedComment, dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string JavaDocConverter::convertLink(string linkObject) {
|
string JavaDocConverter::convertLink(string linkObject) {
|
||||||
if (GetFlag(currentNode, "feature:doxygen:nolinktranslate"))
|
if (GetFlag(currentNode, "feature:doxygen:nolinktranslate"))
|
||||||
return linkObject;
|
return linkObject;
|
||||||
|
|
@ -394,6 +446,7 @@ string JavaDocConverter::convertLink(string linkObject) {
|
||||||
return linkObject;
|
return linkObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handleTagLink(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
void JavaDocConverter::handleTagLink(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
||||||
std::string dummy;
|
std::string dummy;
|
||||||
if (!tag.entityList.size())
|
if (!tag.entityList.size())
|
||||||
|
|
@ -410,6 +463,7 @@ void JavaDocConverter::handleTagLink(DoxygenEntity& tag, std::string& translated
|
||||||
translatedComment += "}";
|
translatedComment += "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaDocConverter::handleTagSee(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
void JavaDocConverter::handleTagSee(DoxygenEntity& tag, std::string& translatedComment, std::string&) {
|
||||||
std::string dummy;
|
std::string dummy;
|
||||||
if (!tag.entityList.size())
|
if (!tag.entityList.size())
|
||||||
|
|
@ -429,33 +483,41 @@ void JavaDocConverter::handleTagSee(DoxygenEntity& tag, std::string& translatedC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int JavaDocConverter::cleanUpTree(DoxygenEntity &root, int level)
|
|
||||||
{
|
|
||||||
// this function should move all endlines out of the child entities
|
|
||||||
// for example:
|
|
||||||
// root
|
|
||||||
// -param
|
|
||||||
// --paramText
|
|
||||||
// --endline
|
|
||||||
// should be turned to
|
|
||||||
// root
|
|
||||||
// -param
|
|
||||||
// --paramText
|
|
||||||
// -endline
|
|
||||||
|
|
||||||
std::list < DoxygenEntity >::iterator it = root.entityList.begin();
|
/* This function moves all endlines at the end of child entities
|
||||||
|
* out of the child entities to the parent.
|
||||||
|
* For example, entity tree:
|
||||||
|
|
||||||
|
-root
|
||||||
|
|-param
|
||||||
|
|-paramText
|
||||||
|
|-endline
|
||||||
|
|
||||||
|
should be turned to
|
||||||
|
|
||||||
|
-root
|
||||||
|
|-param
|
||||||
|
|-paramText
|
||||||
|
|-endline
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int JavaDocConverter::shiftEndlinesUpTree(DoxygenEntity &root, int level)
|
||||||
|
{
|
||||||
|
DoxygenEntityListIt it = root.entityList.begin();
|
||||||
while (it != root.entityList.end()) {
|
while (it != root.entityList.end()) {
|
||||||
// remove endlines
|
// remove endlines
|
||||||
int ret = cleanUpTree(*it, level + 1);
|
int ret = shiftEndlinesUpTree(*it, level + 1);
|
||||||
// insert them after this element
|
// insert them after this element
|
||||||
it++;
|
it++;
|
||||||
for (int i=0; i<ret; i++)
|
for (int i = 0; i < ret; i++) {
|
||||||
root.entityList.insert(it, DoxygenEntity("plainstd::endl"));
|
root.entityList.insert(it, DoxygenEntity("plainstd::endl"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// continue only if we are not root
|
// continue only if we are not root
|
||||||
if (!level)
|
if (!level) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int removedCount = 0;
|
int removedCount = 0;
|
||||||
while (!root.entityList.empty() && root.entityList.rbegin()->typeOfEntity == "plainstd::endl") {
|
while (!root.entityList.empty() && root.entityList.rbegin()->typeOfEntity == "plainstd::endl") {
|
||||||
|
|
@ -465,6 +527,7 @@ int JavaDocConverter::cleanUpTree(DoxygenEntity &root, int level)
|
||||||
return removedCount;
|
return removedCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String *JavaDocConverter::makeDocumentation(Node *node) {
|
String *JavaDocConverter::makeDocumentation(Node *node) {
|
||||||
|
|
||||||
String *documentation = getDoxygenComment(node);
|
String *documentation = getDoxygenComment(node);
|
||||||
|
|
@ -483,10 +546,11 @@ String *JavaDocConverter::makeDocumentation(Node *node) {
|
||||||
return comment;
|
return comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation), Char(Getfile(documentation)), Getline(documentation));
|
DoxygenEntityList entityList = parser.createTree(Char(documentation),
|
||||||
|
Char(Getfile(documentation)),
|
||||||
|
Getline(documentation));
|
||||||
|
|
||||||
// entityList.sort(CompareDoxygenEntities()); sorting currently not used,
|
// entityList.sort(CompareDoxygenEntities()); sorting currently not used,
|
||||||
// see CompareDoxygenEntities::operator() in DoxygenEntity.cpp
|
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
std::cout << "---RESORTED LIST---" << std::endl;
|
std::cout << "---RESORTED LIST---" << std::endl;
|
||||||
|
|
@ -501,13 +565,19 @@ String *JavaDocConverter::makeDocumentation(Node *node) {
|
||||||
|
|
||||||
DoxygenEntity root("root", entityList);
|
DoxygenEntity root("root", entityList);
|
||||||
|
|
||||||
cleanUpTree(root);
|
shiftEndlinesUpTree(root);
|
||||||
|
|
||||||
// strip endlines at the beginning
|
// strip endlines at the beginning
|
||||||
while (root.entityList.begin()->typeOfEntity == "plainstd::endl")
|
while (!root.entityList.empty() &&
|
||||||
|
root.entityList.begin()->typeOfEntity == "plainstd::endl") {
|
||||||
root.entityList.pop_front();
|
root.entityList.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
// and at the end
|
// and at the end
|
||||||
while (root.entityList.rbegin()->typeOfEntity == "plainstd::endl")
|
while (!root.entityList.empty() &&
|
||||||
|
root.entityList.rbegin()->typeOfEntity == "plainstd::endl") {
|
||||||
root.entityList.pop_back();
|
root.entityList.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
javaDocString += translateSubtree(root);
|
javaDocString += translateSubtree(root);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ protected:
|
||||||
/*
|
/*
|
||||||
* Fix all endlines location, etc
|
* Fix all endlines location, etc
|
||||||
*/
|
*/
|
||||||
int cleanUpTree(DoxygenEntity &root, int level = 0);
|
int shiftEndlinesUpTree(DoxygenEntity &root, int level = 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert params in link-objects and references
|
* Convert params in link-objects and references
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue