Beautify doxygen source code

Just whitespace changes
This commit is contained in:
William S Fulton 2018-05-20 21:24:31 +01:00
commit 658eb26e19
11 changed files with 477 additions and 925 deletions

View file

@ -21,7 +21,9 @@ const char *sectionIndicators[] = {
"exception", "if", "ifnot", "invariant", "note", "par", "param", "exception", "if", "ifnot", "invariant", "note", "par", "param",
"tparam", "post", "pre", "remarks", "remark", "result", "return", "tparam", "post", "pre", "remarks", "remark", "result", "return",
"returns", "retval", "sa", "see", "since", "test", "throw", "throws", "returns", "retval", "sa", "see", "since", "test", "throw", "throws",
"todo", "version", "warning", "xrefitem"}; "todo", "version", "warning", "xrefitem"
};
const int sectionIndicatorsSize = sizeof(sectionIndicators) / sizeof(*sectionIndicators); const int sectionIndicatorsSize = sizeof(sectionIndicators) / sizeof(*sectionIndicators);
/* All of the doxygen commands divided up by how they are parsed */ /* All of the doxygen commands divided up by how they are parsed */
@ -31,7 +33,9 @@ const char *simpleCommands[] = {
"endcond", "endcond",
"callgraph", "callergraph", "showinitializer", "hideinitializer", "internal", "callgraph", "callergraph", "showinitializer", "hideinitializer", "internal",
"nosubgrouping", "public", "publicsection", "private", "privatesection", "nosubgrouping", "public", "publicsection", "private", "privatesection",
"protected", "protectedsection", "tableofcontents"}; "protected", "protectedsection", "tableofcontents"
};
const int simpleCommandsSize = sizeof(simpleCommands) / sizeof(*simpleCommands); const int simpleCommandsSize = sizeof(simpleCommands) / sizeof(*simpleCommands);
const char *commandWords[] = { const char *commandWords[] = {
@ -39,52 +43,72 @@ const char *commandWords[] = {
"namespace", "relatesalso", "anchor", "dontinclude", "include", "namespace", "relatesalso", "anchor", "dontinclude", "include",
"includelineno", "copydoc", "copybrief", "copydetails", "verbinclude", "includelineno", "copydoc", "copybrief", "copydetails", "verbinclude",
"htmlinclude", "extends", "implements", "memberof", "related", "relatedalso", "htmlinclude", "extends", "implements", "memberof", "related", "relatedalso",
"cite"}; "cite"
};
const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords); const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords);
const char *commandLines[] = { const char *commandLines[] = {
"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip",
"until", "property"}; "until", "property"
};
const int commandLinesSize = sizeof(commandLines) / sizeof(*commandLines); const int commandLinesSize = sizeof(commandLines) / sizeof(*commandLines);
const char *commandParagraph[] = { const char *commandParagraph[] = {
"partofdescription", "result", "return", "returns", "remarks", "remark", "partofdescription", "result", "return", "returns", "remarks", "remark",
"since", "test", "sa", "see", "pre", "post", "details", "invariant", "since", "test", "sa", "see", "pre", "post", "details", "invariant",
"deprecated", "date", "note", "warning", "version", "todo", "bug", "deprecated", "date", "note", "warning", "version", "todo", "bug",
"attention", "brief", "author", "authors", "copyright", "short"}; "attention", "brief", "author", "authors", "copyright", "short"
};
const int commandParagraphSize = sizeof(commandParagraph) / sizeof(*commandParagraph); const int commandParagraphSize = sizeof(commandParagraph) / sizeof(*commandParagraph);
const char *commandEndCommands[] = { const char *commandEndCommands[] = {
CMD_HTML_ONLY, "latexonly", "manonly", "xmlonly", "link", "rtfonly"}; CMD_HTML_ONLY, "latexonly", "manonly", "xmlonly", "link", "rtfonly"
};
const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands); const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands);
const char *commandWordParagraphs[] = { const char *commandWordParagraphs[] = {
"param", "tparam", "throw", "throws", "retval", "exception", "example"}; "param", "tparam", "throw", "throws", "retval", "exception", "example"
};
const int commandWordParagraphsSize = sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs); const int commandWordParagraphsSize = sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs);
const char *commandWordLines[] = { const char *commandWordLines[] = {
"page", "subsection", "subsubsection", "section", "paragraph", "defgroup", "page", "subsection", "subsubsection", "section", "paragraph", "defgroup",
"snippet", "mainpage"}; "snippet", "mainpage"
};
const int commandWordLinesSize = sizeof(commandWordLines) / sizeof(*commandWordLines); const int commandWordLinesSize = sizeof(commandWordLines) / sizeof(*commandWordLines);
const char *commandWordOWordOWords[] = { const char *commandWordOWordOWords[] = {
"category", "class", "protocol", "interface", "struct", "union"}; "category", "class", "protocol", "interface", "struct", "union"
};
const int commandWordOWordOWordsSize = sizeof(commandWordOWordOWords) / sizeof(*commandWordOWordOWords); const int commandWordOWordOWordsSize = sizeof(commandWordOWordOWords) / sizeof(*commandWordOWordOWords);
const char *commandOWords[] = { const char *commandOWords[] = {
"dir", "file", "cond"}; "dir", "file", "cond"
};
const int commandOWordsSize = sizeof(commandOWords) / sizeof(*commandOWords); const int commandOWordsSize = sizeof(commandOWords) / sizeof(*commandOWords);
const char *commandErrorThrowings[] = { const char *commandErrorThrowings[] = {
"annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", "annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header",
"headerfilestd::list", "inherit", "l", "postheader", "endcode", "enddot", "endmsc", "endhtmlonly", "headerfilestd::list", "inherit", "l", "postheader", "endcode", "enddot", "endmsc", "endhtmlonly",
"endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endif", "else", "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endif", "else",
"endrtfonly"}; "endrtfonly"
};
const int commandErrorThrowingsSize = sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings); const int commandErrorThrowingsSize = sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings);
const char *commandUniques[] = { const char *commandUniques[] = {
"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li", "xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li",
"if", "ifnot", "elseif", "else", "mscfile", "code", CMD_VERBATIM, "f{", "f[", "f$", "dot", "msc"}; "if", "ifnot", "elseif", "else", "mscfile", "code", CMD_VERBATIM, "f{", "f[", "f$", "dot", "msc"
};
const int commandUniquesSize = sizeof(commandUniques) / sizeof(*commandUniques); const int commandUniquesSize = sizeof(commandUniques) / sizeof(*commandUniques);
// These HTML commands are transformed when producing output in other formats. // These HTML commands are transformed when producing output in other formats.
@ -103,7 +127,10 @@ const int commandHtmlSize = sizeof(commandHtml) / sizeof(*commandHtml);
// Only entities which are translatable to plain text are used here. Others // Only entities which are translatable to plain text are used here. Others
// are copied unchanged to output. // are copied unchanged to output.
const char *commandHtmlEntities[] = { "&copy", "&trade", "&reg", // (C), (TM), (R) const char *commandHtmlEntities[] = {
"&copy", // (C)
"&trade", // (TM)
"&reg", // (R)
"&lt", // less-than symbol "&lt", // less-than symbol
"&gt", // greater-than symbol "&gt", // greater-than symbol
"&amp", // ampersand "&amp", // ampersand

View file

@ -16,10 +16,8 @@
using std::cout; using std::cout;
DoxygenEntity::DoxygenEntity(const std::string &typeEnt) : DoxygenEntity::DoxygenEntity(const std::string &typeEnt):typeOfEntity(typeEnt), isLeaf(true) {
typeOfEntity(typeEnt), }
isLeaf(true)
{}
/* Basic node for commands that have /* Basic node for commands that have
@ -27,23 +25,15 @@ DoxygenEntity::DoxygenEntity(const std::string &typeEnt) :
* example: \b word * example: \b word
* OR holding a std::string * OR holding a std::string
*/ */
DoxygenEntity::DoxygenEntity(const std::string &typeEnt, DoxygenEntity::DoxygenEntity(const std::string &typeEnt, const std::string &param1) : typeOfEntity(typeEnt), data(param1), isLeaf(true) {
const std::string &param1) : }
typeOfEntity(typeEnt),
data(param1),
isLeaf(true)
{}
/* Nonterminal node /* Nonterminal node
* contains * contains
*/ */
DoxygenEntity::DoxygenEntity(const std::string &typeEnt, DoxygenEntity::DoxygenEntity(const std::string &typeEnt, const DoxygenEntityList &entList) : typeOfEntity(typeEnt), isLeaf(false), entityList(entList) {
const DoxygenEntityList &entList) : }
typeOfEntity(typeEnt),
isLeaf(false),
entityList(entList)
{}
void DoxygenEntity::printEntity(int level) const { void DoxygenEntity::printEntity(int level) const {

View file

@ -25,10 +25,7 @@ using std::endl;
// This constant defines the (only) characters valid inside a Doxygen "word". // This constant defines the (only) characters valid inside a Doxygen "word".
// It includes some unusual ones because of the commands such as \f[, \f{, \f], // It includes some unusual ones because of the commands such as \f[, \f{, \f],
// \f} and \f$. // \f} and \f$.
static const char* DOXYGEN_WORD_CHARS = "abcdefghijklmnopqrstuvwxyz" static const char *DOXYGEN_WORD_CHARS = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789" "$[]{}";
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789"
"$[]{}";
// Define static class members // Define static class members
DoxygenParser::DoxyCommandsMap DoxygenParser::doxygenCommands; DoxygenParser::DoxyCommandsMap DoxygenParser::doxygenCommands;
@ -37,18 +34,14 @@ 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
const std::string END_HTML_TAG_MARK("/"); const std::string END_HTML_TAG_MARK("/");
DoxygenParser::DoxygenParser(bool noisy) : DoxygenParser::DoxygenParser(bool noisy) : noisy(noisy) {
noisy(noisy)
{
fillTables(); fillTables();
} }
DoxygenParser::~DoxygenParser() DoxygenParser::~DoxygenParser() {
{
} }
void DoxygenParser::fillTables() void DoxygenParser::fillTables() {
{
// run it only once // run it only once
if (doxygenCommands.size()) if (doxygenCommands.size())
return; return;
@ -98,8 +91,7 @@ void DoxygenParser::fillTables()
doxygenSectionIndicators.insert(sectionIndicators[i]); doxygenSectionIndicators.insert(sectionIndicators[i]);
} }
std::string DoxygenParser::stringToLower(const std::string &stringToConvert) std::string DoxygenParser::stringToLower(const std::string &stringToConvert) {
{
string result(stringToConvert.size(), ' '); string result(stringToConvert.size(), ' ');
@ -110,17 +102,14 @@ std::string DoxygenParser::stringToLower(const std::string &stringToConvert)
return result; return result;
} }
bool DoxygenParser::isSectionIndicator(const std::string &smallString) bool DoxygenParser::isSectionIndicator(const std::string &smallString) {
{
std::set<std::string>::iterator it = doxygenSectionIndicators.find( std::set<std::string>::iterator it = doxygenSectionIndicators.find(stringToLower(smallString));
stringToLower(smallString));
return it != doxygenSectionIndicators.end(); return it != doxygenSectionIndicators.end();
} }
void DoxygenParser::printTree(const DoxygenEntityList &rootList) void DoxygenParser::printTree(const DoxygenEntityList &rootList) {
{
DoxygenEntityList::const_iterator p = rootList.begin(); DoxygenEntityList::const_iterator p = rootList.begin();
while (p != rootList.end()) { while (p != rootList.end()) {
(*p).printEntity(0); (*p).printEntity(0);
@ -128,20 +117,16 @@ void DoxygenParser::printTree(const DoxygenEntityList &rootList)
} }
} }
DoxygenParser::DoxyCommandEnum DoxygenParser::DoxyCommandEnum DoxygenParser::commandBelongs(const std::string &theCommand) {
DoxygenParser::commandBelongs(const std::string &theCommand)
{
DoxyCommandsMapIt it = doxygenCommands.find(stringToLower(theCommand)); DoxyCommandsMapIt it = doxygenCommands.find(stringToLower(theCommand));
if (it != doxygenCommands.end()) { if (it != doxygenCommands.end()) {
return it->second; return it->second;
} }
// Check if this command is defined as an alias. // Check if this command is defined as an alias.
if (Getattr(m_node, ("feature:doxygen:alias:" + theCommand).c_str())) { if (Getattr(m_node, ("feature:doxygen:alias:" + theCommand).c_str())) {
return COMMAND_ALIAS; return COMMAND_ALIAS;
} }
// Check if this command should be ignored. // Check if this command should be ignored.
if (String *const ignore = getIgnoreFeature(theCommand)) { if (String *const ignore = getIgnoreFeature(theCommand)) {
// Check that no value is specified for this feature ("1" is the implicit // Check that no value is specified for this feature ("1" is the implicit
@ -149,15 +134,12 @@ DoxygenParser::commandBelongs(const std::string &theCommand)
// for now we only use the attributes. // for now we only use the attributes.
if (Strcmp(ignore, "1") != 0) { if (Strcmp(ignore, "1") != 0) {
Swig_warning(WARN_PP_UNEXPECTED_TOKENS, m_fileName.c_str(), m_fileLineNo, Swig_warning(WARN_PP_UNEXPECTED_TOKENS, m_fileName.c_str(), m_fileLineNo,
"Feature \"doxygen:ignore\" value ignored for Doxygen command \"%s\".\n", "Feature \"doxygen:ignore\" value ignored for Doxygen command \"%s\".\n", theCommand.c_str());
theCommand.c_str());
} }
// Also ensure that the matching end command, if any, will be recognized. // Also ensure that the matching end command, if any, will be recognized.
const string endCommand = getIgnoreFeatureEndCommand(theCommand); const string endCommand = getIgnoreFeatureEndCommand(theCommand);
if (!endCommand.empty()) { if (!endCommand.empty()) {
Setattr(m_node, ("feature:doxygen:ignore:" + endCommand).c_str(), Setattr(m_node, ("feature:doxygen:ignore:" + endCommand).c_str(), NewString("1"));
NewString("1"));
} }
return COMMAND_IGNORE; return COMMAND_IGNORE;
@ -166,8 +148,7 @@ DoxygenParser::commandBelongs(const std::string &theCommand)
return NONE; return NONE;
} }
std::string DoxygenParser::trim(const std::string &text) std::string DoxygenParser::trim(const std::string &text) {
{
size_t start = text.find_first_not_of(" \t"); size_t start = text.find_first_not_of(" \t");
size_t end = text.find_last_not_of(" \t"); size_t end = text.find_last_not_of(" \t");
@ -177,8 +158,7 @@ std::string DoxygenParser::trim(const std::string &text)
return text.substr(start, end - start + 1); return text.substr(start, end - start + 1);
} }
bool DoxygenParser::isEndOfLine() bool DoxygenParser::isEndOfLine() {
{
if (m_tokenListIt == m_tokenList.end()) { if (m_tokenListIt == m_tokenList.end()) {
return false; return false;
} }
@ -186,22 +166,19 @@ bool DoxygenParser::isEndOfLine()
return nextToken.m_tokenType == END_LINE; return nextToken.m_tokenType == END_LINE;
} }
void DoxygenParser::skipWhitespaceTokens() void DoxygenParser::skipWhitespaceTokens() {
{
if (m_tokenListIt == m_tokenList.end()) { if (m_tokenListIt == m_tokenList.end()) {
return; return;
} }
while (m_tokenListIt != m_tokenList.end() while (m_tokenListIt != m_tokenList.end()
&& (m_tokenListIt->m_tokenType == END_LINE && (m_tokenListIt->m_tokenType == END_LINE || trim(m_tokenListIt->m_tokenString).empty())) {
|| trim(m_tokenListIt->m_tokenString).empty())) {
m_tokenListIt++; m_tokenListIt++;
} }
} }
std::string DoxygenParser::getNextToken() std::string DoxygenParser::getNextToken() {
{
if (m_tokenListIt == m_tokenList.end()) { if (m_tokenListIt == m_tokenList.end()) {
return ""; return "";
@ -214,8 +191,7 @@ std::string DoxygenParser::getNextToken()
return ""; return "";
} }
std::string DoxygenParser::getNextWord() std::string DoxygenParser::getNextWord() {
{
/* if (m_tokenListIt == m_tokenList.end()) { /* if (m_tokenListIt == m_tokenList.end()) {
return ""; return "";
@ -251,8 +227,7 @@ std::string DoxygenParser::getNextWord()
return ""; return "";
} }
DoxygenParser::TokenListCIt DoxygenParser::getOneLine(const TokenList &tokList) DoxygenParser::TokenListCIt DoxygenParser::getOneLine(const TokenList &tokList) {
{
TokenListCIt endOfLineIt = m_tokenListIt; TokenListCIt endOfLineIt = m_tokenListIt;
@ -266,8 +241,7 @@ DoxygenParser::TokenListCIt DoxygenParser::getOneLine(const TokenList &tokList)
return tokList.end(); return tokList.end();
} }
std::string DoxygenParser::getStringTilCommand(const TokenList & tokList) std::string DoxygenParser::getStringTilCommand(const TokenList &tokList) {
{
if (m_tokenListIt == tokList.end()) { if (m_tokenListIt == tokList.end()) {
return ""; return "";
@ -284,9 +258,7 @@ std::string DoxygenParser::getStringTilCommand(const TokenList & tokList)
return description; return description;
} }
std::string DoxygenParser::getStringTilEndCommand( std::string DoxygenParser::getStringTilEndCommand(const std::string &theCommand, const TokenList &tokList) {
const std::string & theCommand, const TokenList & tokList)
{
if (m_tokenListIt == tokList.end()) { if (m_tokenListIt == tokList.end()) {
return ""; return "";
@ -307,15 +279,12 @@ std::string DoxygenParser::getStringTilEndCommand(
m_tokenListIt++; m_tokenListIt++;
} }
printListError(WARN_DOXYGEN_COMMAND_EXPECTED, printListError(WARN_DOXYGEN_COMMAND_EXPECTED, theCommand + " command expected");
theCommand + " command expected");
return description; return description;
} }
DoxygenParser::TokenListCIt DoxygenParser::getEndOfParagraph( DoxygenParser::TokenListCIt DoxygenParser::getEndOfParagraph(const TokenList &tokList) {
const TokenList & tokList)
{
TokenListCIt endOfParagraph = m_tokenListIt; TokenListCIt endOfParagraph = m_tokenListIt;
@ -347,9 +316,7 @@ DoxygenParser::TokenListCIt DoxygenParser::getEndOfParagraph(
return tokList.end(); return tokList.end();
} }
DoxygenParser::TokenListCIt DoxygenParser::getEndOfSection( DoxygenParser::TokenListCIt DoxygenParser::getEndOfSection(const std::string &theCommand, const TokenList &tokList) {
const std::string & theCommand, const TokenList & tokList)
{
TokenListCIt endOfParagraph = m_tokenListIt; TokenListCIt endOfParagraph = m_tokenListIt;
@ -372,9 +339,7 @@ DoxygenParser::TokenListCIt DoxygenParser::getEndOfSection(
return tokList.end(); return tokList.end();
} }
DoxygenParser::TokenListCIt DoxygenParser::getEndCommand( DoxygenParser::TokenListCIt DoxygenParser::getEndCommand(const std::string &theCommand, const TokenList &tokList) {
const std::string & theCommand, const TokenList & tokList)
{
TokenListCIt endOfCommand = m_tokenListIt; TokenListCIt endOfCommand = m_tokenListIt;
@ -390,29 +355,21 @@ DoxygenParser::TokenListCIt DoxygenParser::getEndCommand(
return tokList.end(); return tokList.end();
} }
void DoxygenParser::skipEndOfLine() void DoxygenParser::skipEndOfLine() {
{
if (m_tokenListIt != m_tokenList.end() if (m_tokenListIt != m_tokenList.end()
&& m_tokenListIt->m_tokenType == END_LINE) { && m_tokenListIt->m_tokenType == END_LINE) {
m_tokenListIt++; m_tokenListIt++;
} }
} }
void void DoxygenParser::addSimpleCommand(const std::string &theCommand, DoxygenEntityList &doxyList) {
DoxygenParser::addSimpleCommand(const std::string &theCommand,
DoxygenEntityList &doxyList)
{
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
doxyList.push_back(DoxygenEntity(theCommand)); doxyList.push_back(DoxygenEntity(theCommand));
} }
void void DoxygenParser::addCommandWord(const std::string &theCommand, const TokenList &, DoxygenEntityList &doxyList) {
DoxygenParser::addCommandWord(const std::string &theCommand,
const TokenList &,
DoxygenEntityList &doxyList)
{
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
@ -427,16 +384,11 @@ DoxygenParser::addCommandWord(const std::string &theCommand,
aNewList.push_back(DoxygenEntity("plainstd::string", name)); aNewList.push_back(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} else { } else {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
"No word followed " + theCommand + " command. Not added");
} }
} }
void void DoxygenParser::addCommandLine(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList) {
DoxygenParser::addCommandLine(const std::string &theCommand,
const TokenList &tokList,
DoxygenEntityList &doxyList)
{
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
TokenListCIt endOfLine = getOneLine(tokList); TokenListCIt endOfLine = getOneLine(tokList);
@ -445,11 +397,7 @@ DoxygenParser::addCommandLine(const std::string &theCommand,
skipEndOfLine(); skipEndOfLine();
} }
void void DoxygenParser::addCommandParagraph(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList) {
DoxygenParser::addCommandParagraph(const std::string &theCommand,
const TokenList &tokList,
DoxygenEntityList &doxyList)
{
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
@ -459,11 +407,7 @@ DoxygenParser::addCommandParagraph(const std::string &theCommand,
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} }
void void DoxygenParser::addCommandEndCommand(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList) {
DoxygenParser::addCommandEndCommand(const std::string &theCommand,
const TokenList & tokList,
DoxygenEntityList &doxyList)
{
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
TokenListCIt endCommand = getEndCommand("end" + theCommand, tokList); TokenListCIt endCommand = getEndCommand("end" + theCommand, tokList);
@ -477,19 +421,14 @@ DoxygenParser::addCommandEndCommand(const std::string &theCommand,
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} }
void void DoxygenParser::addCommandWordParagraph(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList) {
DoxygenParser::addCommandWordParagraph(const std::string &theCommand,
const TokenList &tokList,
DoxygenEntityList &doxyList)
{
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(); std::string name = getNextWord();
if (name.empty()) { if (name.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
"No word followed " + theCommand + " command. Not added");
return; return;
} }
TokenListCIt endOfParagraph = getEndOfParagraph(tokList); TokenListCIt endOfParagraph = getEndOfParagraph(tokList);
@ -499,17 +438,12 @@ DoxygenParser::addCommandWordParagraph(const std::string &theCommand,
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} }
void void DoxygenParser::addCommandWordLine(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList) {
DoxygenParser::addCommandWordLine(const std::string &theCommand,
const TokenList & tokList,
DoxygenEntityList &doxyList)
{
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(); std::string name = getNextWord();
if (name.empty()) { if (name.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
"No word followed " + theCommand + " command. Not added");
return; return;
} }
@ -521,18 +455,13 @@ DoxygenParser::addCommandWordLine(const std::string &theCommand,
//else cout << "No line followed " << theCommand << " command. Not added" << endl; //else cout << "No line followed " << theCommand << " command. Not added" << endl;
} }
void void DoxygenParser::addCommandWordOWordOWord(const std::string &theCommand, const TokenList &, DoxygenEntityList &doxyList) {
DoxygenParser::addCommandWordOWordOWord(const std::string &theCommand,
const TokenList &,
DoxygenEntityList &doxyList)
{
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(); std::string name = getNextWord();
if (name.empty()) { if (name.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
"No word followed " + theCommand + " command. Not added");
return; return;
} }
std::string headerfile = getNextWord(); std::string headerfile = getNextWord();
@ -546,11 +475,7 @@ DoxygenParser::addCommandWordOWordOWord(const std::string &theCommand,
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} }
void void DoxygenParser::addCommandOWord(const std::string &theCommand, const TokenList &, DoxygenEntityList &doxyList) {
DoxygenParser::addCommandOWord(const std::string &theCommand,
const TokenList &,
DoxygenEntityList &doxyList)
{
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
@ -560,23 +485,14 @@ DoxygenParser::addCommandOWord(const std::string &theCommand,
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} }
void void DoxygenParser::addCommandErrorThrow(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &) {
DoxygenParser::addCommandErrorThrow(const std::string &theCommand,
const TokenList &tokList,
DoxygenEntityList &)
{
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR,
"Encountered: " + theCommand "Encountered: " + theCommand + "\nThis command should not have been encountered. Behaviour past this may be unpredictable");
+ "\nThis command should not have been encountered. Behaviour past this may be unpredictable");
m_tokenListIt = getOneLine(tokList); m_tokenListIt = getOneLine(tokList);
} }
void void DoxygenParser::addCommandHtml(const std::string &theCommand, const TokenList &, DoxygenEntityList &doxyList) {
DoxygenParser::addCommandHtml(const std::string &theCommand,
const TokenList &,
DoxygenEntityList &doxyList)
{
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
@ -584,11 +500,7 @@ DoxygenParser::addCommandHtml(const std::string &theCommand,
doxyList.push_back(DoxygenEntity(theCommand, htmlTagArgs)); doxyList.push_back(DoxygenEntity(theCommand, htmlTagArgs));
} }
void void DoxygenParser::addCommandHtmlEntity(const std::string &theCommand, const TokenList &, DoxygenEntityList &doxyList) {
DoxygenParser::addCommandHtmlEntity(const std::string &theCommand,
const TokenList &,
DoxygenEntityList &doxyList)
{
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
@ -596,11 +508,7 @@ DoxygenParser::addCommandHtmlEntity(const std::string &theCommand,
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} }
void void DoxygenParser::addCommandUnique(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList) {
DoxygenParser::addCommandUnique(const std::string &theCommand,
const TokenList &tokList,
DoxygenEntityList &doxyList)
{
static std::map<std::string, std::string> endCommands; static std::map<std::string, std::string> endCommands;
DoxygenEntityList aNewList; DoxygenEntityList aNewList;
@ -616,20 +524,17 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string key = getNextWord(); std::string key = getNextWord();
if (key.empty()) { if (key.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No key followed " + theCommand + " command. Not added");
"No key followed " + theCommand + " command. Not added");
return; return;
} }
std::string heading = getNextWord(); std::string heading = getNextWord();
if (key.empty()) { if (key.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No heading followed " + theCommand + " command. Not added");
"No heading followed " + theCommand + " command. Not added");
return; return;
} }
std::string title = getNextWord(); std::string title = getNextWord();
if (title.empty()) { if (title.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No title followed " + theCommand + " command. Not added");
"No title followed " + theCommand + " command. Not added");
return; return;
} }
TokenListCIt endOfParagraph = getEndOfParagraph(tokList); TokenListCIt endOfParagraph = getEndOfParagraph(tokList);
@ -687,8 +592,7 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(); std::string name = getNextWord();
if (name.empty()) { if (name.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
"No word followed " + theCommand + " command. Not added");
return; return;
} }
DoxygenEntityList aNewList; DoxygenEntityList aNewList;
@ -705,8 +609,7 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(); std::string name = getNextWord();
if (name.empty()) { if (name.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No key followed " + theCommand + " command. Not added");
"No key followed " + theCommand + " command. Not added");
return; return;
} }
DoxygenEntityList aNewList; DoxygenEntityList aNewList;
@ -735,8 +638,7 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(); std::string name = getNextWord();
if (name.empty()) { if (name.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No name followed " + theCommand + " command. Not added");
"No name followed " + theCommand + " command. Not added");
return; return;
} }
std::string text = getNextWord(); std::string text = getNextWord();
@ -754,8 +656,7 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
// \f{env}{ ... \f} // \f{env}{ ... \f}
// \f$ ... \f$ // \f$ ... \f$
else if (theCommand == "code" || theCommand == "verbatim" else if (theCommand == "code" || theCommand == "verbatim"
|| theCommand == "dot" || theCommand == "msc" || theCommand == "f[" || theCommand == "dot" || theCommand == "msc" || theCommand == "f[" || theCommand == "f{" || theCommand == "f$") {
|| theCommand == "f{" || theCommand == "f$") {
if (!endCommands.size()) { if (!endCommands.size()) {
// fill in static table of end commands // fill in static table of end commands
endCommands["f["] = "f]"; endCommands["f["] = "f]";
@ -784,8 +685,7 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string file = getNextWord(); std::string file = getNextWord();
if (file.empty()) { if (file.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No file followed " + theCommand + " command. Not added");
"No file followed " + theCommand + " command. Not added");
return; return;
} }
std::string caption = getNextWord(); std::string caption = getNextWord();
@ -800,14 +700,12 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string format = getNextWord(); std::string format = getNextWord();
if (format.empty()) { if (format.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No format followed " + theCommand + " command. Not added");
"No format followed " + theCommand + " command. Not added");
return; return;
} }
std::string file = getNextWord(); std::string file = getNextWord();
if (file.empty()) { if (file.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No name followed " + theCommand + " command. Not added");
"No name followed " + theCommand + " command. Not added");
return; return;
} }
std::string caption = getNextWord(); std::string caption = getNextWord();
@ -828,9 +726,7 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(); std::string name = getNextWord();
if (name.empty()) { if (name.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "There should be at least one word following the '" + theCommand + "' command. Command ignored.");
"There should be at least one word following the '" + theCommand
+ "' command. Command ignored.");
return; return;
} }
DoxygenEntityList aNewList; DoxygenEntityList aNewList;
@ -843,20 +739,17 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
skipEndOfLine(); skipEndOfLine();
} }
// \if <cond> [\else ...] [\elseif <cond> ...] \endif // \if <cond> [\else ...] [\elseif <cond> ...] \endif
else if (theCommand == "if" || theCommand == "ifnot" || theCommand == "else" else if (theCommand == "if" || theCommand == "ifnot" || theCommand == "else" || theCommand == "elseif") {
|| theCommand == "elseif") {
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string cond; std::string cond;
bool skipEndif = false; // if true then we skip endif after parsing block of code bool skipEndif = false; // if true then we skip endif after parsing block of code
bool needsCond = (theCommand == "if" || theCommand == "ifnot" bool needsCond = (theCommand == "if" || theCommand == "ifnot" || theCommand == "elseif");
|| theCommand == "elseif");
if (needsCond) { if (needsCond) {
cond = getNextWord(); cond = getNextWord();
if (cond.empty()) { if (cond.empty()) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
"No word followed " + theCommand + " command. Not added");
return; return;
} }
} }
@ -871,8 +764,7 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
nestedCounter++; nestedCounter++;
else if (it->m_tokenString == "endif") else if (it->m_tokenString == "endif")
nestedCounter--; nestedCounter--;
if (nestedCounter == 1 if (nestedCounter == 1 && (it->m_tokenString == "else" || it->m_tokenString == "elseif")) { // else found
&& (it->m_tokenString == "else" || it->m_tokenString == "elseif")) { // else found
endCommand = it; endCommand = it;
break; break;
} }
@ -885,8 +777,7 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
} }
if (endCommand == tokList.end()) { if (endCommand == tokList.end()) {
printListError(WARN_DOXYGEN_COMMAND_EXPECTED, printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "No corresponding endif found");
"No corresponding endif found");
return; return;
} }
@ -900,11 +791,7 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
} }
} }
void void DoxygenParser::aliasCommand(const std::string &theCommand, const TokenList &/* tokList */ , DoxygenEntityList &doxyList) {
DoxygenParser::aliasCommand(const std::string& theCommand,
const TokenList& /* tokList */,
DoxygenEntityList &doxyList)
{
String *const alias = Getattr(m_node, ("feature:doxygen:alias:" + theCommand).c_str()); String *const alias = Getattr(m_node, ("feature:doxygen:alias:" + theCommand).c_str());
if (!alias) if (!alias)
return; return;
@ -912,9 +799,7 @@ DoxygenParser::aliasCommand(const std::string& theCommand,
doxyList.push_back(DoxygenEntity("plainstd::string", Char(alias))); doxyList.push_back(DoxygenEntity("plainstd::string", Char(alias)));
} }
String* DoxygenParser::getIgnoreFeature(const std::string& theCommand, String *DoxygenParser::getIgnoreFeature(const std::string &theCommand, const char *argument) const {
const char* argument) const
{
string feature_name = "feature:doxygen:ignore:" + theCommand; string feature_name = "feature:doxygen:ignore:" + theCommand;
if (argument) { if (argument) {
feature_name += ':'; feature_name += ':';
@ -924,8 +809,7 @@ String* DoxygenParser::getIgnoreFeature(const std::string& theCommand,
return Getattr(m_node, feature_name.c_str()); return Getattr(m_node, feature_name.c_str());
} }
string DoxygenParser::getIgnoreFeatureEndCommand(const std::string& theCommand) const string DoxygenParser::getIgnoreFeatureEndCommand(const std::string &theCommand) const {
{
// We may be dealing either with a simple command or with the starting command // We may be dealing either with a simple command or with the starting command
// of a block, as indicated by the value of "range" starting with "end". // of a block, as indicated by the value of "range" starting with "end".
string endCommand; string endCommand;
@ -946,11 +830,7 @@ string DoxygenParser::getIgnoreFeatureEndCommand(const std::string& theCommand)
return endCommand; return endCommand;
} }
void void DoxygenParser::ignoreCommand(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList) {
DoxygenParser::ignoreCommand(const std::string& theCommand,
const TokenList &tokList,
DoxygenEntityList &doxyList)
{
const string endCommand = getIgnoreFeatureEndCommand(theCommand); const string endCommand = getIgnoreFeatureEndCommand(theCommand);
if (!endCommand.empty()) { if (!endCommand.empty()) {
TokenListCIt itEnd = getEndCommand(endCommand, tokList); TokenListCIt itEnd = getEndCommand(endCommand, tokList);
@ -958,7 +838,6 @@ DoxygenParser::ignoreCommand(const std::string& theCommand,
printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "Expected " + endCommand); printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "Expected " + endCommand);
return; return;
} }
// If we ignore the command, also ignore any whitespace preceding it as we // If we ignore the command, also ignore any whitespace preceding it as we
// want to avoid having lines consisting of whitespace only or trailing // want to avoid having lines consisting of whitespace only or trailing
// whitespace in general (at least Python, with its pep8 tool, really // whitespace in general (at least Python, with its pep8 tool, really
@ -966,12 +845,10 @@ DoxygenParser::ignoreCommand(const std::string& theCommand,
if (!doxyList.empty()) { if (!doxyList.empty()) {
DoxygenEntityList::iterator i = doxyList.end(); DoxygenEntityList::iterator i = doxyList.end();
--i; --i;
if (i->typeOfEntity == "plainstd::string" && if (i->typeOfEntity == "plainstd::string" && i->data.find_first_not_of(" \t") == std::string::npos) {
i->data.find_first_not_of(" \t") == std::string::npos) {
doxyList.erase(i); doxyList.erase(i);
} }
} }
// Determine what to do with the part of the comment between the start and // Determine what to do with the part of the comment between the start and
// end commands: by default, we simply throw it away, but "contents" // end commands: by default, we simply throw it away, but "contents"
// attribute may be used to change this. // attribute may be used to change this.
@ -983,10 +860,7 @@ DoxygenParser::ignoreCommand(const std::string& theCommand,
DoxygenEntityList aNewList = parse(itEnd, tokList); DoxygenEntityList aNewList = parse(itEnd, tokList);
doxyList.splice(doxyList.end(), aNewList); doxyList.splice(doxyList.end(), aNewList);
} else { } else {
Swig_error(m_fileName.c_str(), m_fileLineNo, Swig_error(m_fileName.c_str(), m_fileLineNo, "Invalid \"doxygen:ignore\" feature \"contents\" attribute \"%s\".\n", Char(contents));
"Invalid \"doxygen:ignore\" feature \"contents\" attribute \"%s\".\n",
Char(contents)
);
return; return;
} }
} }
@ -1004,20 +878,13 @@ DoxygenParser::ignoreCommand(const std::string& theCommand,
m_tokenListIt = getOneLine(tokList); m_tokenListIt = getOneLine(tokList);
skipEndOfLine(); skipEndOfLine();
} else { } else {
Swig_error(m_fileName.c_str(), m_fileLineNo, Swig_error(m_fileName.c_str(), m_fileLineNo, "Invalid \"doxygen:ignore\" feature \"range\" attribute \"%s\".\n", Char(range));
"Invalid \"doxygen:ignore\" feature \"range\" attribute \"%s\".\n",
Char(range)
);
return; return;
} }
} }
} }
void void DoxygenParser::addCommand(const std::string &commandString, const TokenList &tokList, DoxygenEntityList &doxyList) {
DoxygenParser::addCommand(const std::string &commandString,
const TokenList &tokList,
DoxygenEntityList &doxyList)
{
string theCommand = stringToLower(commandString); string theCommand = stringToLower(commandString);
@ -1088,12 +955,9 @@ DoxygenParser::addCommand(const std::string &commandString,
/** /**
* This method converts TokenList to DoxygenEntryList. * This method converts TokenList to DoxygenEntryList.
*/ */
DoxygenEntityList DoxygenParser::parse(TokenListCIt endParsingIndex, DoxygenEntityList DoxygenParser::parse(TokenListCIt endParsingIndex, const TokenList &tokList, bool root) {
const TokenList &tokList, 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 = std::string currPlainstringCommandType = root ? "partofdescription" : "plainstd::string";
root ? "partofdescription" : "plainstd::string";
DoxygenEntityList aNewList; DoxygenEntityList aNewList;
while (m_tokenListIt != endParsingIndex) { while (m_tokenListIt != endParsingIndex) {
@ -1115,23 +979,17 @@ DoxygenEntityList DoxygenParser::parse(TokenListCIt endParsingIndex,
if (endParsingIndex != tokList.end() && m_tokenListIt == tokList.end()) { if (endParsingIndex != tokList.end() && m_tokenListIt == tokList.end()) {
// this could happen if we can't reach the original endParsingIndex // this could happen if we can't reach the original endParsingIndex
printListError(WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT, printListError(WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT, "Unexpected end of comment encountered");
"Unexpected end of comment encountered");
break; break;
} }
} }
return aNewList; return aNewList;
} }
DoxygenEntityList DoxygenParser::createTree(Node* node, String* documentation) DoxygenEntityList DoxygenParser::createTree(Node *node, String *documentation) {
{
m_node = node; m_node = node;
tokenizeDoxygenComment( tokenizeDoxygenComment(Char(documentation), Char(Getfile(documentation)), Getline(documentation));
Char(documentation),
Char(Getfile(documentation)),
Getline(documentation)
);
if (noisy) { if (noisy) {
cout << "---TOKEN LIST---" << endl; cout << "---TOKEN LIST---" << endl;
@ -1151,9 +1009,7 @@ DoxygenEntityList DoxygenParser::createTree(Node* node, String* documentation)
* Splits 'text' on 'separator' chars. Separator chars are not part of the * Splits 'text' on 'separator' chars. Separator chars are not part of the
* strings. * strings.
*/ */
DoxygenParser::StringVector DoxygenParser::split(const std::string &text, DoxygenParser::StringVector DoxygenParser::split(const std::string &text, char separator) {
char separator)
{
StringVector lines; StringVector lines;
size_t prevPos = 0, pos = 0; size_t prevPos = 0, pos = 0;
@ -1170,8 +1026,7 @@ DoxygenParser::StringVector DoxygenParser::split(const std::string &text,
* Returns true, if 'c' is one of doxygen comment block start * Returns true, if 'c' is one of doxygen comment block start
* characters: *, /, or ! * characters: *, /, or !
*/ */
bool DoxygenParser::isStartOfDoxyCommentChar(char c) bool DoxygenParser::isStartOfDoxyCommentChar(char c) {
{
return (strchr("*/!", c) != NULL); return (strchr("*/!", c) != NULL);
} }
@ -1180,9 +1035,7 @@ bool DoxygenParser::isStartOfDoxyCommentChar(char c)
* Doxygen commands. In that case true is returned. If the command is not * Doxygen commands. In that case true is returned. If the command is not
* recognized as a doxygen command, it is ignored and false is returned. * recognized as a doxygen command, it is ignored and false is returned.
*/ */
bool DoxygenParser::addDoxyCommand(DoxygenParser::TokenList &tokList, bool DoxygenParser::addDoxyCommand(DoxygenParser::TokenList &tokList, const std::string &cmd) {
const std::string &cmd)
{
if (commandBelongs(cmd) != NONE) { if (commandBelongs(cmd) != NONE) {
tokList.push_back(Token(COMMAND, cmd)); tokList.push_back(Token(COMMAND, cmd));
return true; return true;
@ -1213,17 +1066,14 @@ bool DoxygenParser::addDoxyCommand(DoxygenParser::TokenList &tokList,
* done, Doxygen commands are ignored. It is used for commands \verbatim, * done, Doxygen commands are ignored. It is used for commands \verbatim,
* \htmlonly, \f$, \f[, and \f{. * \htmlonly, \f$, \f[, and \f{.
*/ */
size_t DoxygenParser::processVerbatimText(size_t pos, const std::string &line) size_t DoxygenParser::processVerbatimText(size_t pos, const std::string &line) {
{
if (line[pos] == '\\' || line[pos] == '@') { // check for end commands if (line[pos] == '\\' || line[pos] == '@') { // check for end commands
pos++; pos++;
size_t endOfWordPos = line.find_first_not_of(DOXYGEN_WORD_CHARS, pos); size_t endOfWordPos = line.find_first_not_of(DOXYGEN_WORD_CHARS, pos);
string cmd = line.substr(pos, endOfWordPos - 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) {
|| cmd == CMD_END_LATEX_1 || cmd == CMD_END_LATEX_2
|| cmd == CMD_END_LATEX_3) {
m_isVerbatimText = false; m_isVerbatimText = false;
addDoxyCommand(m_tokenList, cmd); addDoxyCommand(m_tokenList, cmd);
@ -1241,8 +1091,7 @@ size_t DoxygenParser::processVerbatimText(size_t pos, const std::string &line)
// whitespaces are stored as plain strings // whitespaces are stored as plain strings
size_t startOfPossibleEndCmd = line.find_first_of("\\@", pos); size_t startOfPossibleEndCmd = line.find_first_of("\\@", pos);
m_tokenList.push_back( m_tokenList.push_back(Token(PLAINSTRING, line.substr(pos, startOfPossibleEndCmd - pos)));
Token(PLAINSTRING, line.substr(pos, startOfPossibleEndCmd - pos)));
pos = startOfPossibleEndCmd; pos = startOfPossibleEndCmd;
} }
@ -1253,8 +1102,7 @@ size_t DoxygenParser::processVerbatimText(size_t pos, const std::string &line)
* Processes doxy commands for escaped characters: \$ \@ \\ \& \~ \< \> \# \% \" \. \:: * Processes doxy commands for escaped characters: \$ \@ \\ \& \~ \< \> \# \% \" \. \::
* Handling this separately supports documentation text like \@someText. * Handling this separately supports documentation text like \@someText.
*/ */
bool DoxygenParser::processEscapedChars(size_t &pos, const std::string &line) bool DoxygenParser::processEscapedChars(size_t &pos, const std::string &line) {
{
if ((pos + 1) < line.size()) { if ((pos + 1) < line.size()) {
// \ and @ with trailing whitespace or quoted get to output as plain string // \ and @ with trailing whitespace or quoted get to output as plain string
@ -1264,7 +1112,6 @@ bool DoxygenParser::processEscapedChars(size_t &pos, const std::string &line)
pos++; pos++;
return true; return true;
} }
// these chars can be escaped for doxygen // these chars can be escaped for doxygen
string escapedChars = "$@\\&~<>#%\"."; string escapedChars = "$@\\&~<>#%\".";
if (escapedChars.find(line[pos + 1]) != string::npos) { if (escapedChars.find(line[pos + 1]) != string::npos) {
@ -1273,8 +1120,7 @@ bool DoxygenParser::processEscapedChars(size_t &pos, const std::string &line)
pos += 2; pos += 2;
return true; return true;
} else if ((pos + 2) < line.size() && line[pos + 1] == ':' } else if ((pos + 2) < line.size() && line[pos + 1] == ':' && line[pos + 2] == ':') {
&& line[pos + 2] == ':') {
// add command \:: - handling this separately supports documentation // add command \:: - handling this separately supports documentation
// text like \::someText // text like \::someText
@ -1289,16 +1135,14 @@ bool DoxygenParser::processEscapedChars(size_t &pos, const std::string &line)
/* /*
* Processes word doxygen commands, like \arg, \c, \b, \return, ... * Processes word doxygen commands, like \arg, \c, \b, \return, ...
*/ */
void DoxygenParser::processWordCommands(size_t &pos, const std::string &line) void DoxygenParser::processWordCommands(size_t &pos, const std::string &line) {
{
pos++; pos++;
size_t endOfWordPos = line.find_first_not_of(DOXYGEN_WORD_CHARS, pos); size_t endOfWordPos = line.find_first_not_of(DOXYGEN_WORD_CHARS, pos);
string cmd = line.substr(pos, endOfWordPos - pos); string cmd = line.substr(pos, endOfWordPos - pos);
addDoxyCommand(m_tokenList, cmd); addDoxyCommand(m_tokenList, cmd);
if (cmd == CMD_HTML_ONLY || cmd == CMD_VERBATIM || cmd == CMD_LATEX_1 if (cmd == CMD_HTML_ONLY || cmd == CMD_VERBATIM || cmd == CMD_LATEX_1 || cmd == CMD_LATEX_2 || cmd == CMD_LATEX_3) {
|| cmd == CMD_LATEX_2 || cmd == CMD_LATEX_3) {
m_isVerbatimText = true; m_isVerbatimText = true;
@ -1312,8 +1156,7 @@ void DoxygenParser::processWordCommands(size_t &pos, const std::string &line)
pos = endOfWordPos; pos = endOfWordPos;
} }
void DoxygenParser::processHtmlTags(size_t &pos, const std::string &line) void DoxygenParser::processHtmlTags(size_t &pos, const std::string &line) {
{
bool isEndHtmlTag = false; bool isEndHtmlTag = false;
pos++; pos++;
if (line.size() > pos && line[pos] == '/') { if (line.size() > pos && line[pos] == '/') {
@ -1329,24 +1172,21 @@ void DoxygenParser::processHtmlTags(size_t &pos, const std::string &line)
// prepend '<' to distinguish HTML tags from doxygen commands // prepend '<' to distinguish HTML tags from doxygen commands
if (!cmd.empty() && addDoxyCommand(m_tokenList, '<' + cmd)) { if (!cmd.empty() && addDoxyCommand(m_tokenList, '<' + cmd)) {
// it is a valid HTML command // it is a valid HTML command
if (line[pos] != '>') { // it should be HTML tag with args, if (line[pos] != '>') {
// it should be HTML tag with args,
// for example <A ...>, <IMG ...>, ... // for example <A ...>, <IMG ...>, ...
if (isEndHtmlTag) { if (isEndHtmlTag) {
m_tokenListIt = m_tokenList.end(); m_tokenListIt = m_tokenList.end();
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "Illegal end HTML tag without '>' found! Tag: " + cmd);
"Illegal end HTML tag without '>' found! Tag: " + cmd);
} }
endHtmlPos = line.find(">", pos); endHtmlPos = line.find(">", pos);
if (endHtmlPos == string::npos) { if (endHtmlPos == string::npos) {
m_tokenListIt = m_tokenList.end(); m_tokenListIt = m_tokenList.end();
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, "HTML tag without '>' found! Tag: " + cmd);
"HTML tag without '>' found! Tag: " + cmd);
} }
// add args of HTML command, like link URL, image URL, ... // add args of HTML command, like link URL, image URL, ...
m_tokenList.push_back( m_tokenList.push_back(Token(PLAINSTRING, line.substr(pos, endHtmlPos - pos)));
Token(PLAINSTRING, line.substr(pos, endHtmlPos - pos)));
pos = endHtmlPos; pos = endHtmlPos;
} else { } else {
if (isEndHtmlTag) { if (isEndHtmlTag) {
@ -1368,10 +1208,8 @@ void DoxygenParser::processHtmlTags(size_t &pos, const std::string &line)
} }
} }
void DoxygenParser::processHtmlEntities(size_t &pos, const std::string &line) void DoxygenParser::processHtmlEntities(size_t &pos, const std::string &line) {
{ size_t endOfWordPos = line.find_first_not_of("abcdefghijklmnopqrstuvwxyz", pos + 1);
size_t endOfWordPos = line.find_first_not_of("abcdefghijklmnopqrstuvwxyz",
pos + 1);
if (endOfWordPos != string::npos) { if (endOfWordPos != string::npos) {
@ -1380,13 +1218,10 @@ void DoxygenParser::processHtmlEntities(size_t &pos, const std::string &line)
// commands) nothing is added (here and in Doxygen). // commands) nothing is added (here and in Doxygen).
addDoxyCommand(m_tokenList, line.substr(pos, endOfWordPos - pos)); addDoxyCommand(m_tokenList, line.substr(pos, endOfWordPos - pos));
endOfWordPos++; // skip ';' endOfWordPos++; // skip ';'
} else { } else {
// it is not an entity - add entity for ampersand and the rest of string // it is not an entity - add entity for ampersand and the rest of string
addDoxyCommand(m_tokenList, "&amp"); addDoxyCommand(m_tokenList, "&amp");
m_tokenList.push_back( m_tokenList.push_back(Token(PLAINSTRING, line.substr(pos + 1, endOfWordPos - pos - 1)));
Token(PLAINSTRING, line.substr(pos + 1, endOfWordPos - pos - 1)));
} }
} }
pos = endOfWordPos; pos = endOfWordPos;
@ -1395,8 +1230,7 @@ void DoxygenParser::processHtmlEntities(size_t &pos, const std::string &line)
/* /*
* This method processes normal comment, which has to be tokenized. * This method processes normal comment, which has to be tokenized.
*/ */
size_t DoxygenParser::processNormalComment(size_t pos, const std::string &line) size_t DoxygenParser::processNormalComment(size_t pos, const std::string &line) {
{
switch (line[pos]) { switch (line[pos]) {
case '\\': case '\\':
case '@': case '@':
@ -1408,11 +1242,11 @@ size_t DoxygenParser::processNormalComment(size_t pos, const std::string &line)
break; break;
case ' ': // whitespace case ' ': // whitespace
case '\t': { case '\t':
{
// whitespaces are stored as plain strings // whitespaces are stored as plain strings
size_t startOfNextWordPos = line.find_first_not_of(" \t", pos + 1); size_t startOfNextWordPos = line.find_first_not_of(" \t", pos + 1);
m_tokenList.push_back( m_tokenList.push_back(Token(PLAINSTRING, line.substr(pos, startOfNextWordPos - pos)));
Token(PLAINSTRING, line.substr(pos, startOfNextWordPos - pos)));
pos = startOfNextWordPos; pos = startOfNextWordPos;
} }
break; break;
@ -1434,8 +1268,7 @@ size_t DoxygenParser::processNormalComment(size_t pos, const std::string &line)
break; break;
default: default:
m_tokenListIt = m_tokenList.end(); m_tokenListIt = m_tokenList.end();
printListError(WARN_DOXYGEN_COMMAND_ERROR, printListError(WARN_DOXYGEN_COMMAND_ERROR, std::string("Unknown special character: ") + line[pos]);
std::string("Unknown special character: ") + line[pos]);
} }
return pos; return pos;
@ -1445,10 +1278,7 @@ size_t DoxygenParser::processNormalComment(size_t pos, const std::string &line)
* This is the main method, which tokenizes Doxygen comment to words and * This is the main method, which tokenizes Doxygen comment to words and
* doxygen commands. * doxygen commands.
*/ */
void DoxygenParser::tokenizeDoxygenComment(const std::string &doxygenComment, void DoxygenParser::tokenizeDoxygenComment(const std::string &doxygenComment, const std::string &fileName, int fileLine) {
const std::string &fileName,
int fileLine)
{
m_isVerbatimText = false; m_isVerbatimText = false;
m_isInQuotedString = false; m_isInQuotedString = false;
m_tokenList.clear(); m_tokenList.clear();
@ -1477,7 +1307,6 @@ void DoxygenParser::tokenizeDoxygenComment(const std::string &doxygenComment,
m_tokenList.push_back(Token(END_LINE, "\n")); m_tokenList.push_back(Token(END_LINE, "\n"));
continue; continue;
} }
// skip sequences of '*', '/', and '!' of any length // skip sequences of '*', '/', and '!' of any length
bool isStartOfCommentLineCharFound = false; bool isStartOfCommentLineCharFound = false;
while (pos < line.size() && isStartOfDoxyCommentChar(line[pos])) { while (pos < line.size() && isStartOfDoxyCommentChar(line[pos])) {
@ -1489,7 +1318,6 @@ void DoxygenParser::tokenizeDoxygenComment(const std::string &doxygenComment,
m_tokenList.push_back(Token(END_LINE, "\n")); m_tokenList.push_back(Token(END_LINE, "\n"));
continue; continue;
} }
// if 'isStartOfCommentLineCharFound' then preserve leading spaces, so // if 'isStartOfCommentLineCharFound' then preserve leading spaces, so
// ' * comment' gets translated to ' * comment', not ' * comment' // ' * comment' gets translated to ' * comment', not ' * comment'
// This is important to keep formatting for comments translated to Python. // This is important to keep formatting for comments translated to Python.
@ -1500,7 +1328,6 @@ void DoxygenParser::tokenizeDoxygenComment(const std::string &doxygenComment,
continue; continue;
} }
} }
// line[pos] may be ' \t' or start of word, it there was no '*', '/' or '!' // line[pos] may be ' \t' or start of word, it there was no '*', '/' or '!'
// at beginning of the line. Make sure it points to start of the first word // at beginning of the line. Make sure it points to start of the first word
// in the line. // in the line.
@ -1512,13 +1339,11 @@ void DoxygenParser::tokenizeDoxygenComment(const std::string &doxygenComment,
} }
if (firstWordPos > pos) { if (firstWordPos > pos) {
m_tokenList.push_back( m_tokenList.push_back(Token(PLAINSTRING, line.substr(pos, firstWordPos - pos)));
Token(PLAINSTRING, line.substr(pos, firstWordPos - pos)));
pos = firstWordPos; pos = firstWordPos;
} }
} else { } else {
m_tokenList.push_back( m_tokenList.push_back(Token(PLAINSTRING, line.substr(0, pos)));
Token(PLAINSTRING, line.substr(0, pos)));
} }
while (pos != string::npos) { while (pos != string::npos) {
@ -1572,12 +1397,10 @@ void DoxygenParser::tokenizeDoxygenComment(const std::string &doxygenComment,
m_tokenListIt = m_tokenList.begin(); m_tokenListIt = m_tokenList.begin();
} }
void DoxygenParser::printList() void DoxygenParser::printList() {
{
int tokNo = 0; int tokNo = 0;
for (TokenListCIt it = m_tokenList.begin(); it != m_tokenList.end(); for (TokenListCIt it = m_tokenList.begin(); it != m_tokenList.end(); it++, tokNo++) {
it++, tokNo++) {
cout << it->toString() << " "; cout << it->toString() << " ";
@ -1587,8 +1410,7 @@ void DoxygenParser::printList()
} }
} }
void DoxygenParser::printListError(int warningType, const std::string &message) void DoxygenParser::printListError(int warningType, const std::string &message) {
{
int curLine = m_fileLineNo; int curLine = m_fileLineNo;
for (TokenListCIt it = m_tokenList.begin(); it != m_tokenListIt; it++) { for (TokenListCIt it = m_tokenList.begin(); it != m_tokenListIt; it++) {
if (it->m_tokenType == END_LINE) { if (it->m_tokenType == END_LINE) {
@ -1596,6 +1418,5 @@ void DoxygenParser::printListError(int warningType, const std::string &message)
} }
} }
Swig_warning(warningType, m_fileName.c_str(), curLine, Swig_warning(warningType, m_fileName.c_str(), curLine, "Doxygen parser warning: %s.\n", message.c_str());
"Doxygen parser warning: %s.\n", message.c_str());
} }

View file

@ -54,12 +54,10 @@ private:
DoxyCommandEnum m_tokenType; DoxyCommandEnum m_tokenType;
std::string m_tokenString; /* the data , such as param for @param */ std::string m_tokenString; /* the data , such as param for @param */
Token(DoxyCommandEnum tType, std::string tString) : Token(DoxyCommandEnum tType, std::string tString) : m_tokenType(tType), m_tokenString(tString) {
m_tokenType(tType), }
m_tokenString(tString) {}
std::string toString() const { std::string toString() const {
switch (m_tokenType) { switch (m_tokenType) {
case END_LINE: case END_LINE:
return "{END OF LINE}"; return "{END OF LINE}";
@ -190,8 +188,7 @@ private:
* up til the command specified is encountered * up til the command specified is encountered
*/ */
//TODO check that this behaves properly for formulas //TODO check that this behaves properly for formulas
std::string getStringTilEndCommand(const std::string &theCommand, std::string getStringTilEndCommand(const std::string &theCommand, const TokenList &tokList);
const TokenList &tokList);
/* /*
* Returns the end of a Paragraph as an iterator- * Returns the end of a Paragraph as an iterator-
@ -205,8 +202,7 @@ private:
* encounter of the same command. Example of this behaviour is \arg. * encounter of the same command. Example of this behaviour is \arg.
* If no end is encountered, returns the last token of the std::list. * If no end is encountered, returns the last token of the std::list.
*/ */
TokenListCIt getEndOfSection(const std::string &theCommand, TokenListCIt getEndOfSection(const std::string &theCommand, const TokenList &tokList);
const TokenList &tokList);
/* /*
* This method is for returning the end of a specific form of doxygen command * This method is for returning the end of a specific form of doxygen command
@ -215,14 +211,12 @@ private:
* progressTilEndCommand("endcode", tokenList); * progressTilEndCommand("endcode", tokenList);
* If the end is never encountered, it returns the end of the std::list. * If the end is never encountered, it returns the end of the std::list.
*/ */
TokenListCIt getEndCommand(const std::string &theCommand, TokenListCIt getEndCommand(const std::string &theCommand, const TokenList &tokList);
const TokenList &tokList);
/* /*
* A special method for commands such as \arg that end at the end of a * A special method for commands such as \arg that end at the end of a
* paragraph OR when another \arg is encountered * paragraph OR when another \arg is encountered
//TODO getTilAnyCommand //TODO getTilAnyCommand
TokenListCIt getTilAnyCommand(const std::string &theCommand, TokenListCIt getTilAnyCommand(const std::string &theCommand, const TokenList &tokList);
const TokenList &tokList);
*/ */
/** /**
@ -241,8 +235,7 @@ private:
* Plain commands, such as newline etc, they contain no other data * Plain commands, such as newline etc, they contain no other data
* \n \\ \@ \& \$ \# \< \> \% * \n \\ \@ \& \$ \# \< \> \%
*/ */
void addSimpleCommand(const std::string &theCommand, void addSimpleCommand(const std::string &theCommand, DoxygenEntityList &doxyList);
DoxygenEntityList &doxyList);
/* /*
* CommandWord * CommandWord
* Format: @command <word> * Format: @command <word>
@ -251,9 +244,7 @@ private:
* "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include",
* "includelineno" * "includelineno"
*/ */
void addCommandWord(const std::string &theCommand, void addCommandWord(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
/* /*
* CommandLine * CommandLine
* Format: @command (line) * Format: @command (line)
@ -261,9 +252,7 @@ private:
* "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip",
* "until", "property" * "until", "property"
*/ */
void addCommandLine(const std::string &theCommand, void addCommandLine(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
/* /*
* CommandParagraph * CommandParagraph
* Format: @command {paragraph} * Format: @command {paragraph}
@ -272,9 +261,7 @@ private:
* "details", "invariant", "deprecated", "date", "note", "warning", * "details", "invariant", "deprecated", "date", "note", "warning",
* "version", "todo", "bug", "attention", "brief", "arg", "author" * "version", "todo", "bug", "attention", "brief", "arg", "author"
*/ */
void addCommandParagraph(const std::string &theCommand, void addCommandParagraph(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
/* /*
* Command EndCommand * Command EndCommand
* Format: @command and ends at @endcommand * Format: @command and ends at @endcommand
@ -284,95 +271,69 @@ private:
* "link" * "link"
* Returns 1 if success, 0 if the endcommand is never encountered. * Returns 1 if success, 0 if the endcommand is never encountered.
*/ */
void addCommandEndCommand(const std::string &theCommand, void addCommandEndCommand(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList & tokList,
DoxygenEntityList &doxyList);
/* /*
* CommandWordParagraph * CommandWordParagraph
* Format: @command <word> {paragraph} * Format: @command <word> {paragraph}
* Commands such as param * Commands such as param
* "param", "tparam", "throw", "throws", "retval", "exception" * "param", "tparam", "throw", "throws", "retval", "exception"
*/ */
void addCommandWordParagraph(const std::string &theCommand, void addCommandWordParagraph(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList & tokList,
DoxygenEntityList &doxyList);
/* /*
* CommandWordLine * CommandWordLine
* Format: @command <word> (line) * Format: @command <word> (line)
* Commands such as param * Commands such as param
* "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup"
*/ */
void addCommandWordLine(const std::string &theCommand, void addCommandWordLine(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
/* /*
* Command Word Optional Word Optional Word * Command Word Optional Word Optional Word
* Format: @command <word> [<header-file>] [<header-name>] * Format: @command <word> [<header-file>] [<header-name>]
* Commands such as class * Commands such as class
* "category", "class", "protocol", "interface", "struct", "union" * "category", "class", "protocol", "interface", "struct", "union"
*/ */
void addCommandWordOWordOWord(const std::string &theCommand, void addCommandWordOWordOWord(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
/* /*
* Command Optional Word * Command Optional Word
* Format: @command [<word>] * Format: @command [<word>]
* Commands such as dir * Commands such as dir
* "dir", "file", "cond" * "dir", "file", "cond"
*/ */
void addCommandOWord(const std::string &theCommand, void addCommandOWord(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
/* /*
* Commands that should not be encountered (such as PHP only) * Commands that should not be encountered (such as PHP only)
* goes til the end of line then returns * goes til the end of line then returns
*/ */
void addCommandErrorThrow(const std::string &theCommand, void addCommandErrorThrow(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
void addCommandHtml(const std::string &theCommand, void addCommandHtml(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
void addCommandHtmlEntity(const std::string &theCommand, void addCommandHtmlEntity(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
/* /*
*Adds the unique commands- different process for each unique command *Adds the unique commands- different process for each unique command
*/ */
void addCommandUnique(const std::string &theCommand, void addCommandUnique(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
/* /*
* Replace the given command with its predefined alias expansion. * Replace the given command with its predefined alias expansion.
*/ */
void aliasCommand(const std::string& theCommand, void aliasCommand(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
/* /*
* Simply ignore the given command, possibly with the word following it or * Simply ignore the given command, possibly with the word following it or
* until the matching end command. * until the matching end command.
*/ */
void ignoreCommand(const std::string& theCommand, void ignoreCommand(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
/* /*
* The actual "meat" of the doxygen parser. Calls the correct addCommand...() * The actual "meat" of the doxygen parser. Calls the correct addCommand...()
* function. * function.
*/ */
void addCommand(const std::string &commandString, void addCommand(const std::string &commandString, const TokenList &tokList, DoxygenEntityList &doxyList);
const TokenList &tokList,
DoxygenEntityList &doxyList);
DoxygenEntityList parse(TokenListCIt endParsingIndex, DoxygenEntityList parse(TokenListCIt endParsingIndex, const TokenList &tokList, bool root = false);
const TokenList &tokList,
bool root = false);
/* /*
* Fill static doxygenCommands and sectionIndicators containers * Fill static doxygenCommands and sectionIndicators containers
@ -391,9 +352,7 @@ private:
/** Processes comment outside \htmlonly and \verbatim commands. */ /** Processes comment outside \htmlonly and \verbatim commands. */
size_t processNormalComment(size_t pos, const std::string &line); size_t processNormalComment(size_t pos, const std::string &line);
void tokenizeDoxygenComment(const std::string &doxygenComment, void tokenizeDoxygenComment(const std::string &doxygenComment, const std::string &fileName, int fileLine);
const std::string &fileName,
int fileLine);
void printList(); void printList();
void printListError(int warningType, const std::string &message); void printListError(int warningType, const std::string &message);
@ -411,4 +370,3 @@ public:
}; };
#endif #endif

View file

@ -14,10 +14,8 @@
#include "DoxygenTranslator.h" #include "DoxygenTranslator.h"
DoxygenTranslator::DoxygenTranslator(int flags) : DoxygenTranslator::DoxygenTranslator(int flags) : m_flags(flags), parser((flags &debug_parser) != 0) {
m_flags(flags), }
parser((flags & debug_parser) != 0)
{}
DoxygenTranslator::~DoxygenTranslator() { DoxygenTranslator::~DoxygenTranslator() {

View file

@ -26,8 +26,7 @@ using std::string;
using std::list; using std::list;
using std::vector; using std::vector;
void JavaDocConverter::fillStaticTables() void JavaDocConverter::fillStaticTables() {
{
if (tagHandlers.size()) // fill only once if (tagHandlers.size()) // fill only once
return; return;
@ -99,15 +98,13 @@ void JavaDocConverter::fillStaticTables()
tagHandlers["invariant"] = make_pair(&JavaDocConverter::handleParagraph, ""); tagHandlers["invariant"] = make_pair(&JavaDocConverter::handleParagraph, "");
tagHandlers["latexonly"] = make_pair(&JavaDocConverter::handleParagraph, ""); tagHandlers["latexonly"] = make_pair(&JavaDocConverter::handleParagraph, "");
tagHandlers["manonly"] = make_pair(&JavaDocConverter::handleParagraph, ""); tagHandlers["manonly"] = make_pair(&JavaDocConverter::handleParagraph, "");
tagHandlers["partofdescription"] = make_pair( tagHandlers["partofdescription"] = make_pair(&JavaDocConverter::handleParagraph, "");
&JavaDocConverter::handleParagraph, "");
tagHandlers["rtfonly"] = make_pair(&JavaDocConverter::handleParagraph, ""); tagHandlers["rtfonly"] = make_pair(&JavaDocConverter::handleParagraph, "");
tagHandlers["short"] = make_pair(&JavaDocConverter::handleParagraph, ""); tagHandlers["short"] = make_pair(&JavaDocConverter::handleParagraph, "");
tagHandlers["xmlonly"] = make_pair(&JavaDocConverter::handleParagraph, ""); tagHandlers["xmlonly"] = make_pair(&JavaDocConverter::handleParagraph, "");
// these commands are kept as-is, they are supported by JavaDoc // these commands are kept as-is, they are supported by JavaDoc
tagHandlers["author"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["author"] = make_pair(&JavaDocConverter::handleTagSame, "");
tagHandlers["authors"] = make_pair(&JavaDocConverter::handleTagSame, tagHandlers["authors"] = make_pair(&JavaDocConverter::handleTagSame, "author");
"author");
tagHandlers["deprecated"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["deprecated"] = make_pair(&JavaDocConverter::handleTagSame, "");
tagHandlers["exception"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["exception"] = make_pair(&JavaDocConverter::handleTagSame, "");
tagHandlers["package"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["package"] = make_pair(&JavaDocConverter::handleTagSame, "");
@ -116,8 +113,7 @@ void JavaDocConverter::fillStaticTables()
tagHandlers["ref"] = make_pair(&JavaDocConverter::handleTagRef, ""); tagHandlers["ref"] = make_pair(&JavaDocConverter::handleTagRef, "");
tagHandlers["result"] = make_pair(&JavaDocConverter::handleTagSame, "return"); tagHandlers["result"] = make_pair(&JavaDocConverter::handleTagSame, "return");
tagHandlers["return"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["return"] = make_pair(&JavaDocConverter::handleTagSame, "");
tagHandlers["returns"] = make_pair(&JavaDocConverter::handleTagSame, tagHandlers["returns"] = make_pair(&JavaDocConverter::handleTagSame, "return");
"return");
//tagHandlers["see"] = make_pair(&JavaDocConverter::handleTagSame, ""); //tagHandlers["see"] = make_pair(&JavaDocConverter::handleTagSame, "");
//tagHandlers["sa"] = make_pair(&JavaDocConverter::handleTagSame, "see"); //tagHandlers["sa"] = make_pair(&JavaDocConverter::handleTagSame, "see");
tagHandlers["since"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["since"] = make_pair(&JavaDocConverter::handleTagSame, "");
@ -126,104 +122,77 @@ void JavaDocConverter::fillStaticTables()
tagHandlers["version"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["version"] = make_pair(&JavaDocConverter::handleTagSame, "");
// these commands have special handlers // these commands have special handlers
tagHandlers["code"] = make_pair(&JavaDocConverter::handleTagExtended, "code"); tagHandlers["code"] = make_pair(&JavaDocConverter::handleTagExtended, "code");
tagHandlers["cond"] = make_pair(&JavaDocConverter::handleTagMessage, tagHandlers["cond"] = make_pair(&JavaDocConverter::handleTagMessage, "Conditional comment: ");
"Conditional comment: "); tagHandlers["copyright"] = make_pair(&JavaDocConverter::handleTagMessage, "Copyright: ");
tagHandlers["copyright"] = make_pair(&JavaDocConverter::handleTagMessage,
"Copyright: ");
tagHandlers["else"] = make_pair(&JavaDocConverter::handleTagIf, "Else: "); tagHandlers["else"] = make_pair(&JavaDocConverter::handleTagIf, "Else: ");
tagHandlers["elseif"] = make_pair(&JavaDocConverter::handleTagIf, tagHandlers["elseif"] = make_pair(&JavaDocConverter::handleTagIf, "Else if: ");
"Else if: "); tagHandlers["endcond"] = make_pair(&JavaDocConverter::handleTagMessage, "End of conditional comment.");
tagHandlers["endcond"] = make_pair(&JavaDocConverter::handleTagMessage,
"End of conditional comment.");
// space in second arg prevents Javadoc to treat '@ example' as command. File name of // space in second arg prevents Javadoc to treat '@ example' as command. File name of
// example is still informative to user. // example is still informative to user.
tagHandlers["example"] = make_pair(&JavaDocConverter::handleTagSame, tagHandlers["example"] = make_pair(&JavaDocConverter::handleTagSame, " example");
" example");
tagHandlers["if"] = make_pair(&JavaDocConverter::handleTagIf, "If: "); tagHandlers["if"] = make_pair(&JavaDocConverter::handleTagIf, "If: ");
tagHandlers["ifnot"] = make_pair(&JavaDocConverter::handleTagIf, "If not: "); tagHandlers["ifnot"] = make_pair(&JavaDocConverter::handleTagIf, "If not: ");
tagHandlers["image"] = make_pair(&JavaDocConverter::handleTagImage, ""); tagHandlers["image"] = make_pair(&JavaDocConverter::handleTagImage, "");
tagHandlers["link"] = make_pair(&JavaDocConverter::handleTagLink, ""); tagHandlers["link"] = make_pair(&JavaDocConverter::handleTagLink, "");
tagHandlers["see"] = make_pair(&JavaDocConverter::handleTagSee, ""); tagHandlers["see"] = make_pair(&JavaDocConverter::handleTagSee, "");
tagHandlers["sa"] = make_pair(&JavaDocConverter::handleTagSee, ""); tagHandlers["sa"] = make_pair(&JavaDocConverter::handleTagSee, "");
tagHandlers["note"] = make_pair(&JavaDocConverter::handleTagMessage, tagHandlers["note"] = make_pair(&JavaDocConverter::handleTagMessage, "Note: ");
"Note: ");
tagHandlers["overload"] = make_pair(&JavaDocConverter::handleTagMessage, tagHandlers["overload"] = make_pair(&JavaDocConverter::handleTagMessage,
"This is an overloaded member function, provided for" "This is an overloaded member function, provided for"
" convenience. It differs from the above function only in what" " convenience. It differs from the above function only in what" " argument(s) it accepts.");
" argument(s) it accepts.");
tagHandlers["par"] = make_pair(&JavaDocConverter::handleTagPar, ""); tagHandlers["par"] = make_pair(&JavaDocConverter::handleTagPar, "");
tagHandlers["remark"] = make_pair(&JavaDocConverter::handleTagMessage, tagHandlers["remark"] = make_pair(&JavaDocConverter::handleTagMessage, "Remarks: ");
"Remarks: "); tagHandlers["remarks"] = make_pair(&JavaDocConverter::handleTagMessage, "Remarks: ");
tagHandlers["remarks"] = make_pair(&JavaDocConverter::handleTagMessage, tagHandlers["todo"] = make_pair(&JavaDocConverter::handleTagMessage, "TODO: ");
"Remarks: "); tagHandlers["verbatim"] = make_pair(&JavaDocConverter::handleTagExtended, "literal");
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. // \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["f["] = make_pair(&JavaDocConverter::handleTagVerbatim, "");
tagHandlers["f{"] = make_pair(&JavaDocConverter::handleTagVerbatim, ""); tagHandlers["f{"] = make_pair(&JavaDocConverter::handleTagVerbatim, "");
tagHandlers["warning"] = make_pair(&JavaDocConverter::handleTagMessage, tagHandlers["warning"] = make_pair(&JavaDocConverter::handleTagMessage, "Warning: ");
"Warning: ");
// 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(&JavaDocConverter::handlePlainString, "");
&JavaDocConverter::handlePlainString, ""); tagHandlers["plainstd::endl"] = make_pair(&JavaDocConverter::handleNewLine, "");
tagHandlers["plainstd::endl"] = make_pair(&JavaDocConverter::handleNewLine,
"");
tagHandlers["n"] = make_pair(&JavaDocConverter::handleNewLine, ""); tagHandlers["n"] = make_pair(&JavaDocConverter::handleNewLine, "");
// HTML tags // HTML tags
tagHandlers["<a"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<a"); tagHandlers["<a"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<a");
tagHandlers["<b"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<b"); tagHandlers["<b"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<b");
tagHandlers["<blockquote"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, tagHandlers["<blockquote"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<blockquote");
"<blockquote"); tagHandlers["<body"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<body");
tagHandlers["<body"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
"<body");
tagHandlers["<br"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<br"); tagHandlers["<br"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<br");
tagHandlers["<center"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, tagHandlers["<center"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<center");
"<center"); tagHandlers["<caption"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<caption");
tagHandlers["<caption"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, tagHandlers["<code"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<code");
"<caption");
tagHandlers["<code"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
"<code");
tagHandlers["<dd"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<dd"); tagHandlers["<dd"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<dd");
tagHandlers["<dfn"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<dfn"); tagHandlers["<dfn"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<dfn");
tagHandlers["<div"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<div"); tagHandlers["<div"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<div");
tagHandlers["<dl"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<dl"); tagHandlers["<dl"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<dl");
tagHandlers["<dt"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<dt"); tagHandlers["<dt"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<dt");
tagHandlers["<em"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<em"); tagHandlers["<em"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<em");
tagHandlers["<form"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, tagHandlers["<form"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<form");
"<form");
tagHandlers["<hr"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<hr"); tagHandlers["<hr"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<hr");
tagHandlers["<h1"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<h1"); tagHandlers["<h1"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<h1");
tagHandlers["<h2"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<h2"); tagHandlers["<h2"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<h2");
tagHandlers["<h3"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<h3"); tagHandlers["<h3"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<h3");
tagHandlers["<i"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<i"); tagHandlers["<i"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<i");
tagHandlers["<input"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, tagHandlers["<input"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<input");
"<input");
tagHandlers["<img"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<img"); tagHandlers["<img"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<img");
tagHandlers["<li"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<li"); tagHandlers["<li"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<li");
tagHandlers["<meta"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, tagHandlers["<meta"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<meta");
"<meta"); tagHandlers["<multicol"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<multicol");
tagHandlers["<multicol"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
"<multicol");
tagHandlers["<ol"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<ol"); tagHandlers["<ol"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<ol");
tagHandlers["<p"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<p"); tagHandlers["<p"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<p");
tagHandlers["<pre"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<pre"); tagHandlers["<pre"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<pre");
tagHandlers["<small"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, tagHandlers["<small"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<small");
"<small"); tagHandlers["<span"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<span");
tagHandlers["<span"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, tagHandlers["<strong"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<strong");
"<span");
tagHandlers["<strong"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
"<strong");
tagHandlers["<sub"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<sub"); tagHandlers["<sub"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<sub");
tagHandlers["<sup"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<sup"); tagHandlers["<sup"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<sup");
tagHandlers["<table"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, tagHandlers["<table"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<table");
"<table");
tagHandlers["<td"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<td"); tagHandlers["<td"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<td");
tagHandlers["<th"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<th"); tagHandlers["<th"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<th");
tagHandlers["<tr"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<tr"); tagHandlers["<tr"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<tr");
@ -233,50 +202,33 @@ void JavaDocConverter::fillStaticTables()
tagHandlers["<var"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<var"); tagHandlers["<var"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<var");
// HTML entities // HTML entities
tagHandlers["&copy"] = make_pair(&JavaDocConverter::handleHtmlEntity, tagHandlers["&copy"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&copy");
"&copy"); tagHandlers["&trade"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&trade");
tagHandlers["&trade"] = make_pair(&JavaDocConverter::handleHtmlEntity,
"&trade");
tagHandlers["&reg"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&reg"); tagHandlers["&reg"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&reg");
tagHandlers["&lt"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&lt"); tagHandlers["&lt"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&lt");
tagHandlers["&gt"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&gt"); tagHandlers["&gt"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&gt");
tagHandlers["&amp"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&amp"); tagHandlers["&amp"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&amp");
tagHandlers["&apos"] = make_pair(&JavaDocConverter::handleHtmlEntity, tagHandlers["&apos"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&apos");
"&apos"); tagHandlers["&quot"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&quot");
tagHandlers["&quot"] = make_pair(&JavaDocConverter::handleHtmlEntity, tagHandlers["&lsquo"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&lsquo");
"&quot"); tagHandlers["&rsquo"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&rsquo");
tagHandlers["&lsquo"] = make_pair(&JavaDocConverter::handleHtmlEntity, tagHandlers["&ldquo"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&ldquo");
"&lsquo"); tagHandlers["&rdquo"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&rdquo");
tagHandlers["&rsquo"] = make_pair(&JavaDocConverter::handleHtmlEntity, tagHandlers["&ndash"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&ndash");
"&rsquo"); tagHandlers["&mdash"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&mdash");
tagHandlers["&ldquo"] = make_pair(&JavaDocConverter::handleHtmlEntity, tagHandlers["&nbsp"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&nbsp");
"&ldquo"); tagHandlers["&times"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&times");
tagHandlers["&rdquo"] = make_pair(&JavaDocConverter::handleHtmlEntity, tagHandlers["&minus"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&minus");
"&rdquo"); tagHandlers["&sdot"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&sdot");
tagHandlers["&ndash"] = make_pair(&JavaDocConverter::handleHtmlEntity,
"&ndash");
tagHandlers["&mdash"] = make_pair(&JavaDocConverter::handleHtmlEntity,
"&mdash");
tagHandlers["&nbsp"] = make_pair(&JavaDocConverter::handleHtmlEntity,
"&nbsp");
tagHandlers["&times"] = make_pair(&JavaDocConverter::handleHtmlEntity,
"&times");
tagHandlers["&minus"] = make_pair(&JavaDocConverter::handleHtmlEntity,
"&minus");
tagHandlers["&sdot"] = make_pair(&JavaDocConverter::handleHtmlEntity,
"&sdot");
tagHandlers["&sim"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&sim"); tagHandlers["&sim"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&sim");
tagHandlers["&le"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&le"); tagHandlers["&le"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&le");
tagHandlers["&ge"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&ge"); tagHandlers["&ge"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&ge");
tagHandlers["&larr"] = make_pair(&JavaDocConverter::handleHtmlEntity, tagHandlers["&larr"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&larr");
"&larr"); tagHandlers["&rarr"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&rarr");
tagHandlers["&rarr"] = make_pair(&JavaDocConverter::handleHtmlEntity,
"&rarr");
} }
JavaDocConverter::JavaDocConverter(int flags) : JavaDocConverter::JavaDocConverter(int flags) :
DoxygenTranslator(flags) DoxygenTranslator(flags) {
{
fillStaticTables(); fillStaticTables();
} }
@ -288,9 +240,7 @@ JavaDocConverter::JavaDocConverter(int flags) :
* which results in short lines. To be useful, this function should have much * which results in short lines. To be useful, this function should have much
* better algorithm. * better algorithm.
*/ */
std::string JavaDocConverter::formatCommand(std::string unformattedLine, std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent) {
int indent)
{
std::string formattedLines; std::string formattedLines;
return unformattedLine; // currently disabled return unformattedLine; // currently disabled
int lastPosition = 0; int lastPosition = 0;
@ -310,12 +260,10 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine,
if (!isFirstLine) if (!isFirstLine)
for (int j = 0; j < indent; j++) { for (int j = 0; j < indent; j++) {
formattedLines.append("\t"); formattedLines.append("\t");
} } else {
else {
isFirstLine = 0; isFirstLine = 0;
} }
formattedLines.append( formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1));
unformattedLine.substr(lastPosition, i - lastPosition + 1));
formattedLines.append("\n *"); formattedLines.append("\n *");
} }
@ -326,9 +274,7 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine,
formattedLines.append("\t"); formattedLines.append("\t");
} }
} }
formattedLines.append( formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition));
unformattedLine.substr(lastPosition,
unformattedLine.length() - lastPosition));
} }
return formattedLines; return formattedLines;
@ -341,8 +287,7 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine,
* true - parameters are copied to output regardless of presence in * true - parameters are copied to output regardless of presence in
* function params list. * function params list.
*/ */
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;
@ -367,16 +312,14 @@ bool JavaDocConverter::paramExists(std::string param)
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(); for (DoxygenEntityListIt p = doxygenEntity.entityList.begin(); p != doxygenEntity.entityList.end(); p++) {
p != doxygenEntity.entityList.end(); p++) {
translateEntity(*p, translatedComment); translateEntity(*p, translatedComment);
translateSubtree(*p); translateSubtree(*p);
@ -388,9 +331,7 @@ std::string JavaDocConverter::translateSubtree(DoxygenEntity &doxygenEntity)
/** /**
* Checks if a handler for the given tag exists, and calls it. * Checks if a handler for the given tag exists, and calls it.
*/ */
void JavaDocConverter::translateEntity(DoxygenEntity &tag, void JavaDocConverter::translateEntity(DoxygenEntity &tag, std::string &translatedComment) {
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);
@ -405,35 +346,24 @@ void JavaDocConverter::translateEntity(DoxygenEntity &tag,
} }
void JavaDocConverter::handleTagAnchor(DoxygenEntity& tag, void JavaDocConverter::handleTagAnchor(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
std::string& translatedComment,
std::string &)
{
translatedComment += "<a id=\"" + translateSubtree(tag) + "\"></a>"; translatedComment += "<a id=\"" + translateSubtree(tag) + "\"></a>";
} }
void JavaDocConverter::handleTagHtml(DoxygenEntity& tag, void JavaDocConverter::handleTagHtml(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
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);
// wrap the thing, ignoring whitespace // wrap the thing, ignoring whitespace
size_t wsPos = tagData.find_last_not_of("\n\t "); size_t wsPos = tagData.find_last_not_of("\n\t ");
if (wsPos != std::string::npos) if (wsPos != std::string::npos)
translatedComment += "<" + arg + ">" + tagData.substr(0, wsPos + 1) + "</" translatedComment += "<" + arg + ">" + tagData.substr(0, wsPos + 1) + "</" + arg + ">" + tagData.substr(wsPos + 1);
+ arg + ">" + tagData.substr(wsPos + 1);
else else
translatedComment += "<" + arg + ">" + translateSubtree(tag) + "</" + arg translatedComment += "<" + arg + ">" + translateSubtree(tag) + "</" + arg + "> ";
+ "> ";
} }
} }
void JavaDocConverter::handleDoxyHtmlTag(DoxygenEntity& tag, void JavaDocConverter::handleDoxyHtmlTag(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
std::string& translatedComment,
std::string &arg)
{
std::string htmlTagArgs = tag.data; std::string htmlTagArgs = tag.data;
if (htmlTagArgs == "/") { if (htmlTagArgs == "/") {
// end html tag, for example "</ul> // end html tag, for example "</ul>
@ -443,18 +373,12 @@ void JavaDocConverter::handleDoxyHtmlTag(DoxygenEntity& tag,
} }
} }
void JavaDocConverter::handleHtmlEntity(DoxygenEntity&, void JavaDocConverter::handleHtmlEntity(DoxygenEntity &, std::string &translatedComment, std::string &arg) {
std::string& translatedComment,
std::string &arg)
{
// html entities can be preserved for Java // html entities can be preserved for Java
translatedComment += arg + ';'; translatedComment += arg + ';';
} }
void JavaDocConverter::handleNewLine(DoxygenEntity&, void JavaDocConverter::handleNewLine(DoxygenEntity &, std::string &translatedComment, std::string &) {
std::string& translatedComment,
std::string&)
{
// <br> tag is added, because otherwise to much text is joined // <br> tag is added, because otherwise to much text is joined
// into same paragraph by javadoc. For example, doxy list: // into same paragraph by javadoc. For example, doxy list:
// - item one // - item one
@ -466,10 +390,7 @@ void JavaDocConverter::handleNewLine(DoxygenEntity&,
translatedComment += "<br>\n * "; translatedComment += "<br>\n * ";
} }
void JavaDocConverter::handleTagChar(DoxygenEntity& tag, void JavaDocConverter::handleTagChar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
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())
translatedComment += arg; translatedComment += arg;
@ -478,57 +399,37 @@ void JavaDocConverter::handleTagChar(DoxygenEntity& tag,
} }
// handles tags which are the same in Doxygen and Javadoc. // handles tags which are the same in Doxygen and Javadoc.
void JavaDocConverter::handleTagSame(DoxygenEntity& tag, void JavaDocConverter::handleTagSame(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
std::string& translatedComment,
std::string &arg)
{
if (arg.size()) if (arg.size())
tag.typeOfEntity = arg; tag.typeOfEntity = arg;
translatedComment += formatCommand( translatedComment += formatCommand(std::string("@" + tag.typeOfEntity + " " + translateSubtree(tag)), 2);
std::string("@" + tag.typeOfEntity + " " + translateSubtree(tag)), 2);
} }
void JavaDocConverter::handleParagraph(DoxygenEntity& tag, void JavaDocConverter::handleParagraph(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
std::string& translatedComment,
std::string&)
{
translatedComment += formatCommand(translateSubtree(tag), 0); translatedComment += formatCommand(translateSubtree(tag), 0);
} }
void JavaDocConverter::handlePlainString(DoxygenEntity& tag, void JavaDocConverter::handlePlainString(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
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::handleTagVerbatim(DoxygenEntity& tag, void JavaDocConverter::handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
std::string& translatedComment,
std::string &arg)
{
translatedComment += arg + " "; translatedComment += arg + " ";
for (DoxygenEntityListCIt it = tag.entityList.begin(); for (DoxygenEntityListCIt it = tag.entityList.begin(); it != tag.entityList.end(); it++) {
it != tag.entityList.end(); it++) {
translatedComment += it->data; translatedComment += it->data;
} }
} }
void JavaDocConverter::handleTagExtended(DoxygenEntity& tag, void JavaDocConverter::handleTagExtended(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
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, void JavaDocConverter::handleTagIf(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
std::string& translatedComment,
std::string &arg)
{
std::string dummy; std::string dummy;
translatedComment += arg; translatedComment += arg;
if (tag.entityList.size()) { if (tag.entityList.size()) {
@ -538,19 +439,13 @@ void JavaDocConverter::handleTagIf(DoxygenEntity& tag,
} }
} }
void JavaDocConverter::handleTagMessage(DoxygenEntity& tag, void JavaDocConverter::handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
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, void JavaDocConverter::handleTagImage(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
std::string& translatedComment,
std::string&)
{
if (tag.entityList.size() < 2) if (tag.entityList.size() < 2)
return; return;
@ -577,10 +472,7 @@ void JavaDocConverter::handleTagImage(DoxygenEntity& tag,
translatedComment += "/>"; translatedComment += "/>";
} }
void JavaDocConverter::handleTagPar(DoxygenEntity& tag, void JavaDocConverter::handleTagPar(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
std::string& translatedComment,
std::string&)
{
std::string dummy; std::string dummy;
translatedComment += "<p"; translatedComment += "<p";
if (tag.entityList.size()) { if (tag.entityList.size()) {
@ -593,10 +485,7 @@ void JavaDocConverter::handleTagPar(DoxygenEntity& tag,
} }
void JavaDocConverter::handleTagParam(DoxygenEntity& tag, void JavaDocConverter::handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
std::string& translatedComment,
std::string&)
{
std::string dummy; std::string dummy;
if (!tag.entityList.size()) if (!tag.entityList.size())
@ -611,10 +500,7 @@ void JavaDocConverter::handleTagParam(DoxygenEntity& tag,
} }
void JavaDocConverter::handleTagRef(DoxygenEntity& tag, void JavaDocConverter::handleTagRef(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
std::string& translatedComment,
std::string&)
{
std::string dummy; std::string dummy;
if (!tag.entityList.size()) if (!tag.entityList.size())
return; return;
@ -632,15 +518,13 @@ void JavaDocConverter::handleTagRef(DoxygenEntity& tag,
} }
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;
// find the params in function in linkObject (if any) // find the params in function in linkObject (if any)
size_t lbracePos = linkObject.find('(', 0); size_t lbracePos = linkObject.find('(', 0);
size_t rbracePos = linkObject.find(')', 0); size_t rbracePos = linkObject.find(')', 0);
if (lbracePos == string::npos || rbracePos == string::npos if (lbracePos == string::npos || rbracePos == string::npos || lbracePos >= rbracePos)
|| lbracePos >= rbracePos)
return ""; return "";
string paramsStr = linkObject.substr(lbracePos + 1, string paramsStr = linkObject.substr(lbracePos + 1,
@ -699,8 +583,7 @@ string JavaDocConverter::convertLink(string linkObject)
typeNameStart = 0; typeNameStart = 0;
else else
typeNameStart++; typeNameStart++;
Append(swigType, Append(swigType, paramStr.substr(typeNameStart, j - typeNameStart + 1).c_str());
paramStr.substr(typeNameStart, j - typeNameStart + 1).c_str());
break; break;
} }
} }
@ -708,8 +591,7 @@ string JavaDocConverter::convertLink(string linkObject)
// make dummy param list, to lookup typemaps for it // make dummy param list, to lookup typemaps for it
Parm *dummyParam = NewParm(swigType, "", 0); Parm *dummyParam = NewParm(swigType, "", 0);
Swig_typemap_attach_parms("jstype", dummyParam, NULL); Swig_typemap_attach_parms("jstype", dummyParam, NULL);
Language::instance()->replaceSpecialVariables(0, Language::instance()->replaceSpecialVariables(0, Getattr(dummyParam, "tmap:jstype"), dummyParam);
Getattr(dummyParam, "tmap:jstype"), dummyParam);
//Swig_print(dummyParam, 1); //Swig_print(dummyParam, 1);
linkObject += Char(Getattr(dummyParam, "tmap:jstype")); linkObject += Char(Getattr(dummyParam, "tmap:jstype"));
@ -724,10 +606,7 @@ string JavaDocConverter::convertLink(string linkObject)
return linkObject + additionalObject; return linkObject + additionalObject;
} }
void JavaDocConverter::handleTagLink(DoxygenEntity& tag, void JavaDocConverter::handleTagLink(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
std::string& translatedComment,
std::string&)
{
std::string dummy; std::string dummy;
if (!tag.entityList.size()) if (!tag.entityList.size())
return; return;
@ -743,10 +622,7 @@ void JavaDocConverter::handleTagLink(DoxygenEntity& tag,
translatedComment += "}"; translatedComment += "}";
} }
void JavaDocConverter::handleTagSee(DoxygenEntity& tag, void JavaDocConverter::handleTagSee(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
std::string& translatedComment,
std::string&)
{
std::string dummy; std::string dummy;
if (!tag.entityList.size()) if (!tag.entityList.size())
return; return;
@ -762,7 +638,6 @@ void JavaDocConverter::handleTagSee(DoxygenEntity& tag,
// handleNewLine(*it, translatedComment, dummy); // handleNewLine(*it, translatedComment, dummy);
continue; continue;
} }
// restore entities which may be used in C++ type declaration // restore entities which may be used in C++ type declaration
if (it->typeOfEntity == "&amp") { if (it->typeOfEntity == "&amp") {
methodRef += '&'; methodRef += '&';
@ -779,8 +654,7 @@ void JavaDocConverter::handleTagSee(DoxygenEntity& tag,
size_t lbrace = methodRef.find('('); size_t lbrace = methodRef.find('(');
size_t dblColon = methodRef.find("::"); size_t dblColon = methodRef.find("::");
if (dblColon < lbrace) { if (dblColon < lbrace) {
methodRef = methodRef.substr(0, dblColon) + '#' methodRef = methodRef.substr(0, dblColon) + '#' + methodRef.substr(dblColon + 2);
+ methodRef.substr(dblColon + 2);
} }
translatedComment += "@see "; translatedComment += "@see ";
@ -808,8 +682,7 @@ void JavaDocConverter::handleTagSee(DoxygenEntity& tag,
|-endline |-endline
* *
*/ */
int JavaDocConverter::shiftEndlinesUpTree(DoxygenEntity &root, int level) int JavaDocConverter::shiftEndlinesUpTree(DoxygenEntity &root, int level) {
{
DoxygenEntityListIt it = root.entityList.begin(); DoxygenEntityListIt it = root.entityList.begin();
while (it != root.entityList.end()) { while (it != root.entityList.end()) {
// remove line endings // remove line endings
@ -841,8 +714,7 @@ int JavaDocConverter::shiftEndlinesUpTree(DoxygenEntity &root, int level)
* to indentation of the first line. Indentation of non-empty lines is not * to indentation of the first line. Indentation of non-empty lines is not
* changed - garbage in garbage out. * changed - garbage in garbage out.
*/ */
std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) {
{
size_t idx = doc.find('\n'); size_t idx = doc.find('\n');
size_t indent = 0; size_t indent = 0;
@ -857,10 +729,10 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc)
} }
} }
if (indent == 0) { // we can't indent the first line less than 0 if (indent == 0) {
// we can't indent the first line less than 0
indent = 1; indent = 1;
} }
// Create the first line of Javadoc comment. // Create the first line of Javadoc comment.
string indentStr(indent - 1, ' '); string indentStr(indent - 1, ' ');
string translatedStr = indentStr + "/**"; string translatedStr = indentStr + "/**";
@ -881,13 +753,11 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc)
// line without '*' found - is it empty? // line without '*' found - is it empty?
if (translatedStr[nonspaceIdx] != '\n') { if (translatedStr[nonspaceIdx] != '\n') {
// add '* ' to each line without it // add '* ' to each line without it
translatedStr = translatedStr.substr(0, nonspaceIdx) + "* " translatedStr = translatedStr.substr(0, nonspaceIdx) + "* " + translatedStr.substr(nonspaceIdx);
+ translatedStr.substr(nonspaceIdx);
//printf(translatedStr.c_str()); //printf(translatedStr.c_str());
} else { } else {
// we found empty line, replace it with indented '*' // we found empty line, replace it with indented '*'
translatedStr = translatedStr.substr(0, idx + 1) + indentStr + "* " translatedStr = translatedStr.substr(0, idx + 1) + indentStr + "* " + translatedStr.substr(nonspaceIdx);
+ translatedStr.substr(nonspaceIdx);
} }
} }
idx = translatedStr.find('\n', nonspaceIdx); idx = translatedStr.find('\n', nonspaceIdx);
@ -908,8 +778,7 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc)
return translatedStr; return translatedStr;
} }
String *JavaDocConverter::makeDocumentation(Node *node) String *JavaDocConverter::makeDocumentation(Node *node) {
{
String *documentation = getDoxygenComment(node); String *documentation = getDoxygenComment(node);
@ -936,7 +805,6 @@ String *JavaDocConverter::makeDocumentation(Node *node)
std::cout << "---RESORTED LIST---" << std::endl; std::cout << "---RESORTED LIST---" << std::endl;
printTree(entityList); printTree(entityList);
} }
// store the current node // store the current node
// (currently just to handle params) // (currently just to handle params)
currentNode = node; currentNode = node;
@ -971,8 +839,6 @@ String *JavaDocConverter::makeDocumentation(Node *node)
return NewString(javaDocString.c_str()); return NewString(javaDocString.c_str());
} }
void JavaDocConverter::addError(int warningType, const std::string &message) void JavaDocConverter::addError(int warningType, const std::string &message) {
{ Swig_warning(warningType, "", 0, "Doxygen parser warning: %s. \n", message.c_str());
Swig_warning(warningType, "", 0, "Doxygen parser warning: %s. \n",
message.c_str());
} }

View file

@ -30,15 +30,18 @@ protected:
* Used to properly format JavaDoc-style command * Used to properly format JavaDoc-style command
*/ */
std::string formatCommand(std::string unformattedLine, int indent); std::string formatCommand(std::string unformattedLine, int indent);
/* /*
* Translate every entity in a tree. * Translate every entity in a tree.
*/ */
std::string translateSubtree(DoxygenEntity &doxygenEntity); std::string translateSubtree(DoxygenEntity &doxygenEntity);
/* /*
* Translate one entity with the appropriate handler, according * Translate one entity with the appropriate handler, according
* to the tagHandlers * to the tagHandlers
*/ */
void translateEntity(DoxygenEntity &tag, std::string &translatedComment); void translateEntity(DoxygenEntity &tag, std::string &translatedComment);
/* /*
* Fix all endlines location, etc * Fix all endlines location, etc
*/ */
@ -53,8 +56,7 @@ protected:
* Typedef for the function that handles one tag * Typedef for the function that handles one tag
* arg - some string argument to easily pass it through lookup table * arg - some string argument to easily pass it through lookup table
*/ */
typedef void (JavaDocConverter::*tagHandler)(DoxygenEntity &tag, typedef void (JavaDocConverter::*tagHandler) (DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
std::string &translatedComment, std::string &arg);
/** /**
* Copies verbatim args of the tag to output, used for commands like \f$, ... * Copies verbatim args of the tag to output, used for commands like \f$, ...
@ -62,9 +64,7 @@ protected:
void handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/** Creates anchor link. */ /** Creates anchor link. */
void handleTagAnchor(DoxygenEntity& tag, void handleTagAnchor(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
std::string& translatedComment,
std::string &arg);
/* /*
* Wrap the command data with the html tag * Wrap the command data with the html tag
@ -73,80 +73,87 @@ protected:
void handleTagHtml(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagHtml(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* Handles HTML tags recognized by Doxygen, like <A ...>, <ul>, <table>, ... */ /* Handles HTML tags recognized by Doxygen, like <A ...>, <ul>, <table>, ... */
void handleDoxyHtmlTag(DoxygenEntity& tag, void handleDoxyHtmlTag(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
std::string& translatedComment,
std::string &arg);
/* Handles HTML entities recognized by Doxygen, like &lt;, &copy;, ... */ /* Handles HTML entities recognized by Doxygen, like &lt;, &copy;, ... */
void handleHtmlEntity(DoxygenEntity& tag, void handleHtmlEntity(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
std::string& translatedComment,
std::string &arg);
/* /*
* Just prints new line * Just prints new line
*/ */
void handleNewLine(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleNewLine(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Print the name of tag to the output, used for escape-commands * Print the name of tag to the output, used for escape-commands
* arg - html-escaped variant, if not provided the command data is used * arg - html-escaped variant, if not provided the command data is used
*/ */
void handleTagChar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagChar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Do not translate and print as-is * Do not translate and print as-is
* arg - the new tag name, if it needs to be renamed * arg - the new tag name, if it needs to be renamed
*/ */
void handleTagSame(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagSame(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Print only the content and strip original tag * Print only the content and strip original tag
*/ */
void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Print only data part of code * Print only data part of code
*/ */
void handlePlainString(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handlePlainString(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Print extended Javadoc command, like {@code ...} or {@literal ...} * Print extended Javadoc command, like {@code ...} or {@literal ...}
* arg - command name * arg - command name
*/ */
void handleTagExtended(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagExtended(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Print the if-elseif-else-endif section * Print the if-elseif-else-endif section
*/ */
void handleTagIf(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagIf(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Prints the specified message, than the contents of the tag * Prints the specified message, than the contents of the tag
* arg - message * arg - message
*/ */
void handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Insert <img src=... /> tag if the 'format' field is specified as 'html' * Insert <img src=... /> tag if the 'format' field is specified as 'html'
*/ */
void handleTagImage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagImage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Insert <p alt='title'>...</p> * Insert <p alt='title'>...</p>
*/ */
void handleTagPar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagPar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Insert \@param command, if it is really a function param * Insert \@param command, if it is really a function param
*/ */
void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Writes link for \ref tag. * Writes link for \ref tag.
*/ */
void handleTagRef(DoxygenEntity& tag, std::string& translatedComment, void handleTagRef(DoxygenEntity &tag, std::string &translatedComment, std::string &);
std::string&);
/* /*
* Insert {@link...} command, and handle all the <link-object>s correctly * Insert {@link...} command, and handle all the <link-object>s correctly
* (like converting types of params, etc) * (like converting types of params, etc)
*/ */
void handleTagLink(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagLink(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
/* /*
* Insert @see command, and handle all the <link-object>s correctly * Insert @see command, and handle all the <link-object>s correctly
* (like converting types of params, etc) * (like converting types of params, etc)
*/ */
void handleTagSee(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); void handleTagSee(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
private: private:
Node *currentNode; Node *currentNode;
// this contains the handler pointer and one string argument // this contains the handler pointer and one string argument

View file

@ -28,18 +28,14 @@ using std::string;
// Helper class increasing the provided indent string in its ctor and decreasing // Helper class increasing the provided indent string in its ctor and decreasing
// it in its dtor. // it in its dtor.
class IndentGuard class IndentGuard {
{
public: public:
// One indent level. // One indent level.
static const char* Level() { return " "; } static const char *Level() {
return " ";
// Default ctor doesn't do anything and prevents the dtor from doing anything }
// too and should only be used when the guard needs to be initialized // Default ctor doesn't do anything and prevents the dtor from doing anything// too and should only be used when the guard needs to be initialized// conditionally as Init() can then be called after checking some condition.// Otherwise, prefer to use the non default ctor below.
// conditionally as Init() can then be called after checking some condition. IndentGuard() {
// Otherwise, prefer to use the non default ctor below.
IndentGuard()
{
m_initialized = false; m_initialized = false;
} }
@ -47,14 +43,12 @@ public:
// extra indent added to it in the dtor and the variable containing the indent // extra indent added to it in the dtor and the variable containing the indent
// to use, which must be used after every new line by the code actually // to use, which must be used after every new line by the code actually
// updating the output. // updating the output.
IndentGuard(string& output, string& indent) IndentGuard(string &output, string &indent) {
{
Init(output, indent); Init(output, indent);
} }
// Really initializes the object created using the default ctor. // Really initializes the object created using the default ctor.
void Init(string& output, string& indent) void Init(string &output, string &indent) {
{
m_output = &output; m_output = &output;
m_indent = &indent; m_indent = &indent;
@ -77,10 +71,11 @@ public:
// Get the indent for the first line of the paragraph, which is smaller than // Get the indent for the first line of the paragraph, which is smaller than
// the indent for the subsequent lines. // the indent for the subsequent lines.
string getFirstLineIndent() const { return string(m_firstLineIndent, ' '); } string getFirstLineIndent() const {
return string(m_firstLineIndent, ' ');
}
~IndentGuard() ~IndentGuard() {
{
if (!m_initialized) if (!m_initialized)
return; return;
@ -109,8 +104,7 @@ private:
// Return the indent of the given multiline string, i.e. the maximal number of // Return the indent of the given multiline string, i.e. the maximal number of
// spaces present in the beginning of all its non-empty lines. // spaces present in the beginning of all its non-empty lines.
static size_t determineIndent(const string& s) static size_t determineIndent(const string &s) {
{
size_t minIndent = static_cast<size_t>(-1); size_t minIndent = static_cast<size_t>(-1);
for (size_t lineStart = 0; lineStart < s.length();) { for (size_t lineStart = 0; lineStart < s.length();) {
@ -136,8 +130,7 @@ static size_t determineIndent(const string& s)
return minIndent; return minIndent;
} }
static void trimWhitespace(string& s) static void trimWhitespace(string &s) {
{
const size_t lastNonSpace = s.find_last_not_of(' '); const size_t lastNonSpace = s.find_last_not_of(' ');
if (lastNonSpace == string::npos) if (lastNonSpace == string::npos)
s.clear(); s.clear();
@ -146,21 +139,16 @@ static void trimWhitespace(string& s)
} }
/* static */ /* static */
PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::make_handler(tagHandler handler) {
PyDocConverter::make_handler(tagHandler handler)
{
return make_pair(handler, std::string()); return make_pair(handler, std::string());
} }
/* static */ /* static */
PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::make_handler(tagHandler handler, const char *arg) {
PyDocConverter::make_handler(tagHandler handler, const char* arg)
{
return make_pair(handler, arg); return make_pair(handler, arg);
} }
void PyDocConverter::fillStaticTables() void PyDocConverter::fillStaticTables() {
{
if (tagHandlers.size()) // fill only once if (tagHandlers.size()) // fill only once
return; return;
@ -213,9 +201,7 @@ void PyDocConverter::fillStaticTables()
tagHandlers["details"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["details"] = make_handler(&PyDocConverter::handleParagraph);
tagHandlers["em"] = make_handler(&PyDocConverter::handleParagraph, " "); tagHandlers["em"] = make_handler(&PyDocConverter::handleParagraph, " ");
tagHandlers["example"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["example"] = make_handler(&PyDocConverter::handleParagraph);
tagHandlers["exception"] = tagHandlers["exception"] = tagHandlers["throw"] = tagHandlers["throws"] = make_handler(&PyDocConverter::handleTagException);
tagHandlers["throw"] =
tagHandlers["throws"] = make_handler(&PyDocConverter::handleTagException);
tagHandlers["htmlonly"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["htmlonly"] = make_handler(&PyDocConverter::handleParagraph);
tagHandlers["invariant"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["invariant"] = make_handler(&PyDocConverter::handleParagraph);
tagHandlers["latexonly"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["latexonly"] = make_handler(&PyDocConverter::handleParagraph);
@ -228,8 +214,7 @@ void PyDocConverter::fillStaticTables()
tagHandlers["remark"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["remark"] = make_handler(&PyDocConverter::handleParagraph);
tagHandlers["remarks"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["remarks"] = make_handler(&PyDocConverter::handleParagraph);
tagHandlers["sa"] = make_handler(&PyDocConverter::handleTagMessage, "See also: "); tagHandlers["sa"] = make_handler(&PyDocConverter::handleTagMessage, "See also: ");
tagHandlers["see"] = make_handler(&PyDocConverter::handleTagMessage, tagHandlers["see"] = make_handler(&PyDocConverter::handleTagMessage, "See also: ");
"See also: ");
tagHandlers["since"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["since"] = make_handler(&PyDocConverter::handleParagraph);
tagHandlers["short"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["short"] = make_handler(&PyDocConverter::handleParagraph);
tagHandlers["todo"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["todo"] = make_handler(&PyDocConverter::handleParagraph);
@ -239,27 +224,21 @@ void PyDocConverter::fillStaticTables()
tagHandlers["xmlonly"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["xmlonly"] = make_handler(&PyDocConverter::handleParagraph);
// these commands have special handlers // these commands have special handlers
tagHandlers["arg"] = make_handler(&PyDocConverter::handleTagMessage, "* "); tagHandlers["arg"] = make_handler(&PyDocConverter::handleTagMessage, "* ");
tagHandlers["cond"] = make_handler(&PyDocConverter::handleTagMessage, tagHandlers["cond"] = make_handler(&PyDocConverter::handleTagMessage, "Conditional comment: ");
"Conditional comment: ");
tagHandlers["else"] = make_handler(&PyDocConverter::handleTagIf, "Else: "); tagHandlers["else"] = make_handler(&PyDocConverter::handleTagIf, "Else: ");
tagHandlers["elseif"] = make_handler(&PyDocConverter::handleTagIf, "Else if: "); tagHandlers["elseif"] = make_handler(&PyDocConverter::handleTagIf, "Else if: ");
tagHandlers["endcond"] = make_handler(&PyDocConverter::handleTagMessage, tagHandlers["endcond"] = make_handler(&PyDocConverter::handleTagMessage, "End of conditional comment.");
"End of conditional comment.");
tagHandlers["if"] = make_handler(&PyDocConverter::handleTagIf, "If: "); tagHandlers["if"] = make_handler(&PyDocConverter::handleTagIf, "If: ");
tagHandlers["ifnot"] = make_handler(&PyDocConverter::handleTagIf, "If not: "); tagHandlers["ifnot"] = make_handler(&PyDocConverter::handleTagIf, "If not: ");
tagHandlers["image"] = make_handler(&PyDocConverter::handleTagImage); tagHandlers["image"] = make_handler(&PyDocConverter::handleTagImage);
tagHandlers["li"] = make_handler(&PyDocConverter::handleTagMessage, "* "); tagHandlers["li"] = make_handler(&PyDocConverter::handleTagMessage, "* ");
tagHandlers["overload"] = make_handler(&PyDocConverter::handleTagMessage, tagHandlers["overload"] = make_handler(&PyDocConverter::handleTagMessage,
"This is an overloaded member function, provided for" "This is an overloaded member function, provided for"
" convenience.\nIt differs from the above function only in what" " convenience.\nIt differs from the above function only in what" " argument(s) it accepts.");
" argument(s) it accepts.");
tagHandlers["par"] = make_handler(&PyDocConverter::handleTagPar); tagHandlers["par"] = make_handler(&PyDocConverter::handleTagPar);
tagHandlers["param"] = tagHandlers["param"] = tagHandlers["tparam"] = make_handler(&PyDocConverter::handleTagParam);
tagHandlers["tparam"] = make_handler(&PyDocConverter::handleTagParam);
tagHandlers["ref"] = make_handler(&PyDocConverter::handleTagRef); tagHandlers["ref"] = make_handler(&PyDocConverter::handleTagRef);
tagHandlers["result"] = tagHandlers["result"] = tagHandlers["return"] = tagHandlers["returns"] = make_handler(&PyDocConverter::handleTagReturn);
tagHandlers["return"] =
tagHandlers["returns"] = make_handler(&PyDocConverter::handleTagReturn);
// 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)
@ -268,15 +247,12 @@ void PyDocConverter::fillStaticTables()
tagHandlers["n"] = make_handler(&PyDocConverter::handleNewLine); tagHandlers["n"] = make_handler(&PyDocConverter::handleNewLine);
// \f commands output literal Latex formula, which is still better than nothing. // \f commands output literal Latex formula, which is still better than nothing.
tagHandlers["f$"] = tagHandlers["f$"] = tagHandlers["f["] = tagHandlers["f{"] = make_handler(&PyDocConverter::handleMath);
tagHandlers["f["] =
tagHandlers["f{"] = make_handler(&PyDocConverter::handleMath);
// HTML tags // HTML tags
tagHandlers["<a"] = make_handler(&PyDocConverter::handleDoxyHtmlTag_A); tagHandlers["<a"] = make_handler(&PyDocConverter::handleDoxyHtmlTag_A);
tagHandlers["<b"] = make_handler(&PyDocConverter::handleDoxyHtmlTag2, "**"); tagHandlers["<b"] = make_handler(&PyDocConverter::handleDoxyHtmlTag2, "**");
tagHandlers["<blockquote"] = make_handler(&PyDocConverter::handleDoxyHtmlTag_A, tagHandlers["<blockquote"] = make_handler(&PyDocConverter::handleDoxyHtmlTag_A, "Quote: ");
"Quote: ");
tagHandlers["<body"] = make_handler(&PyDocConverter::handleDoxyHtmlTag); tagHandlers["<body"] = make_handler(&PyDocConverter::handleDoxyHtmlTag);
tagHandlers["<br"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "\n"); tagHandlers["<br"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "\n");
@ -294,8 +270,7 @@ void PyDocConverter::fillStaticTables()
tagHandlers["<div"] = make_handler(&PyDocConverter::handleDoxyHtmlTag); tagHandlers["<div"] = make_handler(&PyDocConverter::handleDoxyHtmlTag);
tagHandlers["<em"] = make_handler(&PyDocConverter::handleDoxyHtmlTag2, "**"); tagHandlers["<em"] = make_handler(&PyDocConverter::handleDoxyHtmlTag2, "**");
tagHandlers["<form"] = make_handler(&PyDocConverter::handleDoxyHtmlTag); tagHandlers["<form"] = make_handler(&PyDocConverter::handleDoxyHtmlTag);
tagHandlers["<hr"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, tagHandlers["<hr"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "--------------------------------------------------------------------\n");
"--------------------------------------------------------------------\n");
tagHandlers["<h1"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "# "); tagHandlers["<h1"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "# ");
tagHandlers["<h2"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "## "); tagHandlers["<h2"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "## ");
tagHandlers["<h3"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "### "); tagHandlers["<h3"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "### ");
@ -352,16 +327,12 @@ void PyDocConverter::fillStaticTables()
} }
PyDocConverter::PyDocConverter(int flags): PyDocConverter::PyDocConverter(int flags):
DoxygenTranslator(flags), m_tableLineLen(0), m_prevRowIsTH( DoxygenTranslator(flags), m_tableLineLen(0), m_prevRowIsTH(false) {
false)
{
fillStaticTables(); fillStaticTables();
} }
// Return the type as it should appear in the output documentation. // Return the type as it should appear in the output documentation.
static static std::string getPyDocType(Node *n, const_String_or_char_ptr lname = "") {
std::string getPyDocType(Node* n, const_String_or_char_ptr lname = "")
{
std::string type; std::string type;
String *s = Swig_typemap_lookup("doctype", n, lname, 0); String *s = Swig_typemap_lookup("doctype", n, lname, 0);
@ -390,8 +361,7 @@ std::string getPyDocType(Node* n, const_String_or_char_ptr lname = "")
return type; return type;
} }
std::string PyDocConverter::getParamType(std::string param) std::string PyDocConverter::getParamType(std::string param) {
{
std::string type; std::string type;
ParmList *plist = CopyParmList(Getattr(currentNode, "parms")); ParmList *plist = CopyParmList(Getattr(currentNode, "parms"));
@ -407,8 +377,7 @@ std::string PyDocConverter::getParamType(std::string param)
return type; return type;
} }
std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) std::string PyDocConverter::translateSubtree(DoxygenEntity &doxygenEntity) {
{
std::string translatedComment; std::string translatedComment;
if (doxygenEntity.isLeaf) if (doxygenEntity.isLeaf)
@ -433,28 +402,19 @@ std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity)
return translatedComment; return translatedComment;
} }
void PyDocConverter::translateEntity(DoxygenEntity & doxyEntity, void PyDocConverter::translateEntity(DoxygenEntity &doxyEntity, std::string &translatedComment) {
std::string &translatedComment)
{
// check if we have needed handler and call it // check if we have needed handler and call it
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(doxyEntity.typeOfEntity); it = tagHandlers.find(doxyEntity.typeOfEntity);
if (it != tagHandlers.end()) if (it != tagHandlers.end())
(this->*(it->second.first))(doxyEntity, translatedComment, (this->*(it->second.first)) (doxyEntity, translatedComment, it->second.second);
it->second.second);
} }
void PyDocConverter::handleParagraph(DoxygenEntity& tag, void PyDocConverter::handleParagraph(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
std::string& translatedComment,
const std::string&)
{
translatedComment += translateSubtree(tag); translatedComment += translateSubtree(tag);
} }
void PyDocConverter::handleMath(DoxygenEntity &tag, void PyDocConverter::handleMath(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
std::string &translatedComment,
const std::string& arg)
{
IndentGuard indent; IndentGuard indent;
// Only \f$ is translated to inline formulae, \f[ and \f{ are for the block ones. // Only \f$ is translated to inline formulae, \f[ and \f{ are for the block ones.
@ -507,10 +467,7 @@ void PyDocConverter::handleMath(DoxygenEntity &tag,
} }
} }
void PyDocConverter::handleCode(DoxygenEntity &tag, void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
std::string &translatedComment,
const std::string &arg)
{
IndentGuard indent(translatedComment, m_indent); IndentGuard indent(translatedComment, m_indent);
trimWhitespace(translatedComment); trimWhitespace(translatedComment);
@ -552,43 +509,27 @@ void PyDocConverter::handleCode(DoxygenEntity &tag,
translatedComment += '\n'; translatedComment += '\n';
} }
void PyDocConverter::handlePlainString(DoxygenEntity& tag, void PyDocConverter::handlePlainString(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
std::string& translatedComment,
const std::string&)
{
translatedComment += tag.data; translatedComment += tag.data;
} }
void PyDocConverter::handleTagVerbatim(DoxygenEntity& tag, void PyDocConverter::handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
std::string& translatedComment,
const std::string &arg)
{
translatedComment += arg + " "; translatedComment += arg + " ";
for (DoxygenEntityListCIt it = tag.entityList.begin(); for (DoxygenEntityListCIt it = tag.entityList.begin(); it != tag.entityList.end(); it++) {
it != tag.entityList.end(); it++) {
translatedComment += it->data; translatedComment += it->data;
} }
} }
void PyDocConverter::handleTagMessage(DoxygenEntity& tag, void PyDocConverter::handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
std::string& translatedComment,
const std::string &arg)
{
translatedComment += arg; translatedComment += arg;
handleParagraph(tag, translatedComment); handleParagraph(tag, translatedComment);
} }
void PyDocConverter::handleTagChar(DoxygenEntity& tag, void PyDocConverter::handleTagChar(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
std::string& translatedComment,
const std::string&)
{
translatedComment += tag.typeOfEntity; translatedComment += tag.typeOfEntity;
} }
void PyDocConverter::handleTagIf(DoxygenEntity& tag, void PyDocConverter::handleTagIf(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
std::string& translatedComment,
const std::string &arg)
{
translatedComment += arg; translatedComment += arg;
if (tag.entityList.size()) { if (tag.entityList.size()) {
translatedComment += tag.entityList.begin()->data; translatedComment += tag.entityList.begin()->data;
@ -597,10 +538,7 @@ void PyDocConverter::handleTagIf(DoxygenEntity& tag,
} }
} }
void PyDocConverter::handleTagPar(DoxygenEntity& tag, void PyDocConverter::handleTagPar(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
std::string& translatedComment,
const std::string&)
{
translatedComment += "Title: "; translatedComment += "Title: ";
if (tag.entityList.size()) if (tag.entityList.size())
translatedComment += tag.entityList.begin()->data; translatedComment += tag.entityList.begin()->data;
@ -608,10 +546,7 @@ void PyDocConverter::handleTagPar(DoxygenEntity& tag,
handleParagraph(tag, translatedComment); handleParagraph(tag, translatedComment);
} }
void PyDocConverter::handleTagImage(DoxygenEntity& tag, void PyDocConverter::handleTagImage(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
std::string& translatedComment,
const std::string&)
{
if (tag.entityList.size() < 2) if (tag.entityList.size() < 2)
return; return;
tag.entityList.pop_front(); tag.entityList.pop_front();
@ -622,10 +557,7 @@ void PyDocConverter::handleTagImage(DoxygenEntity& tag,
translatedComment += "(" + tag.entityList.begin()->data + ")"; translatedComment += "(" + tag.entityList.begin()->data + ")";
} }
void PyDocConverter::handleTagParam(DoxygenEntity& tag, void PyDocConverter::handleTagParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
std::string& translatedComment,
const std::string&)
{
if (tag.entityList.size() < 2) if (tag.entityList.size() < 2)
return; return;
@ -648,10 +580,7 @@ void PyDocConverter::handleTagParam(DoxygenEntity& tag,
} }
void PyDocConverter::handleTagReturn(DoxygenEntity &tag, void PyDocConverter::handleTagReturn(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
std::string &translatedComment,
const std::string &)
{
IndentGuard indent(translatedComment, m_indent); IndentGuard indent(translatedComment, m_indent);
const std::string pytype = getPyDocType(currentNode); const std::string pytype = getPyDocType(currentNode);
@ -667,10 +596,7 @@ void PyDocConverter::handleTagReturn(DoxygenEntity &tag,
} }
void PyDocConverter::handleTagException(DoxygenEntity &tag, void PyDocConverter::handleTagException(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
std::string &translatedComment,
const std::string &)
{
IndentGuard indent(translatedComment, m_indent); IndentGuard indent(translatedComment, m_indent);
translatedComment += ":raises: "; translatedComment += ":raises: ";
@ -678,10 +604,7 @@ void PyDocConverter::handleTagException(DoxygenEntity &tag,
} }
void PyDocConverter::handleTagRef(DoxygenEntity& tag, void PyDocConverter::handleTagRef(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
std::string& translatedComment,
const std::string&)
{
if (!tag.entityList.size()) if (!tag.entityList.size())
return; return;
@ -695,26 +618,19 @@ void PyDocConverter::handleTagRef(DoxygenEntity& tag,
} }
void PyDocConverter::handleTagWrap(DoxygenEntity& tag, void PyDocConverter::handleTagWrap(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
std::string& translatedComment,
const 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);
// wrap the thing, ignoring whitespace // wrap the thing, ignoring whitespace
size_t wsPos = tagData.find_last_not_of("\n\t "); size_t wsPos = tagData.find_last_not_of("\n\t ");
if (wsPos != std::string::npos && wsPos != tagData.size() - 1) if (wsPos != std::string::npos && wsPos != tagData.size() - 1)
translatedComment += arg + tagData.substr(0, wsPos + 1) + arg translatedComment += arg + tagData.substr(0, wsPos + 1) + arg + tagData.substr(wsPos + 1);
+ tagData.substr(wsPos + 1);
else else
translatedComment += arg + tagData + arg; translatedComment += arg + tagData + arg;
} }
} }
void PyDocConverter::handleDoxyHtmlTag(DoxygenEntity& tag, void PyDocConverter::handleDoxyHtmlTag(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
std::string& translatedComment,
const std::string &arg)
{
std::string htmlTagArgs = tag.data; std::string htmlTagArgs = tag.data;
if (htmlTagArgs == "/") { if (htmlTagArgs == "/") {
// end html tag, for example "</ul> // end html tag, for example "</ul>
@ -724,10 +640,7 @@ void PyDocConverter::handleDoxyHtmlTag(DoxygenEntity& tag,
} }
} }
void PyDocConverter::handleDoxyHtmlTagNoParam(DoxygenEntity& tag, void PyDocConverter::handleDoxyHtmlTagNoParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
std::string& translatedComment,
const std::string &arg)
{
std::string htmlTagArgs = tag.data; std::string htmlTagArgs = tag.data;
if (htmlTagArgs == "/") { if (htmlTagArgs == "/") {
// end html tag, for example "</ul> // end html tag, for example "</ul>
@ -736,10 +649,7 @@ void PyDocConverter::handleDoxyHtmlTagNoParam(DoxygenEntity& tag,
} }
} }
void PyDocConverter::handleDoxyHtmlTag_A(DoxygenEntity& tag, void PyDocConverter::handleDoxyHtmlTag_A(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
std::string& translatedComment,
const std::string &arg)
{
std::string htmlTagArgs = tag.data; std::string htmlTagArgs = tag.data;
if (htmlTagArgs == "/") { if (htmlTagArgs == "/") {
// end html tag, "</a> // end html tag, "</a>
@ -755,10 +665,7 @@ void PyDocConverter::handleDoxyHtmlTag_A(DoxygenEntity& tag,
} }
} }
void PyDocConverter::handleDoxyHtmlTag2(DoxygenEntity& tag, void PyDocConverter::handleDoxyHtmlTag2(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
std::string& translatedComment,
const std::string &arg)
{
std::string htmlTagArgs = tag.data; std::string htmlTagArgs = tag.data;
if (htmlTagArgs == "/") { if (htmlTagArgs == "/") {
// end html tag, for example "</em> // end html tag, for example "</em>
@ -768,18 +675,14 @@ void PyDocConverter::handleDoxyHtmlTag2(DoxygenEntity& tag,
} }
} }
void PyDocConverter::handleDoxyHtmlTag_tr(DoxygenEntity& tag, void PyDocConverter::handleDoxyHtmlTag_tr(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
std::string& translatedComment,
const std::string &)
{
std::string htmlTagArgs = tag.data; std::string htmlTagArgs = tag.data;
size_t nlPos = translatedComment.rfind('\n'); size_t nlPos = translatedComment.rfind('\n');
if (htmlTagArgs == "/") { if (htmlTagArgs == "/") {
// end tag, </tr> appends vertical table line '|' // end tag, </tr> appends vertical table line '|'
translatedComment += '|'; translatedComment += '|';
if (nlPos != string::npos) { if (nlPos != string::npos) {
size_t startOfTableLinePos = translatedComment.find_first_not_of(" \t", size_t startOfTableLinePos = translatedComment.find_first_not_of(" \t", nlPos + 1);
nlPos + 1);
if (startOfTableLinePos != string::npos) { if (startOfTableLinePos != string::npos) {
m_tableLineLen = translatedComment.size() - startOfTableLinePos; m_tableLineLen = translatedComment.size() - startOfTableLinePos;
} }
@ -800,10 +703,7 @@ void PyDocConverter::handleDoxyHtmlTag_tr(DoxygenEntity& tag,
} }
} }
void PyDocConverter::handleDoxyHtmlTag_th(DoxygenEntity& tag, void PyDocConverter::handleDoxyHtmlTag_th(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
std::string& translatedComment,
const std::string &)
{
std::string htmlTagArgs = tag.data; std::string htmlTagArgs = tag.data;
if (htmlTagArgs == "/") { if (htmlTagArgs == "/") {
// end tag, </th> is ignored // end tag, </th> is ignored
@ -813,10 +713,7 @@ void PyDocConverter::handleDoxyHtmlTag_th(DoxygenEntity& tag,
} }
} }
void PyDocConverter::handleDoxyHtmlTag_td(DoxygenEntity& tag, void PyDocConverter::handleDoxyHtmlTag_td(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
std::string& translatedComment,
const std::string &)
{
std::string htmlTagArgs = tag.data; std::string htmlTagArgs = tag.data;
if (htmlTagArgs == "/") { if (htmlTagArgs == "/") {
// end tag, </td> is ignored // end tag, </td> is ignored
@ -825,18 +722,12 @@ void PyDocConverter::handleDoxyHtmlTag_td(DoxygenEntity& tag,
} }
} }
void PyDocConverter::handleHtmlEntity(DoxygenEntity&, void PyDocConverter::handleHtmlEntity(DoxygenEntity &, std::string &translatedComment, const std::string &arg) {
std::string& translatedComment,
const std::string &arg)
{
// html entities // html entities
translatedComment += arg; translatedComment += arg;
} }
void PyDocConverter::handleNewLine(DoxygenEntity&, void PyDocConverter::handleNewLine(DoxygenEntity &, std::string &translatedComment, const std::string &) {
std::string& translatedComment,
const std::string&)
{
trimWhitespace(translatedComment); trimWhitespace(translatedComment);
translatedComment += "\n"; translatedComment += "\n";
@ -844,8 +735,7 @@ void PyDocConverter::handleNewLine(DoxygenEntity&,
translatedComment += m_indent; translatedComment += m_indent;
} }
String *PyDocConverter::makeDocumentation(Node *n) String *PyDocConverter::makeDocumentation(Node *n) {
{
String *documentation; String *documentation;
std::string pyDocString; std::string pyDocString;
@ -901,9 +791,7 @@ String *PyDocConverter::makeDocumentation(Node *n)
indentStr.assign(minIndent, ' '); indentStr.assign(minIndent, ' ');
std::ostringstream concatDocString; std::ostringstream concatDocString;
for (size_t realOverloadCount = 0; for (size_t realOverloadCount = 0; realOverloadCount < allDocumentation.size(); realOverloadCount++) {
realOverloadCount < allDocumentation.size();
realOverloadCount++) {
if (realOverloadCount != 0) { if (realOverloadCount != 0) {
// separate it from the preceding one. // separate it from the preceding one.
concatDocString << "\n" << indentStr << "|\n\n"; concatDocString << "\n" << indentStr << "|\n\n";
@ -911,8 +799,7 @@ String *PyDocConverter::makeDocumentation(Node *n)
oneDoc = allDocumentation[realOverloadCount]; oneDoc = allDocumentation[realOverloadCount];
trimWhitespace(oneDoc); trimWhitespace(oneDoc);
concatDocString << indentStr << "*Overload " << (realOverloadCount + 1) << ":*\n" concatDocString << indentStr << "*Overload " << (realOverloadCount + 1) << ":*\n" << oneDoc;
<< oneDoc;
} }
pyDocString = concatDocString.str(); pyDocString = concatDocString.str();
} else if (allDocumentation.size() == 1) { } else if (allDocumentation.size() == 1) {

View file

@ -40,6 +40,7 @@ protected:
* a section title associated with them * a section title associated with them
*/ */
std::string translateSubtree(DoxygenEntity &doxygenEntity); std::string translateSubtree(DoxygenEntity &doxygenEntity);
/* /*
* Translate one entity with the appropriate handler, according * Translate one entity with the appropriate handler, according
* to the tagHandlers * to the tagHandlers
@ -50,31 +51,33 @@ protected:
* Typedef for the function that handles one tag * Typedef for the function that handles one tag
* arg - some string argument to easily pass it through lookup table * arg - some string argument to easily pass it through lookup table
*/ */
typedef void (PyDocConverter::*tagHandler)(DoxygenEntity &tag, typedef void (PyDocConverter::*tagHandler) (DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
std::string &translatedComment, const std::string &arg);
/* /*
* Wrap the command data with the some string * Wrap the command data with the some string
* arg - string to wrap with, like '_' or '*' * arg - string to wrap with, like '_' or '*'
*/ */
void handleTagWrap(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); void handleTagWrap(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
/* /*
* Just prints new line * Just prints new line
*/ */
void handleNewLine(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); void handleNewLine(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
/* /*
* Print the name of tag to the output, used for escape-commands * Print the name of tag to the output, used for escape-commands
*/ */
void handleTagChar(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); void handleTagChar(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
/* /*
* Format the contents of the \exception tag or its synonyms. * Format the contents of the \exception tag or its synonyms.
*/ */
void handleTagException(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); void handleTagException(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
/* /*
* Print only the content and strip original tag * Print only the content and strip original tag
*/ */
void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg = std::string());
const std::string &arg = std::string());
/* /*
* Handle one of the Doxygen formula-related tags. * Handle one of the Doxygen formula-related tags.
@ -94,35 +97,39 @@ protected:
/** /**
* Copies verbatim args of the tag to output, used for commands like \f$, ... * Copies verbatim args of the tag to output, used for commands like \f$, ...
*/ */
void handleTagVerbatim(DoxygenEntity& tag, void handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
std::string& translatedComment,
const std::string &arg);
/* /*
* Print the if-elseif-else-endif section * Print the if-elseif-else-endif section
*/ */
void handleTagIf(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); void handleTagIf(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
/* /*
* Prints the specified message, than the contents of the tag * Prints the specified message, than the contents of the tag
* arg - message * arg - message
*/ */
void handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); void handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
/* /*
* Insert 'Title: ...' * Insert 'Title: ...'
*/ */
void handleTagPar(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); void handleTagPar(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
/* /*
* Insert 'Image: ...' * Insert 'Image: ...'
*/ */
void handleTagImage(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); void handleTagImage(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
/* /*
* Format nice param description with type information * Format nice param description with type information
*/ */
void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
/* /*
* Format the contents of the \return tag or its synonyms. * Format the contents of the \return tag or its synonyms.
*/ */
void handleTagReturn(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); void handleTagReturn(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
/* /*
* Writes text for \ref tag. * Writes text for \ref tag.
*/ */
@ -135,34 +142,25 @@ protected:
/** Does not output params of HTML tag, for example in <table border='1'> /** Does not output params of HTML tag, for example in <table border='1'>
* 'border=1' is not written to output. * 'border=1' is not written to output.
*/ */
void handleDoxyHtmlTagNoParam(DoxygenEntity& tag, void handleDoxyHtmlTagNoParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
std::string& translatedComment,
const std::string &arg);
/** Translates tag <a href = "url">text</a> to: text ("url"). */ /** Translates tag <a href = "url">text</a> to: text ("url"). */
void handleDoxyHtmlTag_A(DoxygenEntity& tag, void handleDoxyHtmlTag_A(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
std::string& translatedComment,
const std::string &arg);
/* /*
* Handles HTML tags, which are translated to markdown-like syntax, for example * Handles HTML tags, which are translated to markdown-like syntax, for example
* <i>text</i> --> _text_. Appends arg for start HTML tag and end HTML tag. * <i>text</i> --> _text_. Appends arg for start HTML tag and end HTML tag.
*/ */
void handleDoxyHtmlTag2(DoxygenEntity& tag, void handleDoxyHtmlTag2(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
std::string& translatedComment,
const std::string &arg);
/* Handles HTML table, tag <tr> */ /* Handles HTML table, tag <tr> */
void handleDoxyHtmlTag_tr(DoxygenEntity& tag, std::string& translatedComment, void handleDoxyHtmlTag_tr(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
const std::string &arg);
/* Handles HTML table, tag <th> */ /* Handles HTML table, tag <th> */
void handleDoxyHtmlTag_th(DoxygenEntity& tag, std::string& translatedComment, void handleDoxyHtmlTag_th(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
const std::string &arg);
/* Handles HTML table, tag <td> */ /* Handles HTML table, tag <td> */
void handleDoxyHtmlTag_td(DoxygenEntity& tag, std::string& translatedComment, void handleDoxyHtmlTag_td(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
const std::string &arg);
/* Handles HTML entities recognized by Doxygen, like &lt;, &copy;, ... */ /* Handles HTML entities recognized by Doxygen, like &lt;, &copy;, ... */
void handleHtmlEntity(DoxygenEntity &, std::string &translatedComment, const std::string &arg); void handleHtmlEntity(DoxygenEntity &, std::string &translatedComment, const std::string &arg);