Various small code fixes. Some unwanted code removed.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13551 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dmitry Kabak 2012-08-07 20:04:23 +00:00
commit cecc793782
7 changed files with 36 additions and 177 deletions

View file

@ -2,25 +2,6 @@
#ifndef DOXYGENCOMMANDS_H
#define DOXYGENCOMMANDS_H
const char *commandArray[] = {
"a", "addindex", "addtogroup", "anchor", "arg", "attention",
"author", "authors", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", "cite",
"class", "code", "cond", "copybrief", "copydetails", "copydoc", "copyright", "date", "def",
"defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e",
"else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif",
"endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly",
"enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile",
"hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include",
"includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li",
"line", "link", "mainpage", "manonly", "msc", "mscfile", "n", "name", "namespace", "nosubgrouping",
"note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre",
"private", "privatesection", "property", "protected", "protectedsection", "protocol",
"public", "publicsection", "ref", "relates", "relatesalso", "remarks", "remark", "result", "return", "returns", "retval",
"sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage",
"subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until",
"var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", "$", "@", "\\", "&", "~", "<", ">", "#", "%"};
const char *sectionIndicators[] = {
"attention", "author", "authors", "brief", "bug", "cond", "date", "deprecated", "details",
"else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param",
@ -35,38 +16,22 @@ const char *simpleCommands[] = {
"protected", "protectedsection", "tableofcontents"};
const int simpleCommandsSize = sizeof(simpleCommands) / sizeof(*simpleCommands);
const char *ignoredSimpleCommands[] = {
"nothing at the moment"};
const int ignoredSimpleCommandsSize = sizeof(ignoredSimpleCommands) / sizeof(*ignoredSimpleCommands);
const char *commandWords[] = {
"a", "b", "c", "e", "em", "p", "def", "enum", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include",
"includelineno", "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude", "extends", "implements", "memberof", "related",
"relatedalso", "cite"};
const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords);
const char *ignoredCommandWords[] = {
"nothing at the moment"};
const int ignoredCommandWordsSize = sizeof(ignoredCommandWords) / sizeof(*ignoredCommandWords);
const char *commandLines[] = {
"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"};
const int commandLinesSize = sizeof(commandLines) / sizeof(*commandLines);
const char *ignoreCommandLines[] = {
"nothing at the moment"};
const int ignoreCommandLinesSize = sizeof(ignoreCommandLines) / sizeof(*ignoreCommandLines);
const char *commandParagraph[] = {
"partofdescription", "result", "return", "returns", "remarks", "remark", "since", "test", "sa", "see", "pre", "post", "details", "invariant",
"deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author", "authors",
"copyright", "short"};
const int commandParagraphSize = sizeof(commandParagraph) / sizeof(*commandParagraph);
const char *ignoreCommandParagraphs[] = {
"nothing at the moment"};
const int ignoreCommandParagraphsSize = sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs);
const char *commandEndCommands[] = {
"htmlonly", "latexonly", "manonly", "xmlonly", "link", "rtfonly"};
const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands);

View file

@ -20,13 +20,9 @@
typedef enum {
SIMPLECOMMAND,
IGNOREDSIMPLECOMMAND,
COMMANDWORD,
IGNOREDCOMMANDWORD,
COMMANDLINE,
IGNOREDCOMMANDLINE,
COMMANDPARAGRAPH,
IGNORECOMMANDPARAGRAPH,
COMMANDENDCOMMAND,
COMMANDWORDPARAGRAPH,
COMMANDWORDLINE,

View file

@ -32,24 +32,12 @@ void DoxygenParser::fillTables() {
// fill in tables with data from DxygenCommands.h
for (int i = 0; i < simpleCommandsSize; i++)
doxygenCommands[simpleCommands[i]] = SIMPLECOMMAND;
for (int i = 0; i < ignoredSimpleCommandsSize; i++)
doxygenCommands[ignoredSimpleCommands[i]] = IGNOREDSIMPLECOMMAND;
for (int i = 0; i < commandWordsSize; i++)
doxygenCommands[commandWords[i]] = COMMANDWORD;
for (int i = 0; i < ignoredCommandWordsSize; i++)
doxygenCommands[ignoredCommandWords[i]] = IGNOREDCOMMANDWORD;
for (int i = 0; i < commandLinesSize; i++)
doxygenCommands[commandLines[i]] = COMMANDLINE;
for (int i = 0; i < ignoreCommandLinesSize; i++)
doxygenCommands[ignoreCommandLines[i]] = IGNOREDCOMMANDLINE;
for (int i = 0; i < commandParagraphSize; i++)
doxygenCommands[commandParagraph[i]] = COMMANDPARAGRAPH;
for (int i = 0; i < ignoreCommandParagraphsSize; i++)
doxygenCommands[ignoreCommandParagraphs[i]] = IGNORECOMMANDPARAGRAPH;
for (int i = 0; i < commandEndCommandsSize; i++)
doxygenCommands[commandEndCommands[i]] = COMMANDENDCOMMAND;
for (int i = 0; i < commandWordParagraphsSize; i++)
@ -70,7 +58,7 @@ void DoxygenParser::fillTables() {
doxygenSectionIndicators.insert(sectionIndicators[i]);
}
std::string DoxygenParser::StringToLower(std::string stringToConvert) {
std::string DoxygenParser::stringToLower(std::string &stringToConvert) {
for (unsigned int i = 0; i < stringToConvert.length(); i++) {
stringToConvert[i] = tolower(stringToConvert[i]);
}
@ -79,7 +67,7 @@ std::string DoxygenParser::StringToLower(std::string stringToConvert) {
int DoxygenParser::findCommand(std::string smallString) {
std::map<std::string, DoxyCommandEnum>::iterator it;
smallString = StringToLower(smallString);
smallString = stringToLower(smallString);
// I'm not sure if we can really do so, because there are different commands
// in doxygenCommands and original commandArray
it = doxygenCommands.find(smallString);
@ -89,7 +77,7 @@ int DoxygenParser::findCommand(std::string smallString) {
}
int DoxygenParser::isSectionIndicator(std::string smallString) {
smallString = StringToLower(smallString);
smallString = stringToLower(smallString);
std::set<std::string>::iterator it;
it = doxygenSectionIndicators.find(smallString);
if (it != doxygenSectionIndicators.end())
@ -106,7 +94,7 @@ void DoxygenParser::printTree(std::list < DoxygenEntity > &rootList) {
}
int DoxygenParser::commandBelongs(std::string theCommand) {
std::string smallString = StringToLower(theCommand);
std::string smallString = stringToLower(theCommand);
//cout << " Looking for command " << theCommand << endl;
std::map<std::string, DoxyCommandEnum>::iterator it;
it = doxygenCommands.find(smallString);
@ -238,8 +226,7 @@ std::list < Token >::iterator DoxygenParser::getEndCommand(std::string theComman
return tokList.end();
}
std::list < Token >::iterator DoxygenParser::getTilAnyCommand(std::string theCommand, TokenList & tokList) {
#pragma unused(theCommand,tokList)
std::list < Token >::iterator DoxygenParser::getTilAnyCommand(std::string, TokenList &) {
std::list < Token >::iterator anIterator;
return anIterator;
}
@ -251,13 +238,6 @@ int DoxygenParser::addSimpleCommand(std::string theCommand, std::list < DoxygenE
return 1;
}
int DoxygenParser::ignoreSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) {
#pragma unused(doxyList)
if (noisy)
cout << "Not Adding " << theCommand << endl;
return 1;
}
int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
@ -272,18 +252,6 @@ int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, s
return 0;
}
int DoxygenParser::ignoreCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
#pragma unused(doxyList)
if (noisy)
cout << "Not Adding " << theCommand << endl;
std::string name = getNextWord(tokList);
if (!name.empty())
return 1;
else
tokList.printListError("No word followed " + theCommand + " command.");
return 0;
}
int DoxygenParser::addCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
@ -293,15 +261,6 @@ int DoxygenParser::addCommandLine(std::string theCommand, TokenList & tokList, s
return 1;
}
int DoxygenParser::ignoreCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
#pragma unused(doxyList)
if (noisy)
cout << "Not Adding " << theCommand << endl;
std::list < Token >::iterator endOfLine = getOneLine(tokList);
tokList.setIterator(endOfLine);
return 1;
}
int DoxygenParser::addCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
@ -312,15 +271,6 @@ int DoxygenParser::addCommandParagraph(std::string theCommand, TokenList & tokLi
return 1;
}
int DoxygenParser::ignoreCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
#pragma unused(doxyList)
if (noisy)
cout << "Not Adding " << theCommand << endl;
std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList);
tokList.setIterator(endOfParagraph);
return 1;
}
int DoxygenParser::addCommandEndCommand(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
@ -399,8 +349,7 @@ int DoxygenParser::addCommandOWord(std::string theCommand, TokenList & tokList,
return 1;
}
int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
#pragma unused(doxyList)
int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &) {
tokList.printListError("Encountered: " + theCommand +
"\nThis command should not have been encountered. Behaviour past this may be unpredictable");
std::list < Token >::iterator endOfLine = getOneLine(tokList);
@ -684,7 +633,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
}
int DoxygenParser::addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
std::string theCommand = StringToLower(commandString);
std::string theCommand = stringToLower(commandString);
if (theCommand == "plainstd::string") {
std::string nextPhrase = getStringTilCommand(tokList);
if (noisy)
@ -692,53 +641,30 @@ int DoxygenParser::addCommand(std::string commandString, TokenList & tokList, st
doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase));
return 1;
}
int commandNumber = commandBelongs(theCommand);
if (commandNumber == SIMPLECOMMAND) {
return addSimpleCommand(theCommand, doxyList);
switch (commandBelongs(theCommand)) {
case SIMPLECOMMAND:
return addSimpleCommand(theCommand, doxyList);
case COMMANDWORD:
return addCommandWord(theCommand, tokList, doxyList);
case COMMANDLINE:
return addCommandLine(theCommand, tokList, doxyList);
case COMMANDPARAGRAPH:
return addCommandParagraph(theCommand, tokList, doxyList);
case COMMANDENDCOMMAND:
return addCommandEndCommand(theCommand, tokList, doxyList);
case COMMANDWORDPARAGRAPH:
return addCommandWordParagraph(theCommand, tokList, doxyList);
case COMMANDWORDLINE:
return addCommandWordLine(theCommand, tokList, doxyList);
case COMMANDWORDOWORDWORD:
return addCommandWordOWordOWord(theCommand, tokList, doxyList);
case COMMANDOWORD:
return addCommandOWord(theCommand, tokList, doxyList);
case COMMANDERRORTHROW:
return addCommandErrorThrow(theCommand, tokList, doxyList);
case COMMANDUNIQUE:
return addCommandUnique(theCommand, tokList, doxyList);
}
if (commandNumber == IGNOREDSIMPLECOMMAND) {
return ignoreSimpleCommand(theCommand, doxyList);
}
if (commandNumber == COMMANDWORD) {
return addCommandWord(theCommand, tokList, doxyList);
}
if (commandNumber == IGNOREDCOMMANDWORD) {
return ignoreCommandWord(theCommand, tokList, doxyList);
}
if (commandNumber == COMMANDLINE) {
return addCommandLine(theCommand, tokList, doxyList);
}
if (commandNumber == IGNOREDCOMMANDLINE) {
return ignoreCommandLine(theCommand, tokList, doxyList);
}
if (commandNumber == COMMANDPARAGRAPH) {
return addCommandParagraph(theCommand, tokList, doxyList);
}
if (commandNumber == IGNORECOMMANDPARAGRAPH) {
return ignoreCommandParagraph(theCommand, tokList, doxyList);
}
if (commandNumber == COMMANDENDCOMMAND) {
return addCommandEndCommand(theCommand, tokList, doxyList);
}
if (commandNumber == COMMANDWORDPARAGRAPH) {
return addCommandWordParagraph(theCommand, tokList, doxyList);
}
if (commandNumber == COMMANDWORDLINE) {
return addCommandWordLine(theCommand, tokList, doxyList);
}
if (commandNumber == COMMANDWORDOWORDWORD) {
return addCommandWordOWordOWord(theCommand, tokList, doxyList);
}
if (commandNumber == COMMANDOWORD) {
return addCommandOWord(theCommand, tokList, doxyList);
}
if (commandNumber == COMMANDERRORTHROW) {
return addCommandErrorThrow(theCommand, tokList, doxyList);
}
if (commandNumber == COMMANDUNIQUE) {
return addCommandUnique(theCommand, tokList, doxyList);
}
return 0;
}

View file

@ -27,7 +27,7 @@ private:
/*
*Changes a std::string to all lower case
*/
std::string StringToLower(std::string stringToConvert);
std::string stringToLower(std::string &stringToConvert);
/*
* Finds out if a command exists (is a possible command)
@ -112,12 +112,6 @@ private:
* \n \\ \@ \& \$ \# \< \> \%
*/
int addSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList);
/*
* NOT INCLUDED Simple Commands
* Format: @command
* Plain commands, such as newline etc, they contain no other data
*/
int ignoreSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList);
/*
* CommandWord
* Format: @command <word>
@ -126,13 +120,6 @@ private:
* "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"
*/
int addCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList);
/*
* NOT INCLUDED CommandWord
* Format: @command <word>
* Commands with a single WORD after then such as @b
* "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"
*/
int ignoreCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList);
/*
* CommandLine
* Format: @command (line)
@ -140,12 +127,6 @@ private:
* "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"
*/
int addCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList);
/*
* NOT INCLUDED CommandLine
* Format: @command (line)
* Commands with a single LINE after then such as @var
*/
int ignoreCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList);
/*
* CommandParagraph
* Format: @command {paragraph}
@ -154,12 +135,6 @@ private:
* "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author"
*/
int addCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList);
/*
* CommandParagraph
* Format: @command {paragraph}
* Commands with a single LINE after then such as @var
*/
int ignoreCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList);
/*
* Command EndCommand
* Format: @command and ends at @endcommand
@ -207,9 +182,7 @@ private:
*/
int addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList);
/*
* The actual "meat" of the doxygen parser. This is not yet fully implemented
* with my current design- however the skeletal outline is contained in
* the file Skeleton
* The actual "meat" of the doxygen parser. Calls the correct addCommand* function
*/
int addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList);

View file

@ -32,7 +32,7 @@ String *DoxygenTranslator::getDoxygenComment(Node *node) {
String *DoxygenTranslator::getDocumentation(Node *node) {
if (!hasDocumentation(node))
return 0;
return NewString("");
return makeDocumentation(node);
}

View file

@ -39,7 +39,7 @@ public:
* Return the documentation for a given node formated for the correct
* documentation system.
* @param node The node to extract and translate documentation for.
* @return The resulted documentation string.
* @return The resulted documentation string, or empty string in case of any errors.
*/
String *getDocumentation(Node *node);
/*
@ -57,8 +57,7 @@ protected:
* Overridden in subclasses to return the documentation formatted for a given
* documentation system.
* @param node The node to extract and translate documentation for.
* @param documentation The returned documentation string.
* @return A bool to indicate if there was documentation to return for the node.
* @return The resulted documentation string
*/
virtual String *makeDocumentation(Node *node) = 0;

View file

@ -45,7 +45,7 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c
// check if it's one of the '!!!', '***', '///' of any length
char c = currentWord[0];
isPlainString = false;
for (int i=0; i<currentWord.size(); i++)
for (size_t i=0; i<currentWord.size(); i++)
if (currentWord[i] != c) {
isPlainString = true;
break;