formatting fixes after running make beautify plus a few manual formatting fixes

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@11699 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-10-13 23:26:01 +00:00
commit 19d90026ef
17 changed files with 1805 additions and 1729 deletions

View file

@ -10,7 +10,7 @@
#include "DoxygenEntity.h" #include "DoxygenEntity.h"
#include <iostream> #include <iostream>
DoxygenEntity::DoxygenEntity(std::string typeEnt){ DoxygenEntity::DoxygenEntity(std::string typeEnt) {
typeOfEntity = typeEnt; typeOfEntity = typeEnt;
data = ""; data = "";
isLeaf = true; isLeaf = true;
@ -21,7 +21,7 @@ DoxygenEntity::DoxygenEntity(std::string typeEnt){
* example: \b word * example: \b word
* OR holding a std::string * OR holding a std::string
*/ */
DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){ DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1) {
typeOfEntity = typeEnt; typeOfEntity = typeEnt;
data = param1; data = param1;
isLeaf = true; isLeaf = true;
@ -30,14 +30,14 @@ DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){
/* Nonterminal node /* Nonterminal node
* contains * contains
*/ */
DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list <DoxygenEntity> &entList ){ DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list < DoxygenEntity > &entList) {
typeOfEntity = typeEnt; typeOfEntity = typeEnt;
data = ""; data = "";
isLeaf = false; isLeaf = false;
entityList = entList; entityList = entList;
} }
void DoxygenEntity::printEntity(int level){ void DoxygenEntity::printEntity(int level) {
int thisLevel = level; int thisLevel = level;
if (isLeaf) { if (isLeaf) {
for (int i = 0; i < thisLevel; i++) { for (int i = 0; i < thisLevel; i++) {
@ -59,10 +59,10 @@ void DoxygenEntity::printEntity(int level){
std::cout << "Node Command : " << typeOfEntity << std::endl; std::cout << "Node Command : " << typeOfEntity << std::endl;
std::list<DoxygenEntity>::iterator p = entityList.begin(); std::list < DoxygenEntity >::iterator p = entityList.begin();
thisLevel++; thisLevel++;
while (p != entityList.end()){ while (p != entityList.end()) {
(*p).printEntity(thisLevel); (*p).printEntity(thisLevel);
p++; p++;
} }
@ -70,124 +70,122 @@ void DoxygenEntity::printEntity(int level){
} }
// not used, completely wrong - currently std lib reports 'invalid operator <' // not used, completely wrong - currently std lib reports 'invalid operator <'
bool CompareDoxygenEntities::operator()(DoxygenEntity& first, DoxygenEntity& second){ bool CompareDoxygenEntities::operator() (DoxygenEntity & first, DoxygenEntity & second) {
// return first.typeOfEntity < second.typeOfEntity; // return first.typeOfEntity < second.typeOfEntity;
if(first.typeOfEntity.compare("brief") == 0) if (first.typeOfEntity.compare("brief") == 0)
return true; return true;
if(second.typeOfEntity.compare("brief") == 0) if (second.typeOfEntity.compare("brief") == 0)
return false; return false;
if(first.typeOfEntity.compare("details") == 0) if (first.typeOfEntity.compare("details") == 0)
return true; return true;
if(second.typeOfEntity.compare("details") == 0) if (second.typeOfEntity.compare("details") == 0)
return false; return false;
if(first.typeOfEntity.compare("partofdescription") == 0) if (first.typeOfEntity.compare("partofdescription") == 0)
return true; return true;
if(second.typeOfEntity.compare("partofdescription") == 0) if (second.typeOfEntity.compare("partofdescription") == 0)
return false; return false;
if(first.typeOfEntity.compare("plainstd::string") == 0) if (first.typeOfEntity.compare("plainstd::string") == 0)
return true; return true;
if(second.typeOfEntity.compare("plainstd::string") == 0) if (second.typeOfEntity.compare("plainstd::string") == 0)
return false; return false;
if(first.typeOfEntity.compare("param") == 0){ if (first.typeOfEntity.compare("param") == 0) {
if(second.typeOfEntity.compare("param")== 0) if (second.typeOfEntity.compare("param") == 0)
return true; return true;
if(second.typeOfEntity.compare("return")== 0) if (second.typeOfEntity.compare("return") == 0)
return true; return true;
if(second.typeOfEntity.compare("exception")== 0) if (second.typeOfEntity.compare("exception") == 0)
return true; return true;
if(second.typeOfEntity.compare("author")== 0) if (second.typeOfEntity.compare("author") == 0)
return true; return true;
if(second.typeOfEntity.compare("version")== 0) if (second.typeOfEntity.compare("version") == 0)
return true; return true;
if(second.typeOfEntity.compare("see")== 0) if (second.typeOfEntity.compare("see") == 0)
return true; return true;
if(second.typeOfEntity.compare("since")== 0) if (second.typeOfEntity.compare("since") == 0)
return true; return true;
if(second.typeOfEntity.compare("deprecated")== 0) if (second.typeOfEntity.compare("deprecated") == 0)
return true; return true;
return false; return false;
} }
if(first.typeOfEntity.compare("return")== 0){ if (first.typeOfEntity.compare("return") == 0) {
if(second.typeOfEntity.compare("return")== 0) if (second.typeOfEntity.compare("return") == 0)
return true; return true;
if(second.typeOfEntity.compare("exception")== 0) if (second.typeOfEntity.compare("exception") == 0)
return true; return true;
if(second.typeOfEntity.compare("author")== 0) if (second.typeOfEntity.compare("author") == 0)
return true; return true;
if(second.typeOfEntity.compare("version")== 0) if (second.typeOfEntity.compare("version") == 0)
return true; return true;
if(second.typeOfEntity.compare("see")== 0) if (second.typeOfEntity.compare("see") == 0)
return true; return true;
if(second.typeOfEntity.compare("since")== 0) if (second.typeOfEntity.compare("since") == 0)
return true; return true;
if(second.typeOfEntity.compare("deprecated")== 0 if (second.typeOfEntity.compare("deprecated") == 0)
)return true;
return false;
}
if(first.typeOfEntity.compare("exception")== 0){
if(second.typeOfEntity.compare("exception")== 0)
return true;
if(second.typeOfEntity.compare("author")== 0)
return true;
if(second.typeOfEntity.compare("version")== 0)
return true;
if(second.typeOfEntity.compare("see")== 0)
return true;
if(second.typeOfEntity.compare("since")== 0)
return true;
if(second.typeOfEntity.compare("deprecated")== 0)
return true; return true;
return false; return false;
} }
if(first.typeOfEntity.compare("author")== 0){ if (first.typeOfEntity.compare("exception") == 0) {
if(second.typeOfEntity.compare("author")== 0) if (second.typeOfEntity.compare("exception") == 0)
return true; return true;
if(second.typeOfEntity.compare("version")== 0) if (second.typeOfEntity.compare("author") == 0)
return true; return true;
if(second.typeOfEntity.compare("see")== 0) if (second.typeOfEntity.compare("version") == 0)
return true; return true;
if(second.typeOfEntity.compare("since")== 0) if (second.typeOfEntity.compare("see") == 0)
return true; return true;
if(second.typeOfEntity.compare("deprecated")== 0) if (second.typeOfEntity.compare("since") == 0)
return true;
if (second.typeOfEntity.compare("deprecated") == 0)
return true; return true;
return false; return false;
} }
if(first.typeOfEntity.compare("version")== 0){ if (first.typeOfEntity.compare("author") == 0) {
if(second.typeOfEntity.compare("version")== 0) if (second.typeOfEntity.compare("author") == 0)
return true; return true;
if(second.typeOfEntity.compare("see")== 0) if (second.typeOfEntity.compare("version") == 0)
return true; return true;
if(second.typeOfEntity.compare("since")== 0) if (second.typeOfEntity.compare("see") == 0)
return true; return true;
if(second.typeOfEntity.compare("deprecated")== 0) if (second.typeOfEntity.compare("since") == 0)
return true;
if (second.typeOfEntity.compare("deprecated") == 0)
return true; return true;
return false; return false;
} }
if(first.typeOfEntity.compare("see")== 0 || first.typeOfEntity.compare("sa")== 0){ if (first.typeOfEntity.compare("version") == 0) {
if(second.typeOfEntity.compare("see")== 0) if (second.typeOfEntity.compare("version") == 0)
return true; return true;
if(second.typeOfEntity.compare("sa")== 0) if (second.typeOfEntity.compare("see") == 0)
return true; return true;
if(second.typeOfEntity.compare("since")== 0) if (second.typeOfEntity.compare("since") == 0)
return true; return true;
if(second.typeOfEntity.compare("deprecated")== 0) if (second.typeOfEntity.compare("deprecated") == 0)
return true; return true;
return false; return false;
} }
if(first.typeOfEntity.compare("since")== 0){ if (first.typeOfEntity.compare("see") == 0 || first.typeOfEntity.compare("sa") == 0) {
if(second.typeOfEntity.compare("since")== 0) if (second.typeOfEntity.compare("see") == 0)
return true; return true;
if(second.typeOfEntity.compare("deprecated")== 0) if (second.typeOfEntity.compare("sa") == 0)
return true;
if (second.typeOfEntity.compare("since") == 0)
return true;
if (second.typeOfEntity.compare("deprecated") == 0)
return true; return true;
return false; return false;
} }
if(first.typeOfEntity.compare("deprecated")== 0){ if (first.typeOfEntity.compare("since") == 0) {
if(second.typeOfEntity.compare("deprecated")== 0) if (second.typeOfEntity.compare("since") == 0)
return true;
if (second.typeOfEntity.compare("deprecated") == 0)
return true;
return false;
}
if (first.typeOfEntity.compare("deprecated") == 0) {
if (second.typeOfEntity.compare("deprecated") == 0)
return true; return true;
return false; return false;
} }
return true; return true;
} }

View file

@ -39,15 +39,15 @@ typedef enum {
/* /*
* Structure to represent a doxygen comment entry * Structure to represent a doxygen comment entry
*/ */
struct DoxygenEntity{ struct DoxygenEntity {
std::string typeOfEntity; std::string typeOfEntity;
std::list <DoxygenEntity> entityList; std::list < DoxygenEntity > entityList;
std::string data; std::string data;
bool isLeaf; bool isLeaf;
DoxygenEntity(std::string typeEnt); DoxygenEntity(std::string typeEnt);
DoxygenEntity(std::string typeEnt, std::string param1); DoxygenEntity(std::string typeEnt, std::string param1);
DoxygenEntity(std::string typeEnt, std::list <DoxygenEntity> &entList ); DoxygenEntity(std::string typeEnt, std::list < DoxygenEntity > &entList);
void printEntity(int level); void printEntity(int level);
}; };
@ -58,7 +58,7 @@ struct DoxygenEntity{
* such as brief descriptions are TAGGED as such * such as brief descriptions are TAGGED as such
*/ */
struct CompareDoxygenEntities { struct CompareDoxygenEntities {
bool operator()(DoxygenEntity& first, DoxygenEntity& second); bool operator() (DoxygenEntity & first, DoxygenEntity & second);
}; };
#endif /*TOKENLIST_H_*/ #endif

View file

@ -2,23 +2,22 @@
#include "TokenList.h" #include "TokenList.h"
DoxygenParser::DoxygenParser() DoxygenParser::DoxygenParser() {
{
} }
DoxygenParser::~DoxygenParser() DoxygenParser::~DoxygenParser() {
{
} }
////////////////////////////////////////// //////////////////////////////////////////
int noisy = 0; // set this to 1 for extra chatter from the parsing stage. int noisy = 0; // set this to 1 for extra chatter from the parsing stage.
int addCommand(std::string currCommand, TokenList &tokList, std::list <DoxygenEntity> &aNewList); int addCommand(std::string currCommand, TokenList & tokList, std::list < DoxygenEntity > &aNewList);
std::list <DoxygenEntity> parse(std::list<Token>::iterator endParsingIndex, TokenList &tokList); std::list < DoxygenEntity > parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList);
////////////////////////////////////////// //////////////////////////////////////////
std::string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", std::string commandArray[] = {
"a", "addindex", "addtogroup", "anchor", "arg", "attention",
"author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category",
"class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def",
"defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e",
@ -33,44 +32,67 @@ std::string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "a
"public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval",
"sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage",
"subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until", "subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until",
"var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", "$", "@", "\\", "&", "~", "<", ">", "#", "%"};
"$", "@", "\\","&", "~", "<", ">", "#", "%"};
std::string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", std::string sectionIndicators[] = {
"attention", "author", "brief", "bug", "cond", "date", "deprecated", "details",
"else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param",
"tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "throws", "todo", "tparam", "post", "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "throws", "todo", "version", "warning", "xrefitem"};
"version", "warning", "xrefitem" };
/* All of the doxygen commands divided up by how they are parsed */ /* All of the doxygen commands divided up by how they are parsed */
std::string simpleCommands[] = {"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; std::string simpleCommands[] = {
std::string ignoredSimpleCommands[] = {"nothing at the moment"}; "n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"};
std::string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package",
"relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; std::string ignoredSimpleCommands[] = {
std::string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; "nothing at the moment"};
std::string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"};
std::string ignoreCommandLines[] = {"nothing at the moment"}; std::string commandWords[] = {
std::string commandParagraph[] = {"partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno"};
std::string ignoredCommandWords[] = {
"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"};
std::string commandLines[] = {
"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"};
std::string ignoreCommandLines[] = {
"nothing at the moment"};
std::string commandParagraph[] = {
"partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant",
"deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"};
std::string ignoreCommandParagraphs[] = {"nothing at the moment"};
std::string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", std::string ignoreCommandParagraphs[] = {
"verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; "nothing at the moment"};
std::string commandWordParagraphs[] = {"param", "tparam", "throw", "throws", "retval", "exception"};
std::string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; std::string commandEndCommands[] = {
std::string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "cond", "if", "ifnot", "link"};
std::string commandOWords[] = {"dir", "file", "cond"};
std::string commandErrorThrowings[] = {"annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", std::string commandWordParagraphs[] = {
"param", "tparam", "throw", "throws", "retval", "exception"};
std::string commandWordLines[] = {
"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"};
std::string commandWordOWordOWords[] = {
"category", "class", "protocol", "interface", "struct", "union"};
std::string commandOWords[] = {
"dir", "file", "cond"};
std::string commandErrorThrowings[] = {
"annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header",
"headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected",
"protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly",
"endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", "endif"};
"endif"}; std::string commandUniques[] = {
std::string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li"};
"subpage", "dotfile", "image", "addtogroup", "li"};
/* Changes a std::string to all lower case */ /* Changes a std::string to all lower case */
std::string StringToLower(std::string stringToConvert){ std::string StringToLower(std::string stringToConvert) {
for(unsigned int i=0;i<stringToConvert.length();i++){ for (unsigned int i = 0; i < stringToConvert.length(); i++) {
stringToConvert[i] = tolower(stringToConvert[i]); stringToConvert[i] = tolower(stringToConvert[i]);
} }
return stringToConvert; //return the converted std::string return stringToConvert; //return the converted std::string
@ -79,11 +101,11 @@ std::string StringToLower(std::string stringToConvert){
/* finds out if a command exists (is a possible command) /* finds out if a command exists (is a possible command)
* from the std::string array commandArray * from the std::string array commandArray
* returns -1 if no match is found */ * returns -1 if no match is found */
int findCommand(std::string smallString){ int findCommand(std::string smallString) {
smallString = StringToLower(smallString); smallString = StringToLower(smallString);
int a; int a;
for (unsigned i = 0; i < sizeof(commandArray)/sizeof(*commandArray); i++){ for (unsigned i = 0; i < sizeof(commandArray) / sizeof(*commandArray); i++) {
if( (a = smallString.compare(commandArray[i])) == 0){ if ((a = smallString.compare(commandArray[i])) == 0) {
return 101 + i; return 101 + i;
} }
} }
@ -94,10 +116,10 @@ int findCommand(std::string smallString){
* This is a helper method for finding the end of a paragraph * This is a helper method for finding the end of a paragraph
* by Doxygen's terms * by Doxygen's terms
*/ */
int isSectionIndicator(std::string smallString){ int isSectionIndicator(std::string smallString) {
smallString = StringToLower(smallString); smallString = StringToLower(smallString);
for (unsigned i = 0; i < sizeof( sectionIndicators)/sizeof(* sectionIndicators); i++){ for (unsigned i = 0; i < sizeof(sectionIndicators) / sizeof(*sectionIndicators); i++) {
if( smallString.compare( sectionIndicators[i]) == 0){ if (smallString.compare(sectionIndicators[i]) == 0) {
return 1; return 1;
} }
} }
@ -105,9 +127,9 @@ int isSectionIndicator(std::string smallString){
} }
/* prints the parse tree */ /* prints the parse tree */
void printTree( std::list <DoxygenEntity> &rootList){ void printTree(std::list < DoxygenEntity > &rootList) {
std::list<DoxygenEntity>::iterator p = rootList.begin(); std::list < DoxygenEntity >::iterator p = rootList.begin();
while (p != rootList.end()){ while (p != rootList.end()) {
(*p).printEntity(0); (*p).printEntity(0);
p++; p++;
} }
@ -116,68 +138,68 @@ void printTree( std::list <DoxygenEntity> &rootList){
/* Determines how a command should be handled (what group it belongs to /* Determines how a command should be handled (what group it belongs to
* for parsing rules * for parsing rules
*/ */
int commandBelongs(std::string theCommand){ int commandBelongs(std::string theCommand) {
std::string smallString = StringToLower(theCommand); std::string smallString = StringToLower(theCommand);
//cout << " Looking for command " << theCommand << endl; //cout << " Looking for command " << theCommand << endl;
unsigned i = 0; unsigned i = 0;
for (i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ for (i = 0; i < sizeof(simpleCommands) / sizeof(*simpleCommands); i++) {
if(smallString.compare(simpleCommands[i]) == 0) if (smallString.compare(simpleCommands[i]) == 0)
return SIMPLECOMMAND; return SIMPLECOMMAND;
} }
for (i = 0; i < sizeof(ignoredSimpleCommands)/sizeof(*ignoredSimpleCommands); i++){ for (i = 0; i < sizeof(ignoredSimpleCommands) / sizeof(*ignoredSimpleCommands); i++) {
if(smallString.compare(ignoredSimpleCommands[i]) == 0) if (smallString.compare(ignoredSimpleCommands[i]) == 0)
return IGNOREDSIMPLECOMMAND; return IGNOREDSIMPLECOMMAND;
} }
for (i = 0; i < sizeof(commandWords)/sizeof(*commandWords); i++){ for (i = 0; i < sizeof(commandWords) / sizeof(*commandWords); i++) {
if(smallString.compare( commandWords[i]) == 0) if (smallString.compare(commandWords[i]) == 0)
return COMMANDWORD; return COMMANDWORD;
} }
for (i = 0; i < sizeof(ignoredCommandWords)/sizeof(*ignoredCommandWords); i++){ for (i = 0; i < sizeof(ignoredCommandWords) / sizeof(*ignoredCommandWords); i++) {
if(smallString.compare( ignoredCommandWords[i]) == 0) if (smallString.compare(ignoredCommandWords[i]) == 0)
return IGNOREDCOMMANDWORD; return IGNOREDCOMMANDWORD;
} }
for (i = 0; i < sizeof(commandLines)/sizeof(*commandLines); i++){ for (i = 0; i < sizeof(commandLines) / sizeof(*commandLines); i++) {
if(smallString.compare( commandLines[i]) == 0) if (smallString.compare(commandLines[i]) == 0)
return COMMANDLINE; return COMMANDLINE;
} }
for (i = 0; i < sizeof(ignoreCommandLines)/sizeof(*ignoreCommandLines); i++){ for (i = 0; i < sizeof(ignoreCommandLines) / sizeof(*ignoreCommandLines); i++) {
if(smallString.compare( ignoreCommandLines[i]) == 0) if (smallString.compare(ignoreCommandLines[i]) == 0)
return IGNOREDCOMMANDLINE; return IGNOREDCOMMANDLINE;
} }
for (i = 0; i < sizeof(commandParagraph)/sizeof(*commandParagraph); i++){ for (i = 0; i < sizeof(commandParagraph) / sizeof(*commandParagraph); i++) {
if(smallString.compare( commandParagraph[i]) == 0) if (smallString.compare(commandParagraph[i]) == 0)
return COMMANDPARAGRAPH; return COMMANDPARAGRAPH;
} }
for (i = 0; i < sizeof(ignoreCommandParagraphs)/sizeof(*ignoreCommandParagraphs); i++){ for (i = 0; i < sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs); i++) {
if(smallString.compare( ignoreCommandParagraphs[i]) == 0) if (smallString.compare(ignoreCommandParagraphs[i]) == 0)
return IGNORECOMMANDPARAGRAPH; return IGNORECOMMANDPARAGRAPH;
} }
for (i = 0; i < sizeof(commandEndCommands)/sizeof(*commandEndCommands); i++){ for (i = 0; i < sizeof(commandEndCommands) / sizeof(*commandEndCommands); i++) {
if(smallString.compare( commandEndCommands[i]) == 0) if (smallString.compare(commandEndCommands[i]) == 0)
return COMMANDENDCOMMAND; return COMMANDENDCOMMAND;
} }
for (i = 0; i < sizeof(commandWordParagraphs)/sizeof(*commandWordParagraphs); i++){ for (i = 0; i < sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs); i++) {
if(smallString.compare( commandWordParagraphs[i]) == 0) if (smallString.compare(commandWordParagraphs[i]) == 0)
return COMMANDWORDPARAGRAPH; return COMMANDWORDPARAGRAPH;
} }
for (i = 0; i < sizeof(commandWordLines)/sizeof(*commandWordLines); i++){ for (i = 0; i < sizeof(commandWordLines) / sizeof(*commandWordLines); i++) {
if(smallString.compare( commandWordLines[i]) == 0) if (smallString.compare(commandWordLines[i]) == 0)
return COMMANDWORDLINE; return COMMANDWORDLINE;
} }
for (i = 0; i < sizeof(commandWordOWordOWords)/sizeof(*commandWordOWordOWords); i++){ for (i = 0; i < sizeof(commandWordOWordOWords) / sizeof(*commandWordOWordOWords); i++) {
if(smallString.compare( commandWordOWordOWords[i]) == 0) if (smallString.compare(commandWordOWordOWords[i]) == 0)
return COMMANDWORDOWORDWORD; return COMMANDWORDOWORDWORD;
} }
for (i = 0; i < sizeof(commandOWords)/sizeof(*commandOWords); i++){ for (i = 0; i < sizeof(commandOWords) / sizeof(*commandOWords); i++) {
if(smallString.compare( commandOWords[i]) == 0) if (smallString.compare(commandOWords[i]) == 0)
return COMMANDOWORD; return COMMANDOWORD;
} }
for (i = 0; i < sizeof(commandErrorThrowings)/sizeof(*commandErrorThrowings); i++){ for (i = 0; i < sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings); i++) {
if(smallString.compare( commandErrorThrowings[i]) == 0) if (smallString.compare(commandErrorThrowings[i]) == 0)
return COMMANDERRORTHROW; return COMMANDERRORTHROW;
} }
for (i = 0; i < sizeof(commandUniques)/sizeof(*commandUniques); i++){ for (i = 0; i < sizeof(commandUniques) / sizeof(*commandUniques); i++) {
if(smallString.compare( commandUniques[i]) == 0) if (smallString.compare(commandUniques[i]) == 0)
return COMMANDUNIQUE; return COMMANDUNIQUE;
} }
return 0; return 0;
@ -187,9 +209,9 @@ int commandBelongs(std::string theCommand){
* if a new line is encountered, returns a blank std::string. * if a new line is encountered, returns a blank std::string.
* Updates the index it is given if success. * Updates the index it is given if success.
*/ */
std::string getNextWord(TokenList &tokList){ std::string getNextWord(TokenList & tokList) {
Token nextToken = tokList.peek(); Token nextToken = tokList.peek();
if (nextToken.tokenType == PLAINSTRING ){ if (nextToken.tokenType == PLAINSTRING) {
nextToken = tokList.next(); nextToken = tokList.next();
return nextToken.tokenString; return nextToken.tokenString;
} }
@ -199,10 +221,10 @@ std::string getNextWord(TokenList &tokList){
/* Returns the location of the end of the line as /* Returns the location of the end of the line as
* an iterator. * an iterator.
*/ */
std::list<Token>::iterator getOneLine(TokenList &tokList){ std::list < Token >::iterator getOneLine(TokenList & tokList) {
std::list<Token>::iterator endOfLine = tokList.iteratorCopy(); std::list < Token >::iterator endOfLine = tokList.iteratorCopy();
while(endOfLine!= tokList.end()){ while (endOfLine != tokList.end()) {
if ((* endOfLine).tokenType == END_LINE){ if ((*endOfLine).tokenType == END_LINE) {
//cout << "REACHED END" << endl; //cout << "REACHED END" << endl;
//endOfLine++; //endOfLine++;
return endOfLine; return endOfLine;
@ -212,48 +234,50 @@ std::list<Token>::iterator getOneLine(TokenList &tokList){
} }
return tokList.end(); return tokList.end();
} }
/* Returns a properly formatted std::string /* Returns a properly formatted std::string
* up til ANY command or end of line is encountered. * up til ANY command or end of line is encountered.
*/ */
std::string getStringTilCommand(TokenList &tokList){ std::string getStringTilCommand(TokenList & tokList) {
std::string description; std::string description;
if (tokList.peek().tokenType == 0) return ""; if (tokList.peek().tokenType == 0)
while(tokList.peek().tokenType == PLAINSTRING){ return "";
while (tokList.peek().tokenType == PLAINSTRING) {
Token currentToken = tokList.next(); Token currentToken = tokList.next();
if(currentToken.tokenType == PLAINSTRING) { if (currentToken.tokenType == PLAINSTRING) {
description = description + currentToken.tokenString + " "; description = description + currentToken.tokenString + " ";
} }
} }
return description; return description;
} }
/* Returns a properly formatted std::string /* Returns a properly formatted std::string
* 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(std::string theCommand, TokenList &tokList){ std::string getStringTilEndCommand(std::string theCommand, TokenList & tokList) {
std::string description; std::string description;
if (tokList.peek().tokenType == 0) return ""; if (tokList.peek().tokenType == 0)
while(tokList.peek().tokenString.compare(theCommand) != 0 ){ return "";
while (tokList.peek().tokenString.compare(theCommand) != 0) {
Token currentToken = tokList.next(); Token currentToken = tokList.next();
description = description + currentToken.tokenString + " "; description = description + currentToken.tokenString + " ";
} }
return description; return description;
} }
/* Returns the end of a Paragraph as an iterator- /* Returns the end of a Paragraph as an iterator-
* Paragraph is defined in Doxygen to be a paragraph of text * Paragraph is defined in Doxygen to be a paragraph of text
* separated by either a structural command or a blank line * separated by either a structural command or a blank line
*/ */
std::list<Token>::iterator getEndOfParagraph(TokenList &tokList){ std::list < Token >::iterator getEndOfParagraph(TokenList & tokList) {
std::list<Token>::iterator endOfParagraph = tokList.iteratorCopy(); std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy();
while(endOfParagraph != tokList.end()){ while (endOfParagraph != tokList.end()) {
if ((* endOfParagraph).tokenType == END_LINE){ if ((*endOfParagraph).tokenType == END_LINE) {
endOfParagraph++; endOfParagraph++;
if (endOfParagraph != tokList.end() && (* endOfParagraph).tokenType == END_LINE) { if (endOfParagraph != tokList.end() && (*endOfParagraph).tokenType == END_LINE) {
endOfParagraph++; endOfParagraph++;
//cout << "ENCOUNTERED END OF PARA" << endl; //cout << "ENCOUNTERED END OF PARA" << endl;
return endOfParagraph; return endOfParagraph;
@ -261,10 +285,10 @@ std::list<Token>::iterator getEndOfParagraph(TokenList &tokList){
} else if ((*endOfParagraph).tokenType == COMMAND) { } else if ((*endOfParagraph).tokenType == COMMAND) {
if (isSectionIndicator((* endOfParagraph).tokenString)) { if (isSectionIndicator((*endOfParagraph).tokenString)) {
return endOfParagraph; return endOfParagraph;
} } else
else endOfParagraph++; endOfParagraph++;
} else if ((*endOfParagraph).tokenType == PLAINSTRING) { } else if ((*endOfParagraph).tokenType == PLAINSTRING) {
endOfParagraph++; endOfParagraph++;
@ -274,32 +298,32 @@ std::list<Token>::iterator getEndOfParagraph(TokenList &tokList){
} }
return tokList.end(); return tokList.end();
} }
/* Returns the end of a section, defined as the first blank line OR first encounter of the same /* Returns the end of a section, defined as the first blank line OR first encounter of the same
* command. Example of this behaviour is \arg * 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.
*/ */
std::list<Token>::iterator getEndOfSection(std::string theCommand, TokenList &tokList){ std::list < Token >::iterator getEndOfSection(std::string theCommand, TokenList & tokList) {
std::list<Token>::iterator endOfParagraph = tokList.iteratorCopy(); std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy();
while(endOfParagraph != tokList.end()){ while (endOfParagraph != tokList.end()) {
if ((* endOfParagraph).tokenType == COMMAND){ if ((*endOfParagraph).tokenType == COMMAND) {
if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph; if (theCommand.compare((*endOfParagraph).tokenString) == 0)
else endOfParagraph++; return endOfParagraph;
} else
else if((* endOfParagraph).tokenType == PLAINSTRING) {
endOfParagraph++; endOfParagraph++;
} } else if ((*endOfParagraph).tokenType == PLAINSTRING) {
else if ((* endOfParagraph).tokenType == END_LINE){
endOfParagraph++; endOfParagraph++;
if ((* endOfParagraph).tokenType == END_LINE){ } else if ((*endOfParagraph).tokenType == END_LINE) {
endOfParagraph++;
if ((*endOfParagraph).tokenType == END_LINE) {
endOfParagraph++; endOfParagraph++;
return endOfParagraph; return endOfParagraph;
} }
} }
} }
return tokList.end(); return tokList.end();
} }
/* 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
* that begins with a \command and ends in \endcommand * that begins with a \command and ends in \endcommand
@ -307,11 +331,11 @@ std::list<Token>::iterator getEndOfSection(std::string theCommand, TokenList &to
* 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.
*/ */
std::list<Token>::iterator getEndCommand(std::string theCommand, TokenList &tokList){ std::list < Token >::iterator getEndCommand(std::string theCommand, TokenList & tokList) {
std::list<Token>::iterator endOfCommand = tokList.iteratorCopy(); std::list < Token >::iterator endOfCommand = tokList.iteratorCopy();
while (endOfCommand!= tokList.end()){ while (endOfCommand != tokList.end()) {
if ((*endOfCommand).tokenType == COMMAND){ if ((*endOfCommand).tokenType == COMMAND) {
if (theCommand.compare((* endOfCommand).tokenString) == 0){ if (theCommand.compare((*endOfCommand).tokenString) == 0) {
return endOfCommand; return endOfCommand;
} }
endOfCommand++; endOfCommand++;
@ -324,9 +348,9 @@ std::list<Token>::iterator getEndCommand(std::string theCommand, TokenList &tokL
/* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered
*/ */
//TODO getTilAnyCommand //TODO getTilAnyCommand
std::list<Token>::iterator getTilAnyCommand(std::string theCommand, TokenList &tokList){ std::list < Token >::iterator getTilAnyCommand(std::string theCommand, TokenList & tokList) {
#pragma unused(theCommand,tokList) #pragma unused(theCommand,tokList)
std::list<Token>::iterator anIterator; std::list < Token >::iterator anIterator;
return anIterator; return anIterator;
} }
@ -338,8 +362,9 @@ std::list<Token>::iterator getTilAnyCommand(std::string theCommand, TokenList &t
* Plain commands, such as newline etc, they contain no other data * Plain commands, such as newline etc, they contain no other data
* \n \\ \@ \& \$ \# \< \> \% * \n \\ \@ \& \$ \# \< \> \%
*/ */
int addSimpleCommand(std::string theCommand, std::list <DoxygenEntity> &doxyList){ int addSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) {
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy)
cout << "Parsing " << theCommand << endl;
doxyList.push_back(DoxygenEntity(theCommand)); doxyList.push_back(DoxygenEntity(theCommand));
return 1; return 1;
} }
@ -348,9 +373,10 @@ int addSimpleCommand(std::string theCommand, std::list <DoxygenEntity> &doxyList
* Format: @command * Format: @command
* Plain commands, such as newline etc, they contain no other data * Plain commands, such as newline etc, they contain no other data
*/ */
int ignoreSimpleCommand(std::string theCommand, std::list <DoxygenEntity> &doxyList){ int ignoreSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) {
#pragma unused(doxyList) #pragma unused(doxyList)
if (noisy) cout << "Not Adding " << theCommand << endl; if (noisy)
cout << "Not Adding " << theCommand << endl;
return 1; return 1;
} }
@ -360,14 +386,14 @@ int ignoreSimpleCommand(std::string theCommand, std::list <DoxygenEntity> &doxyL
* "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package",
* "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"
*/ */
int addCommandWord(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int addCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy)
cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (!name.empty()){ if (!name.empty()) {
doxyList.push_back(DoxygenEntity(theCommand, name)); doxyList.push_back(DoxygenEntity(theCommand, name));
return 1; return 1;
} } else
else
cout << "No word followed " << theCommand << " command. Not added" << endl; cout << "No word followed " << theCommand << " command. Not added" << endl;
return 0; return 0;
} }
@ -377,7 +403,7 @@ int addCommandWord(std::string theCommand, TokenList &tokList, std::list <Doxyge
* Commands with a single WORD after then such as @b * Commands with a single WORD after then such as @b
* "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"
*/ */
int ignoreCommandWord(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int ignoreCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
#pragma unused(doxyList) #pragma unused(doxyList)
if (noisy) if (noisy)
cout << "Not Adding " << theCommand << endl; cout << "Not Adding " << theCommand << endl;
@ -394,12 +420,12 @@ int ignoreCommandWord(std::string theCommand, TokenList &tokList, std::list <Dox
* Commands with a single LINE after then such as @var * Commands with a single LINE after then such as @var
* "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"
*/ */
int addCommandLine(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int addCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::list<Token>::iterator endOfLine = getOneLine(tokList); std::list < Token >::iterator endOfLine = getOneLine(tokList);
std::list <DoxygenEntity> aNewList = parse(endOfLine, tokList); std::list < DoxygenEntity > aNewList = parse(endOfLine, tokList);
doxyList.push_back( DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1; return 1;
} }
@ -408,11 +434,11 @@ int addCommandLine(std::string theCommand, TokenList &tokList, std::list <Doxyge
* Commands with a single LINE after then such as @var * Commands with a single LINE after then such as @var
* *
*/ */
int ignoreCommandLine(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int ignoreCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
#pragma unused(doxyList) #pragma unused(doxyList)
if (noisy) if (noisy)
cout << "Not Adding " << theCommand << endl; cout << "Not Adding " << theCommand << endl;
std::list<Token>::iterator endOfLine = getOneLine(tokList); std::list < Token >::iterator endOfLine = getOneLine(tokList);
tokList.setIterator(endOfLine); tokList.setIterator(endOfLine);
return 1; return 1;
} }
@ -423,13 +449,13 @@ int ignoreCommandLine(std::string theCommand, TokenList &tokList, std::list <Dox
* "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant",
* "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author"
*/ */
int addCommandParagraph(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int addCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList);
std::list <DoxygenEntity> aNewList; std::list < DoxygenEntity > aNewList;
aNewList = parse(endOfParagraph, tokList); aNewList = parse(endOfParagraph, tokList);
doxyList.push_back( DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1; return 1;
} }
@ -438,11 +464,11 @@ int addCommandParagraph(std::string theCommand, TokenList &tokList, std::list <D
* Commands with a single LINE after then such as @var * Commands with a single LINE after then such as @var
* *
*/ */
int ignoreCommandParagraph(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int ignoreCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
#pragma unused(doxyList) #pragma unused(doxyList)
if (noisy) if (noisy)
cout << "Not Adding " << theCommand << endl; cout << "Not Adding " << theCommand << endl;
std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList);
tokList.setIterator(endOfParagraph); tokList.setIterator(endOfParagraph);
return 1; return 1;
} }
@ -454,10 +480,10 @@ int ignoreCommandParagraph(std::string theCommand, TokenList &tokList, std::list
* "verbatim", "xmlonly", "cond", "if", "ifnot", "link" * "verbatim", "xmlonly", "cond", "if", "ifnot", "link"
* Returns 1 if success, 0 if the endcommand is never encountered. * Returns 1 if success, 0 if the endcommand is never encountered.
*/ */
int addCommandEndCommand(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int addCommandEndCommand(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
if (noisy) if (noisy)
cout << "Not Adding " << theCommand << endl; cout << "Not Adding " << theCommand << endl;
std::string description = getStringTilEndCommand( "end" + theCommand, tokList); std::string description = getStringTilEndCommand("end" + theCommand, tokList);
doxyList.push_back(DoxygenEntity(theCommand, description)); doxyList.push_back(DoxygenEntity(theCommand, description));
return 1; return 1;
} }
@ -467,16 +493,16 @@ int addCommandEndCommand(std::string theCommand, TokenList &tokList, std::list <
* Commands such as param * Commands such as param
* "param", "tparam", "throw", "throws", "retval", "exception" * "param", "tparam", "throw", "throws", "retval", "exception"
*/ */
int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int addCommandWordParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (name.empty()){ if (name.empty()) {
cout << "No word followed " << theCommand << " command. Not added" << endl; cout << "No word followed " << theCommand << " command. Not added" << endl;
return 0; return 0;
} }
std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList);
std::list <DoxygenEntity> aNewList; std::list < DoxygenEntity > aNewList;
aNewList = parse(endOfParagraph, tokList); aNewList = parse(endOfParagraph, tokList);
aNewList.push_front(DoxygenEntity("plainstd::string", name)); aNewList.push_front(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
@ -488,15 +514,16 @@ int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::lis
* Commands such as param * Commands such as param
* "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup"
*/ */
int addCommandWordLine(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int addCommandWordLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy)
cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (name.empty()){ if (name.empty()) {
cout << "No word followed " << theCommand << " command. Not added" << endl; cout << "No word followed " << theCommand << " command. Not added" << endl;
return 0; return 0;
} }
std::list<Token>::iterator endOfLine = getOneLine(tokList); std::list < Token >::iterator endOfLine = getOneLine(tokList);
std::list <DoxygenEntity> aNewList; std::list < DoxygenEntity > aNewList;
aNewList = parse(endOfLine, tokList); aNewList = parse(endOfLine, tokList);
aNewList.push_front(DoxygenEntity("plainstd::string", name)); aNewList.push_front(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
@ -509,17 +536,17 @@ int addCommandWordLine(std::string theCommand, TokenList &tokList, std::list <Do
* Commands such as class * Commands such as class
* "category", "class", "protocol", "interface", "struct", "union" * "category", "class", "protocol", "interface", "struct", "union"
*/ */
int addCommandWordOWordOWord(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int addCommandWordOWordOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (name.empty()){ if (name.empty()) {
cout << "No word followed " << theCommand << " command. Not added" << endl; cout << "No word followed " << theCommand << " command. Not added" << endl;
return 0; return 0;
} }
std::string headerfile = getNextWord(tokList); std::string headerfile = getNextWord(tokList);
std::string headername = getNextWord(tokList); std::string headername = getNextWord(tokList);
std::list <DoxygenEntity> aNewList; std::list < DoxygenEntity > aNewList;
aNewList.push_back(DoxygenEntity("plainstd::string", name)); aNewList.push_back(DoxygenEntity("plainstd::string", name));
if (!headerfile.empty()) if (!headerfile.empty())
aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); aNewList.push_back(DoxygenEntity("plainstd::string", headerfile));
@ -534,7 +561,7 @@ int addCommandWordOWordOWord(std::string theCommand, TokenList &tokList, std::li
* Commands such as dir * Commands such as dir
* "dir", "file", "cond" * "dir", "file", "cond"
*/ */
int addCommandOWord(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int addCommandOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(tokList); std::string name = getNextWord(tokList);
@ -545,91 +572,91 @@ int addCommandOWord(std::string theCommand, TokenList &tokList, std::list <Doxyg
/* 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
*/ */
int addCommandErrorThrow(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
#pragma unused(doxyList) #pragma unused(doxyList)
if (noisy) { if (noisy) {
cout << "Encountered :" << theCommand << endl; cout << "Encountered :" << theCommand << endl;
cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl;
} }
std::list<Token>::iterator endOfLine = getOneLine(tokList); std::list < Token >::iterator endOfLine = getOneLine(tokList);
tokList.setIterator(endOfLine); tokList.setIterator(endOfLine);
return 0; return 0;
} }
/* Adds the unique commands- different process for each unique command */ /* Adds the unique commands- different process for each unique command */
int addCommandUnique(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){ int addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
std::list <DoxygenEntity> aNewList; std::list < DoxygenEntity > aNewList;
if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){ if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0) {
std::list<Token>::iterator endOfSection = getEndOfSection(theCommand, tokList); std::list < Token >::iterator endOfSection = getEndOfSection(theCommand, tokList);
std::list <DoxygenEntity> aNewList; std::list < DoxygenEntity > aNewList;
aNewList = parse(endOfSection, tokList); aNewList = parse(endOfSection, tokList);
doxyList.push_back( DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} }
// \xrefitem <key> "(heading)" "(std::list title)" {text} // \xrefitem <key> "(heading)" "(std::list title)" {text}
else if (theCommand.compare("xrefitem") == 0){ else if (theCommand.compare("xrefitem") == 0) {
//TODO Implement xrefitem //TODO Implement xrefitem
if (noisy) if (noisy)
cout << "Not Adding " << theCommand << endl; cout << "Not Adding " << theCommand << endl;
std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList);
tokList.setIterator(endOfParagraph); tokList.setIterator(endOfParagraph);
return 1; return 1;
} }
// \ingroup (<groupname> [<groupname> <groupname>]) // \ingroup (<groupname> [<groupname> <groupname>])
else if (theCommand.compare("ingroup") == 0){ else if (theCommand.compare("ingroup") == 0) {
std::string name = getNextWord(tokList); std::string name = getNextWord(tokList);
aNewList.push_back(DoxygenEntity("plainstd::string", name)); aNewList.push_back(DoxygenEntity("plainstd::string", name));
name = getNextWord(tokList); name = getNextWord(tokList);
if(!name.empty()) if (!name.empty())
aNewList.push_back(DoxygenEntity("plainstd::string", name)); aNewList.push_back(DoxygenEntity("plainstd::string", name));
name = getNextWord(tokList); name = getNextWord(tokList);
if(!name.empty()) if (!name.empty())
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));
return 1; return 1;
} }
// \par [(paragraph title)] { paragraph } // \par [(paragraph title)] { paragraph }
else if (theCommand.compare("par") == 0){ else if (theCommand.compare("par") == 0) {
std::list<Token>::iterator endOfLine = getOneLine(tokList); std::list < Token >::iterator endOfLine = getOneLine(tokList);
aNewList = parse(endOfLine, tokList); aNewList = parse(endOfLine, tokList);
std::list <DoxygenEntity> aNewList2; std::list < DoxygenEntity > aNewList2;
aNewList2 = parse(endOfLine, tokList); aNewList2 = parse(endOfLine, tokList);
aNewList.splice(aNewList.end(), aNewList2); aNewList.splice(aNewList.end(), aNewList2);
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1; return 1;
} }
// \headerfile <header-file> [<header-name>] // \headerfile <header-file> [<header-name>]
else if (theCommand.compare("headerfile") == 0){ else if (theCommand.compare("headerfile") == 0) {
std::list <DoxygenEntity> aNewList; std::list < DoxygenEntity > aNewList;
std::string name = getNextWord(tokList); std::string name = getNextWord(tokList);
aNewList.push_back(DoxygenEntity("plainstd::string", name)); aNewList.push_back(DoxygenEntity("plainstd::string", name));
name = getNextWord(tokList); name = getNextWord(tokList);
if(!name.empty()) if (!name.empty())
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));
return 1; return 1;
} }
// \overload [(function declaration)] // \overload [(function declaration)]
else if (theCommand.compare("overload") == 0){ else if (theCommand.compare("overload") == 0) {
std::list<Token>::iterator endOfLine = getOneLine(tokList); std::list < Token >::iterator endOfLine = getOneLine(tokList);
if (endOfLine != tokList.current()){ if (endOfLine != tokList.current()) {
std::list <DoxygenEntity> aNewList; std::list < DoxygenEntity > aNewList;
aNewList = parse(endOfLine, tokList); aNewList = parse(endOfLine, tokList);
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} } else
else
doxyList.push_back(DoxygenEntity(theCommand)); doxyList.push_back(DoxygenEntity(theCommand));
return 1; return 1;
} }
// \weakgroup <name> [(title)] // \weakgroup <name> [(title)]
else if (theCommand.compare("weakgroup") == 0){ else if (theCommand.compare("weakgroup") == 0) {
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy)
cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (name.empty()){ if (name.empty()) {
cout << "No word followed " << theCommand << " command. Not added" << endl; cout << "No word followed " << theCommand << " command. Not added" << endl;
return 0; return 0;
} }
std::list <DoxygenEntity> aNewList; std::list < DoxygenEntity > aNewList;
std::list<Token>::iterator endOfLine = getOneLine(tokList); std::list < Token >::iterator endOfLine = getOneLine(tokList);
if (endOfLine != tokList.current()) { if (endOfLine != tokList.current()) {
aNewList = parse(endOfLine, tokList); aNewList = parse(endOfLine, tokList);
} }
@ -637,44 +664,44 @@ int addCommandUnique(std::string theCommand, TokenList &tokList, std::list <Doxy
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} }
// \ref <name> ["(text)"] // \ref <name> ["(text)"]
else if (theCommand.compare("ref") == 0){ else if (theCommand.compare("ref") == 0) {
//TODO Implement ref //TODO Implement ref
if (noisy) if (noisy)
cout << "Not Adding " << theCommand << endl; cout << "Not Adding " << theCommand << endl;
std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList);
tokList.setIterator(endOfParagraph); tokList.setIterator(endOfParagraph);
} }
// \subpage <name> ["(text)"] // \subpage <name> ["(text)"]
else if (theCommand.compare("subpage") == 0){ else if (theCommand.compare("subpage") == 0) {
//TODO implement subpage //TODO implement subpage
if (noisy) if (noisy)
cout << "Not Adding " << theCommand << endl; cout << "Not Adding " << theCommand << endl;
std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList);
tokList.setIterator(endOfParagraph); tokList.setIterator(endOfParagraph);
} }
// \dotfile <file> ["caption"] // \dotfile <file> ["caption"]
else if (theCommand.compare("dotfile") == 0){ else if (theCommand.compare("dotfile") == 0) {
//TODO implement dotfile //TODO implement dotfile
if (noisy) if (noisy)
cout << "Not Adding " << theCommand << endl; cout << "Not Adding " << theCommand << endl;
std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList);
tokList.setIterator(endOfParagraph); tokList.setIterator(endOfParagraph);
} }
// \image <format> <file> ["caption"] [<sizeindication>=<size>] // \image <format> <file> ["caption"] [<sizeindication>=<size>]
else if (theCommand.compare("image") == 0){ else if (theCommand.compare("image") == 0) {
//todo implement image //todo implement image
} }
// \addtogroup <name> [(title)] // \addtogroup <name> [(title)]
else if (theCommand.compare("addtogroup") == 0){ else if (theCommand.compare("addtogroup") == 0) {
if (noisy) if (noisy)
cout << "Parsing " << theCommand << endl; cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (name.empty()){ if (name.empty()) {
cout << "No word followed " << theCommand << " command. Not added" << endl; cout << "No word followed " << theCommand << " command. Not added" << endl;
return 0; return 0;
} }
std::list <DoxygenEntity> aNewList; std::list < DoxygenEntity > aNewList;
std::list<Token>::iterator endOfLine = getOneLine(tokList); std::list < Token >::iterator endOfLine = getOneLine(tokList);
if (endOfLine != tokList.current()) { if (endOfLine != tokList.current()) {
aNewList = parse(endOfLine, tokList); aNewList = parse(endOfLine, tokList);
} }
@ -688,87 +715,86 @@ int addCommandUnique(std::string theCommand, TokenList &tokList, std::list <Doxy
* with my current design- however the skeletal outline is contained in * with my current design- however the skeletal outline is contained in
* the file Skeleton * the file Skeleton
*/ */
int addCommand(std::string commandString, TokenList &tokList,std::list <DoxygenEntity> &doxyList){ int addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
std::string theCommand = StringToLower(commandString); std::string theCommand = StringToLower(commandString);
if (theCommand.compare("plainstd::string") == 0){ if (theCommand.compare("plainstd::string") == 0) {
std::string nextPhrase = getStringTilCommand( tokList); std::string nextPhrase = getStringTilCommand(tokList);
if (noisy) cout << "Parsing plain std::string :" << nextPhrase << endl; if (noisy)
doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase )); cout << "Parsing plain std::string :" << nextPhrase << endl;
doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase));
return 1; return 1;
} }
int commandNumber = commandBelongs(theCommand); int commandNumber = commandBelongs(theCommand);
if (commandNumber == SIMPLECOMMAND){ if (commandNumber == SIMPLECOMMAND) {
return addSimpleCommand(theCommand, doxyList); return addSimpleCommand(theCommand, doxyList);
} }
if (commandNumber == IGNOREDSIMPLECOMMAND){ if (commandNumber == IGNOREDSIMPLECOMMAND) {
return ignoreSimpleCommand(theCommand, doxyList); return ignoreSimpleCommand(theCommand, doxyList);
} }
if (commandNumber == COMMANDWORD){ if (commandNumber == COMMANDWORD) {
return addCommandWord(theCommand, tokList, doxyList); return addCommandWord(theCommand, tokList, doxyList);
} }
if (commandNumber == IGNOREDCOMMANDWORD){ if (commandNumber == IGNOREDCOMMANDWORD) {
return ignoreCommandWord(theCommand, tokList, doxyList); return ignoreCommandWord(theCommand, tokList, doxyList);
} }
if (commandNumber == COMMANDLINE ){ if (commandNumber == COMMANDLINE) {
return addCommandLine(theCommand, tokList, doxyList); return addCommandLine(theCommand, tokList, doxyList);
} }
if (commandNumber == IGNOREDCOMMANDLINE ){ if (commandNumber == IGNOREDCOMMANDLINE) {
return ignoreCommandLine(theCommand, tokList, doxyList); return ignoreCommandLine(theCommand, tokList, doxyList);
} }
if (commandNumber == COMMANDPARAGRAPH){ if (commandNumber == COMMANDPARAGRAPH) {
return addCommandParagraph(theCommand, tokList, doxyList); return addCommandParagraph(theCommand, tokList, doxyList);
} }
if (commandNumber == IGNORECOMMANDPARAGRAPH){ if (commandNumber == IGNORECOMMANDPARAGRAPH) {
return ignoreCommandParagraph(theCommand, tokList, doxyList); return ignoreCommandParagraph(theCommand, tokList, doxyList);
} }
if (commandNumber == COMMANDENDCOMMAND){ if (commandNumber == COMMANDENDCOMMAND) {
return addCommandEndCommand(theCommand, tokList, doxyList); return addCommandEndCommand(theCommand, tokList, doxyList);
} }
if (commandNumber == COMMANDWORDPARAGRAPH){ if (commandNumber == COMMANDWORDPARAGRAPH) {
return addCommandWordParagraph(theCommand, tokList, doxyList); return addCommandWordParagraph(theCommand, tokList, doxyList);
} }
if (commandNumber == COMMANDWORDLINE){ if (commandNumber == COMMANDWORDLINE) {
return addCommandWordLine(theCommand, tokList, doxyList); return addCommandWordLine(theCommand, tokList, doxyList);
} }
if (commandNumber == COMMANDWORDOWORDWORD){ if (commandNumber == COMMANDWORDOWORDWORD) {
return addCommandWordOWordOWord(theCommand, tokList, doxyList); return addCommandWordOWordOWord(theCommand, tokList, doxyList);
} }
if (commandNumber == COMMANDOWORD){ if (commandNumber == COMMANDOWORD) {
return addCommandOWord(theCommand, tokList, doxyList); return addCommandOWord(theCommand, tokList, doxyList);
} }
if (commandNumber == COMMANDERRORTHROW){ if (commandNumber == COMMANDERRORTHROW) {
return addCommandErrorThrow(theCommand, tokList, doxyList); return addCommandErrorThrow(theCommand, tokList, doxyList);
} }
if (commandNumber == COMMANDUNIQUE){ if (commandNumber == COMMANDUNIQUE) {
return addCommandUnique(theCommand, tokList, doxyList); return addCommandUnique(theCommand, tokList, doxyList);
} }
return 0; return 0;
} }
std::list<DoxygenEntity> parse(std::list<Token>::iterator endParsingIndex, TokenList &tokList){ std::list < DoxygenEntity > parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList) {
std::list <DoxygenEntity> aNewList; std::list < DoxygenEntity > aNewList;
int currCommand; int currCommand;
while (tokList.current() != endParsingIndex){ while (tokList.current() != endParsingIndex) {
Token currToken = tokList.peek(); Token currToken = tokList.peek();
if(noisy) if (noisy)
cout << "Parsing for phrase starting in:" << currToken.toString() << endl; cout << "Parsing for phrase starting in:" << currToken.toString() << endl;
if(currToken.tokenType == END_LINE ){ if (currToken.tokenType == END_LINE) {
tokList.next(); tokList.next();
} } else if (currToken.tokenType == COMMAND) {
else if(currToken.tokenType == COMMAND){
currCommand = findCommand(currToken.tokenString); currCommand = findCommand(currToken.tokenString);
if (currCommand < 0 ){ if (currCommand < 0) {
if(noisy) if (noisy)
cout << "Unidentified Command " << currToken.tokenString << endl; cout << "Unidentified Command " << currToken.tokenString << endl;
tokList.next(); tokList.next();
addCommand(std::string("plainstd::string"), tokList, aNewList); addCommand(std::string("plainstd::string"), tokList, aNewList);
} } else {
else { tokList.next(); tokList.next();
addCommand(currToken.tokenString, tokList, aNewList); addCommand(currToken.tokenString, tokList, aNewList);
} }
} } else if (currToken.tokenType == PLAINSTRING) {
else if (currToken.tokenType == PLAINSTRING){
addCommand(std::string("plainstd::string"), tokList, aNewList); addCommand(std::string("plainstd::string"), tokList, aNewList);
} }
break; break;
@ -776,25 +802,24 @@ std::list<DoxygenEntity> parse(std::list<Token>::iterator endParsingIndex, Token
return aNewList; return aNewList;
} }
std::list<DoxygenEntity> parseRoot(std::list<Token>::iterator endParsingIndex, TokenList &tokList){ std::list < DoxygenEntity > parseRoot(std::list < Token >::iterator endParsingIndex, TokenList & tokList) {
std::list <DoxygenEntity> aNewList; std::list < DoxygenEntity > aNewList;
int currCommand; int currCommand;
while (tokList.current() != endParsingIndex){ while (tokList.current() != endParsingIndex) {
Token currToken = tokList.peek(); Token currToken = tokList.peek();
if(noisy) { if (noisy) {
cout << "Parsing for phrase starting in:" << currToken.toString() << endl; cout << "Parsing for phrase starting in:" << currToken.toString() << endl;
} }
if(currToken.tokenType == END_LINE ){ if (currToken.tokenType == END_LINE) {
tokList.next(); tokList.next();
} } else if (currToken.tokenType == COMMAND) {
else if(currToken.tokenType == COMMAND){
currCommand = findCommand(currToken.tokenString); currCommand = findCommand(currToken.tokenString);
if (currCommand < 0 ){ if (currCommand < 0) {
if(noisy) { if (noisy) {
cout << "Unidentified Command " << currToken.tokenString << endl; cout << "Unidentified Command " << currToken.tokenString << endl;
} }
tokList.next(); tokList.next();
@ -803,23 +828,22 @@ std::list<DoxygenEntity> parseRoot(std::list<Token>::iterator endParsingIndex, T
tokList.next(); tokList.next();
addCommand(currToken.tokenString, tokList, aNewList); addCommand(currToken.tokenString, tokList, aNewList);
} }
} } else if (currToken.tokenType == PLAINSTRING) {
else if (currToken.tokenType == PLAINSTRING){
addCommand(std::string("partofdescription"), tokList, aNewList); addCommand(std::string("partofdescription"), tokList, aNewList);
} }
} }
return aNewList; return aNewList;
} }
std::list<DoxygenEntity> DoxygenParser::createTree(std::string doxygenBlob){ std::list < DoxygenEntity > DoxygenParser::createTree(std::string doxygenBlob) {
TokenList tokList = TokenList(doxygenBlob); TokenList tokList = TokenList(doxygenBlob);
if(noisy) { if (noisy) {
cout << "---TOKEN LIST---" << endl; cout << "---TOKEN LIST---" << endl;
tokList.printList(); tokList.printList();
} }
std::list <DoxygenEntity> rootList; std::list < DoxygenEntity > rootList;
rootList = parseRoot( tokList.end(), tokList); rootList = parseRoot(tokList.end(), tokList);
if(noisy) { if (noisy) {
cout << "PARSED LIST" << endl; cout << "PARSED LIST" << endl;
printTree(rootList); printTree(rootList);
} }

View file

@ -3,12 +3,11 @@
#include <string> #include <string>
#include <list> #include <list>
#include "DoxygenEntity.h" #include "DoxygenEntity.h"
class DoxygenParser class DoxygenParser {
{
public: public:
DoxygenParser(); DoxygenParser();
virtual ~DoxygenParser(); virtual ~DoxygenParser();
std::list <DoxygenEntity> createTree(std::string doxygen); std::list < DoxygenEntity > createTree(std::string doxygen);
}; };
#endif /*DOXYGENPARSER_H_*/ #endif

View file

@ -12,8 +12,8 @@
#include "JavaDocConverter.h" #include "JavaDocConverter.h"
#include "PyDocConverter.h" #include "PyDocConverter.h"
bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format, String *&documentation){ bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format, String *&documentation) {
switch(format){ switch (format) {
case JavaDoc: case JavaDoc:
return JavaDocConverter().getDocumentation(node, documentation); return JavaDocConverter().getDocumentation(node, documentation);
case PyDoc: case PyDoc:
@ -23,9 +23,9 @@ bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format,
} }
} }
void DoxygenTranslator::printTree(std::list<DoxygenEntity> &entityList){ void DoxygenTranslator::printTree(std::list < DoxygenEntity > &entityList) {
std::list<DoxygenEntity>::iterator p = entityList.begin(); std::list < DoxygenEntity >::iterator p = entityList.begin();
while (p != entityList.end()){ while (p != entityList.end()) {
(*p).printEntity(0); (*p).printEntity(0);
p++; p++;
} }

View file

@ -28,14 +28,13 @@ enum DocumentationFormat {
* A class to translate doxygen comments attacted to parser nodes * A class to translate doxygen comments attacted to parser nodes
* into alternative formats for use in code generated for target languages. * into alternative formats for use in code generated for target languages.
*/ */
class DoxygenTranslator class DoxygenTranslator {
{
public: public:
/* /*
* Virtual destructor. * Virtual destructor.
*/ */
virtual ~DoxygenTranslator(){} virtual ~ DoxygenTranslator() {
}
/* /*
* Return the documentation for a given node formated for the correct * Return the documentation for a given node formated for the correct
* documentation system. * documentation system.
@ -59,7 +58,7 @@ protected:
/* /*
* Prints the details of a parsed entity list to stdout (for debugging). * Prints the details of a parsed entity list to stdout (for debugging).
*/ */
void printTree(std::list<DoxygenEntity> &entityList); void printTree(std::list < DoxygenEntity > &entityList);
}; };
#endif /*DOXYGENTRANSLATOR_H_*/ #endif

View file

@ -1,11 +1,10 @@
#ifndef DOXYGENTRANSWTOKENIZER_H_ #ifndef DOXYGENTRANSWTOKENIZER_H_
#define DOXYGENTRANSWTOKENIZER_H_ #define DOXYGENTRANSWTOKENIZER_H_
class DoxygenTransWTokenizer class DoxygenTransWTokenizer {
{
public: public:
DoxygenTransWTokenizer(); DoxygenTransWTokenizer();
virtual ~DoxygenTransWTokenizer(); virtual ~DoxygenTransWTokenizer();
}; };
#endif /*DOXYGENTRANSWTOKENIZER_H_*/ #endif

View file

@ -57,7 +57,7 @@
#define FRIGHTBRACKET 152 /* \f} */ #define FRIGHTBRACKET 152 /* \f} */
#define FILE_COMMAND 153 /* \file */ #define FILE_COMMAND 153 /* \file */
#define FN_COMMAND 154 /* \fn */ #define FN_COMMAND 154 /* \fn */
#define HEADERFILE 155/* \headerfile */ #define HEADERFILE 155 /* \headerfile */
#define HIDEINITIALIZER 156 /* \hideinitializer */ #define HIDEINITIALIZER 156 /* \hideinitializer */
#define HTMLINCLUDE 157 /* \htmlinclude */ #define HTMLINCLUDE 157 /* \htmlinclude */
#define HTMLONLY 158 /* \htmlonly */ #define HTMLONLY 158 /* \htmlonly */
@ -129,7 +129,7 @@
#define VERSION 224 /* \version */ #define VERSION 224 /* \version */
#define WARNING 225 /* \warning */ #define WARNING 225 /* \warning */
#define WEAKGROUP 226 /* \weakgroup */ #define WEAKGROUP 226 /* \weakgroup */
#define XMLONLY 227/* \xmlonly */ #define XMLONLY 227 /* \xmlonly */
#define XREFITEM 228 /* \xrefitem */ #define XREFITEM 228 /* \xrefitem */
#define DOLLAR_COMMAND 229 /* \$ */ #define DOLLAR_COMMAND 229 /* \$ */
#define AT_COMMAND 230 /* \@ */ #define AT_COMMAND 230 /* \@ */
@ -141,4 +141,4 @@
#define POUND_COMMAND 236 /* \# */ #define POUND_COMMAND 236 /* \# */
#define PERCENT_COMMAND 237 /* \% */ #define PERCENT_COMMAND 237 /* \% */
#endif /*TRANSLATOR_H_*/ #endif

View file

@ -1,28 +1,29 @@
#include "JavaDocConverter.h" #include "JavaDocConverter.h"
#include "DoxygenParser.h" #include "DoxygenParser.h"
#include <iostream> #include <iostream>
#define APPROX_LINE_LENGTH 64//characters per line allowed #define APPROX_LINE_LENGTH 64 //characters per line allowed
#define TAB_SIZE 8//characters per line allowed #define TAB_SIZE 8 //characters per line allowed
int printSortedTree2 = 0; int printSortedTree2 = 0;
//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag
std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent){ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent) {
std::string formattedLines = "\n * "; std::string formattedLines = "\n * ";
int lastPosition = 0; int lastPosition = 0;
int i = 0; int i = 0;
int isFirstLine = 1; int isFirstLine = 1;
while (i != -1 && i < (int)unformattedLine.length()){ while (i != -1 && i < (int) unformattedLine.length()) {
lastPosition = i; lastPosition = i;
if (isFirstLine){ if (isFirstLine) {
i+=APPROX_LINE_LENGTH; i += APPROX_LINE_LENGTH;
} else { } else {
i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; i += APPROX_LINE_LENGTH - indent * TAB_SIZE;
} }
i = unformattedLine.find(" ", i); i = unformattedLine.find(" ", i);
if (i > 0 && i + 1 < (int)unformattedLine.length()){ if (i > 0 && i + 1 < (int) unformattedLine.length()) {
if (!isFirstLine) for (int j = 0; j < indent; j++) { if (!isFirstLine)
for (int j = 0; j < indent; j++) {
formattedLines.append("\t"); formattedLines.append("\t");
} else { } else {
isFirstLine = 0; isFirstLine = 0;
@ -32,7 +33,7 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind
} }
} }
if (lastPosition < (int)unformattedLine.length()){ if (lastPosition < (int) unformattedLine.length()) {
if (!isFirstLine) { if (!isFirstLine) {
for (int j = 0; j < indent; j++) { for (int j = 0; j < indent; j++) {
formattedLines.append("\t"); formattedLines.append("\t");
@ -47,57 +48,47 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind
/* Contains the conversions for tags /* Contains the conversions for tags
* could probably be much more efficient... * could probably be much more efficient...
*/ */
std::string JavaDocConverter::javaDocFormat(DoxygenEntity &doxygenEntity){ std::string JavaDocConverter::javaDocFormat(DoxygenEntity & doxygenEntity) {
if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ if (doxygenEntity.typeOfEntity.compare("partofdescription") == 0) {
return doxygenEntity.data; return doxygenEntity.data;
} }
if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0){ if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0) {
return doxygenEntity.data; return doxygenEntity.data;
} } else if (doxygenEntity.typeOfEntity.compare("b") == 0) {
else if (doxygenEntity.typeOfEntity.compare("b") == 0){
return "<b>" + doxygenEntity.data + "</b>"; return "<b>" + doxygenEntity.data + "</b>";
} } else if (doxygenEntity.typeOfEntity.compare("c") == 0) {
else if (doxygenEntity.typeOfEntity.compare("c") == 0){
return "<tt>" + doxygenEntity.data + "</tt>"; return "<tt>" + doxygenEntity.data + "</tt>";
} } else if (doxygenEntity.typeOfEntity.compare("@") == 0) {
else if (doxygenEntity.typeOfEntity.compare("@") == 0){
return "@"; return "@";
} } else if (doxygenEntity.typeOfEntity.compare("\\") == 0) {
else if (doxygenEntity.typeOfEntity.compare("\\") == 0){
return "\\"; return "\\";
} } else if (doxygenEntity.typeOfEntity.compare("<") == 0) {
else if (doxygenEntity.typeOfEntity.compare("<") == 0){
return "&lt;"; return "&lt;";
} } else if (doxygenEntity.typeOfEntity.compare(">") == 0) {
else if (doxygenEntity.typeOfEntity.compare(">") == 0){
return "&gt;"; return "&gt;";
} } else if (doxygenEntity.typeOfEntity.compare("&") == 0) {
else if (doxygenEntity.typeOfEntity.compare("&") == 0){
return "&amp;"; return "&amp;";
} } else if (doxygenEntity.typeOfEntity.compare("#") == 0) {
else if (doxygenEntity.typeOfEntity.compare("#") == 0){
return "#"; return "#";
} } else if (doxygenEntity.typeOfEntity.compare("%") == 0) {
else if (doxygenEntity.typeOfEntity.compare("%") == 0){
return "%"; return "%";
} } else if (doxygenEntity.typeOfEntity.compare("~") == 0) {
else if (doxygenEntity.typeOfEntity.compare("~") == 0){
return "~"; return "~";
} }
return ""; return "";
} }
std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ std::string JavaDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) {
std::string returnedString; std::string returnedString;
if (doxygenEntity.isLeaf) { if (doxygenEntity.isLeaf) {
return javaDocFormat(doxygenEntity) + " "; return javaDocFormat(doxygenEntity) + " ";
} else { } else {
returnedString += javaDocFormat(doxygenEntity); returnedString += javaDocFormat(doxygenEntity);
std::list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin(); std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin();
while (p != doxygenEntity.entityList.end()){ while (p != doxygenEntity.entityList.end()) {
returnedString+= translateSubtree(*p); returnedString += translateSubtree(*p);
p++; p++;
} }
} }
@ -105,45 +96,43 @@ std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){
} }
std::string JavaDocConverter::translateEntity(DoxygenEntity &doxyEntity){ std::string JavaDocConverter::translateEntity(DoxygenEntity & doxyEntity) {
if (doxyEntity.typeOfEntity.compare("partofdescription") == 0) { if (doxyEntity.typeOfEntity.compare("partofdescription") == 0) {
return formatCommand(std::string(translateSubtree(doxyEntity)), 0); return formatCommand(std::string(translateSubtree(doxyEntity)), 0);
} }
if ((doxyEntity.typeOfEntity.compare("brief") == 0) || if ((doxyEntity.typeOfEntity.compare("brief") == 0) || (doxyEntity.typeOfEntity.compare("details") == 0)) {
(doxyEntity.typeOfEntity.compare("details") == 0)) {
return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * "; return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";
} else if(doxyEntity.typeOfEntity.compare("plainstd::string")== 0 || } else if (doxyEntity.typeOfEntity.compare("plainstd::string") == 0 ||
doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("deprecated") == 0 ||
doxyEntity.typeOfEntity.compare("brief")== 0) { doxyEntity.typeOfEntity.compare("brief") == 0) {
return formatCommand(doxyEntity.data, 0) + "\n * "; return formatCommand(doxyEntity.data, 0) + "\n * ";
} else if(doxyEntity.typeOfEntity.compare("see") == 0) { } else if (doxyEntity.typeOfEntity.compare("see") == 0) {
return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2);
translateSubtree(doxyEntity)), 2);
} else if(doxyEntity.typeOfEntity.compare("return")== 0 } else if (doxyEntity.typeOfEntity.compare("return") == 0
|| doxyEntity.typeOfEntity.compare("author")== 0 || doxyEntity.typeOfEntity.compare("author") == 0
|| doxyEntity.typeOfEntity.compare("param")== 0 || doxyEntity.typeOfEntity.compare("param") == 0
|| doxyEntity.typeOfEntity.compare("throw")== 0 || doxyEntity.typeOfEntity.compare("throw") == 0
|| doxyEntity.typeOfEntity.compare("throws")== 0 || doxyEntity.typeOfEntity.compare("throws") == 0
|| doxyEntity.typeOfEntity.compare("since")== 0 || doxyEntity.typeOfEntity.compare("since") == 0
|| doxyEntity.typeOfEntity.compare("version")== 0 || doxyEntity.typeOfEntity.compare("version") == 0
|| doxyEntity.typeOfEntity.compare("exception") == 0 || doxyEntity.typeOfEntity.compare("exception") == 0
|| doxyEntity.typeOfEntity.compare("deprecated") == 0){ || doxyEntity.typeOfEntity.compare("deprecated") == 0) {
// this 'if' is a hack - convert doxyEntity.typeOfEntity at the time of parsing // this 'if' is a hack - convert doxyEntity.typeOfEntity at the time of parsing
if (doxyEntity.typeOfEntity.compare("throw")== 0) { if (doxyEntity.typeOfEntity.compare("throw") == 0) {
doxyEntity.typeOfEntity = "throws"; doxyEntity.typeOfEntity = "throws";
} }
return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2);
} else if(doxyEntity.typeOfEntity.compare("sa")== 0) { } else if (doxyEntity.typeOfEntity.compare("sa") == 0) {
return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2); return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2);
} else { } else {
return formatCommand(javaDocFormat(doxyEntity), 0 ); return formatCommand(javaDocFormat(doxyEntity), 0);
} }
return ""; return "";
@ -158,26 +147,26 @@ bool JavaDocConverter::getDocumentation(Node *node, String *&documentation) {
return false; return false;
} }
std::list <DoxygenEntity> entityList = DoxygenParser().createTree(Char(documentation)); std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation));
// entityList.sort(CompareDoxygenEntities()); sorting currently not used, // entityList.sort(CompareDoxygenEntities()); sorting currently not used,
// see CompareDoxygenEntities::operator() in DoxygenEntity.cpp // see CompareDoxygenEntities::operator() in DoxygenEntity.cpp
if(debug){ if (debug) {
std::cout << "---RESORTED LIST---" << std::endl; std::cout << "---RESORTED LIST---" << std::endl;
printTree(entityList); printTree(entityList);
} }
std::string javaDocString = "/**"; std::string javaDocString = "/**";
for(std::list<DoxygenEntity>::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){ for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) {
javaDocString += translateEntity(*entityIterator); javaDocString += translateEntity(*entityIterator);
entityIterator++; entityIterator++;
} }
javaDocString += "\n */\n"; javaDocString += "\n */\n";
if(debug){ if (debug) {
std::cout << "\n---RESULT IN JAVADOC---" << std::endl; std::cout << "\n---RESULT IN JAVADOC---" << std::endl;
std::cout << javaDocString; std::cout << javaDocString;
} }

View file

@ -15,20 +15,20 @@
/* /*
* A class to translate doxygen comments into JavaDoc style comments. * A class to translate doxygen comments into JavaDoc style comments.
*/ */
class JavaDocConverter : public DoxygenTranslator class JavaDocConverter : public DoxygenTranslator {
{
public: public:
JavaDocConverter() : debug( false ){} JavaDocConverter() : debug(false) {
}
virtual bool getDocumentation(Node *node, String *&documentation); virtual bool getDocumentation(Node *node, String *&documentation);
protected: protected:
std::string formatCommand(std::string unformattedLine, int indent); std::string formatCommand(std::string unformattedLine, int indent);
std::string translateEntity(DoxygenEntity &doxyEntity); std::string translateEntity(DoxygenEntity & doxyEntity);
std::string javaDocFormat(DoxygenEntity &doxygenEntity); std::string javaDocFormat(DoxygenEntity & doxygenEntity);
std::string translateSubtree( DoxygenEntity &doxygenEntity); std::string translateSubtree(DoxygenEntity & doxygenEntity);
private: private:
bool debug; bool debug;
}; };
#endif /*JAVADOCCONVERTER_H_*/ #endif

View file

@ -14,22 +14,22 @@
#include <iostream> #include <iostream>
//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag
PyDocConverter::PyDocConverter(){ PyDocConverter::PyDocConverter() {
debug = 1; debug = 1;
} }
std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) {
ParmList *plist = CopyParmList(Getattr(n, "parms")); ParmList *plist = CopyParmList(Getattr(n, "parms"));
Parm *p = NULL; Parm *p = NULL;
DoxygenEntity& paramNameEntity = *doxygenEntity.entityList.begin(); DoxygenEntity & paramNameEntity = *doxygenEntity.entityList.begin();
DoxygenEntity& paramDescriptionEntity = *(++doxygenEntity.entityList.begin()); DoxygenEntity & paramDescriptionEntity = *(++doxygenEntity.entityList.begin());
std::string result; std::string result;
std::string paramDescription = justifyString(paramDescriptionEntity.data, DOC_PARAM_STRING_LENGTH); std::string paramDescription = justifyString(paramDescriptionEntity.data, DOC_PARAM_STRING_LENGTH);
for (p = plist; p;) { for (p = plist; p;) {
if(Char(Getattr(p, "name")) == paramNameEntity.data) { if (Char(Getattr(p, "name")) == paramNameEntity.data) {
std::string name = Char(Swig_name_make(n, 0, Getattr(p, "name"), 0, 0)); std::string name = Char(Swig_name_make(n, 0, Getattr(p, "name"), 0, 0));
std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0)); std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0));
@ -45,24 +45,22 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) {
return result; return result;
} }
std::string PyDocConverter::formatReturnDescription(Node *node, DoxygenEntity &doxygenEntity){ std::string PyDocConverter::formatReturnDescription(Node *node, DoxygenEntity & doxygenEntity) {
#pragma unused(node) #pragma unused(node)
return "\nResult:\n" + justifyString(translateSubtree(doxygenEntity)); return "\nResult:\n" + justifyString(translateSubtree(doxygenEntity));
} }
std::string PyDocConverter::justifyString(std::string documentString, int indent, int maxWidth){ std::string PyDocConverter::justifyString(std::string documentString, int indent, int maxWidth) {
std::ostringstream formattedString; std::ostringstream formattedString;
std::string currentLine; std::string currentLine;
for(std::string::iterator stringPosition = documentString.begin(); stringPosition != documentString.end(); ++stringPosition) for (std::string::iterator stringPosition = documentString.begin(); stringPosition != documentString.end(); ++stringPosition) {
{ if (currentLine.length() == 0)
if(currentLine.length() == 0)
currentLine.resize(indent, ' '); currentLine.resize(indent, ' ');
currentLine += *stringPosition; currentLine += *stringPosition;
if(*stringPosition == ' ' && (int)currentLine.size() >= maxWidth || (stringPosition + 1) == documentString.end()) if (*stringPosition == ' ' && (int) currentLine.size() >= maxWidth || (stringPosition + 1) == documentString.end()) {
{
formattedString << currentLine << std::endl; formattedString << currentLine << std::endl;
currentLine = ""; currentLine = "";
} }
@ -71,41 +69,41 @@ std::string PyDocConverter::justifyString(std::string documentString, int indent
return formattedString.str(); return formattedString.str();
} }
std::string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) {
std::string returnedString; std::string returnedString;
if (doxygenEntity.isLeaf) if (doxygenEntity.isLeaf)
return doxygenEntity.data + " "; return doxygenEntity.data + " ";
else { else {
returnedString += doxygenEntity.data; returnedString += doxygenEntity.data;
std::list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin(); std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin();
while (p != doxygenEntity.entityList.end()){ while (p != doxygenEntity.entityList.end()) {
returnedString+= translateSubtree(*p); returnedString += translateSubtree(*p);
p++; p++;
} }
} }
return returnedString; return returnedString;
} }
std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity & doxyEntity) {
if(doxyEntity.typeOfEntity.compare("partofdescription") == 0) if (doxyEntity.typeOfEntity.compare("partofdescription") == 0)
return justifyString(std::string(translateSubtree(doxyEntity)), 0); return justifyString(std::string(translateSubtree(doxyEntity)), 0);
if ((doxyEntity.typeOfEntity.compare("brief") == 0) if ((doxyEntity.typeOfEntity.compare("brief") == 0)
||(doxyEntity.typeOfEntity.compare("details") == 0)) || (doxyEntity.typeOfEntity.compare("details") == 0))
return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n"; return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n";
if(doxyEntity.typeOfEntity.compare("plainstd::string") == 0 if (doxyEntity.typeOfEntity.compare("plainstd::string") == 0
|| doxyEntity.typeOfEntity.compare("deprecated") == 0 || doxyEntity.typeOfEntity.compare("deprecated") == 0
|| doxyEntity.typeOfEntity.compare("brief") == 0) || doxyEntity.typeOfEntity.compare("brief") == 0)
return justifyString(doxyEntity.data, 0) + "\n"; return justifyString(doxyEntity.data, 0) + "\n";
if(doxyEntity.typeOfEntity.compare("param") == 0) if (doxyEntity.typeOfEntity.compare("param") == 0)
return formatParam(n, doxyEntity); return formatParam(n, doxyEntity);
if(doxyEntity.typeOfEntity.compare("return") == 0) if (doxyEntity.typeOfEntity.compare("return") == 0)
return formatReturnDescription(n, doxyEntity); return formatReturnDescription(n, doxyEntity);
if(doxyEntity.typeOfEntity.compare("author") == 0 if (doxyEntity.typeOfEntity.compare("author") == 0
|| doxyEntity.typeOfEntity.compare("param") == 0 || doxyEntity.typeOfEntity.compare("param") == 0
|| doxyEntity.typeOfEntity.compare("since") == 0 || doxyEntity.typeOfEntity.compare("since") == 0
|| doxyEntity.typeOfEntity.compare("version") == 0 || doxyEntity.typeOfEntity.compare("version") == 0
@ -117,16 +115,15 @@ std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){
return justifyString(doxyEntity.data); return justifyString(doxyEntity.data);
} }
std::string PyDocConverter::processEntityList(Node *n, std::list<DoxygenEntity>& entityList){ std::string PyDocConverter::processEntityList(Node *n, std::list < DoxygenEntity > &entityList) {
std::string result; std::string result;
bool inParamsSection = false; bool inParamsSection = false;
for(std::list<DoxygenEntity>::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){ for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) {
if(entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection){ if (entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection) {
inParamsSection = true; inParamsSection = true;
result += "\nArguments:\n"; result += "\nArguments:\n";
} } else if (entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection)
else if(entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection)
inParamsSection = false; inParamsSection = false;
result += translateEntity(n, *entityIterator); result += translateEntity(n, *entityIterator);
@ -136,56 +133,55 @@ std::string PyDocConverter::processEntityList(Node *n, std::list<DoxygenEntity>&
return result; return result;
} }
bool PyDocConverter::getDocumentation(Node *n, String *&documentation){ bool PyDocConverter::getDocumentation(Node *n, String *&documentation) {
std::string pyDocString, result; std::string pyDocString, result;
// for overloaded functions we must concat documentation for underlying overloads // for overloaded functions we must concat documentation for underlying overloads
if(Checkattr(n, "kind", "function") && Getattr(n, "sym:overloaded")){ if (Checkattr(n, "kind", "function") && Getattr(n, "sym:overloaded")) {
// rewind to the first overload // rewind to the first overload
while (Getattr(n, "sym:previousSibling")) while (Getattr(n, "sym:previousSibling"))
n = Getattr(n, "sym:previousSibling"); n = Getattr(n, "sym:previousSibling");
std::vector<std::string> allDocumentation; std::vector < std::string > allDocumentation;
// for each real method (not a generated overload) append the documentation // for each real method (not a generated overload) append the documentation
while(n){ while (n) {
documentation = Getattr(n,"DoxygenComment"); documentation = Getattr(n, "DoxygenComment");
if(!Swig_is_generated_overload(n) && documentation){ if (!Swig_is_generated_overload(n) && documentation) {
std::list<DoxygenEntity> entityList = DoxygenParser().createTree(Char(documentation)); std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation));
allDocumentation.push_back(processEntityList(n, entityList)); allDocumentation.push_back(processEntityList(n, entityList));
} }
n = Getattr(n, "sym:nextSibling"); n = Getattr(n, "sym:nextSibling");
} }
// construct final documentation string // construct final documentation string
if(allDocumentation.size() > 1){ if (allDocumentation.size() > 1) {
std::ostringstream concatDocString; std::ostringstream concatDocString;
for(int realOverloadCount = 0; realOverloadCount < (int)allDocumentation.size(); realOverloadCount++){ for (int realOverloadCount = 0; realOverloadCount < (int) allDocumentation.size(); realOverloadCount++) {
concatDocString << generateDivider(); concatDocString << generateDivider();
concatDocString << "Overload " << (realOverloadCount + 1) << ":" << std::endl; concatDocString << "Overload " << (realOverloadCount + 1) << ":" << std::endl;
concatDocString << generateDivider(); concatDocString << generateDivider();
concatDocString << allDocumentation[realOverloadCount] << std::endl; concatDocString << allDocumentation[realOverloadCount] << std::endl;
} }
pyDocString = concatDocString.str(); pyDocString = concatDocString.str();
} } else if (allDocumentation.size() == 1) {
else if (allDocumentation.size() == 1) {
pyDocString = *(allDocumentation.begin()); pyDocString = *(allDocumentation.begin());
} }
} }
// for other nodes just process as normal // for other nodes just process as normal
else { else {
documentation = Getattr(n,"DoxygenComment"); documentation = Getattr(n, "DoxygenComment");
if(documentation != NULL){ if (documentation != NULL) {
std::list<DoxygenEntity> entityList = DoxygenParser().createTree(Char(documentation)); std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation));
pyDocString = processEntityList(n, entityList); pyDocString = processEntityList(n, entityList);
} }
} }
// if we got something log the result and construct DOH string to return // if we got something log the result and construct DOH string to return
if(pyDocString.length()) { if (pyDocString.length()) {
result = "\"\"\"\n" + pyDocString + "\"\"\"\n"; result = "\"\"\"\n" + pyDocString + "\"\"\"\n";
if(debug){ if (debug) {
std::cout << "\n---RESULT IN PYDOC---" << std::endl; std::cout << "\n---RESULT IN PYDOC---" << std::endl;
std::cout << result; std::cout << result;
std::cout << std::endl; std::cout << std::endl;
@ -198,9 +194,9 @@ bool PyDocConverter::getDocumentation(Node *n, String *&documentation){
return false; return false;
} }
std::string PyDocConverter::generateDivider(){ std::string PyDocConverter::generateDivider() {
std::ostringstream dividerString; std::ostringstream dividerString;
for(int i = 0; i < DOC_STRING_LENGTH; i++) for (int i = 0; i < DOC_STRING_LENGTH; i++)
dividerString << '-'; dividerString << '-';
dividerString << std::endl; dividerString << std::endl;
return dividerString.str(); return dividerString.str();

View file

@ -19,8 +19,7 @@
#define DOC_STRING_LENGTH 64 // characters per line allowed #define DOC_STRING_LENGTH 64 // characters per line allowed
#define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type #define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type
class PyDocConverter : public DoxygenTranslator class PyDocConverter : public DoxygenTranslator {
{
public: public:
PyDocConverter(); PyDocConverter();
bool getDocumentation(Node *node, String *&documentation); bool getDocumentation(Node *node, String *&documentation);
@ -32,21 +31,21 @@ protected:
* @param node The parse tree node that the entity list relates to. * @param node The parse tree node that the entity list relates to.
* @param entityList The entity list to process * @param entityList The entity list to process
*/ */
std::string processEntityList(Node *node, std::list<DoxygenEntity>& entityList); std::string processEntityList(Node *node, std::list < DoxygenEntity > &entityList);
/* /*
* Format the doxygen comment relating to a function or method parameter * Format the doxygen comment relating to a function or method parameter
* @param node The parse tree node that the parameter relates to. * @param node The parse tree node that the parameter relates to.
* @param doxygenEntity The doxygen entity relating to the parameter docstring. * @param doxygenEntity The doxygen entity relating to the parameter docstring.
*/ */
std::string formatParam(Node *node, DoxygenEntity &doxygenEntity); std::string formatParam(Node *node, DoxygenEntity & doxygenEntity);
/* /*
* Format the doxygen comment relating to the return value for a method or function. * Format the doxygen comment relating to the return value for a method or function.
* @param node The parse tree node that the parameter relates to. * @param node The parse tree node that the parameter relates to.
* @param doxygenEntity The doxygen entity relating to the parameter docstring. * @param doxygenEntity The doxygen entity relating to the parameter docstring.
*/ */
std::string formatReturnDescription(Node *node, DoxygenEntity &doxygenEntity); std::string formatReturnDescription(Node *node, DoxygenEntity & doxygenEntity);
/* /*
* Format a string so it is justified and split over several lines * Format a string so it is justified and split over several lines
@ -57,8 +56,8 @@ protected:
*/ */
std::string justifyString(std::string unformattedLine, int indent = 0, int maxWidth = DOC_STRING_LENGTH); std::string justifyString(std::string unformattedLine, int indent = 0, int maxWidth = DOC_STRING_LENGTH);
std::string translateSubtree( DoxygenEntity &doxygenEntity); std::string translateSubtree(DoxygenEntity & doxygenEntity);
std::string translateEntity(Node *n, DoxygenEntity &doxyEntity); std::string translateEntity(Node *n, DoxygenEntity & doxyEntity);
/* /*
* Utility method to generate a diving line for a documentation string. * Utility method to generate a diving line for a documentation string.
@ -69,4 +68,4 @@ private:
bool debug; bool debug;
}; };
#endif /*PYDOCCONVERTER_H_*/ #endif

View file

@ -3,27 +3,26 @@
using namespace std; using namespace std;
Token::Token(int tType, string tString) Token::Token(int tType, string tString) {
{
tokenType = tType; tokenType = tType;
tokenString = tString; tokenString = tString;
} }
string Token::toString() string Token::toString() {
{ if (tokenType == END_LINE) {
if (tokenType == END_LINE){
return "{END OF LINE}"; return "{END OF LINE}";
} }
if (tokenType == PARAGRAPH_END){ if (tokenType == PARAGRAPH_END) {
return "{END OF PARAGRAPH}"; return "{END OF PARAGRAPH}";
} }
if (tokenType == PLAINSTRING){ if (tokenType == PLAINSTRING) {
return "{PLAINSTRING :" + tokenString + "}"; return "{PLAINSTRING :" + tokenString + "}";
} }
if (tokenType == COMMAND){ if (tokenType == COMMAND) {
return "{COMMAND : " + tokenString+ "}"; return "{COMMAND : " + tokenString + "}";
} }
return ""; return "";
} }
Token:: ~Token(){} Token::~Token() {
}

View file

@ -4,15 +4,14 @@
using namespace std; using namespace std;
class Token class Token {
{
public: public:
Token(int tType, string tString); Token(int tType, string tString);
~Token(); ~Token();
int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */ int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */
string tokenString; /* the data , such as param for @param*/ string tokenString; /* the data , such as param for @param */
string toString(); string toString();
}; };
#endif /*TOKEN_H_*/ #endif

View file

@ -11,7 +11,7 @@ using namespace std;
int noisy2 = 0; int noisy2 = 0;
/* The tokenizer*/ /* The tokenizer*/
TokenList::TokenList(const std::string &doxygenStringConst){ TokenList::TokenList(const std::string & doxygenStringConst) {
size_t commentPos; size_t commentPos;
string doxygenString = doxygenStringConst; string doxygenString = doxygenStringConst;
@ -39,65 +39,62 @@ TokenList::TokenList(const std::string &doxygenStringConst){
continue; continue;
} }
break; break;
} while (true); */ } while (true);
*/
size_t currentIndex = 0; size_t currentIndex = 0;
size_t nextIndex = 0; size_t nextIndex = 0;
string currentWord; string currentWord;
while (currentIndex < doxygenString.length()){ while (currentIndex < doxygenString.length()) {
if(doxygenString[currentIndex] == '\n'){ if (doxygenString[currentIndex] == '\n') {
m_tokenList.push_back(Token(END_LINE, currentWord)); m_tokenList.push_back(Token(END_LINE, currentWord));
currentIndex++; currentIndex++;
} }
// skip WS, except \n // skip WS, except \n
while(currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' while (currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' || doxygenString[currentIndex] == '\t'))
|| doxygenString[currentIndex]== '\t')) currentIndex ++; currentIndex++;
if (currentIndex < doxygenString.length()) { if (currentIndex < doxygenString.length()) {
nextIndex = currentIndex; nextIndex = currentIndex;
// skip non WS // skip non WS
while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' && doxygenString[nextIndex] != '\t' && doxygenString[nextIndex] != '\n'))
&& doxygenString[nextIndex] != '\t' && doxygenString[nextIndex]!= '\n'))
nextIndex++; nextIndex++;
// now we have a token // now we have a token
currentWord = doxygenString.substr(currentIndex, nextIndex-currentIndex); currentWord = doxygenString.substr(currentIndex, nextIndex - currentIndex);
if(noisy2) if (noisy2)
cout << "Current Word: " << currentWord << endl; cout << "Current Word: " << currentWord << endl;
if (currentWord[0] == '@' || currentWord[0] == '\\'){ if (currentWord[0] == '@' || currentWord[0] == '\\') {
// it is doxygen command // it is doxygen command
currentWord = currentWord.substr(1, currentWord.length()-1); currentWord = currentWord.substr(1, currentWord.length() - 1);
m_tokenList.push_back(Token(COMMAND, currentWord)); m_tokenList.push_back(Token(COMMAND, currentWord));
} else if (currentWord[0] == '\n'){ } else if (currentWord[0] == '\n') {
m_tokenList.push_back(Token(END_LINE, currentWord)); m_tokenList.push_back(Token(END_LINE, currentWord));
} } else if (currentWord[0] == '*' || currentWord[0] == '/' || currentWord[0] == '!') {
else if (currentWord[0] == '*' || currentWord[0] == '/' ||currentWord[0] == '!'){
bool isPlainString = false; bool isPlainString = false;
if (currentWord.length() > 1) { if (currentWord.length() > 1) {
for(size_t i = 1; i < currentWord.length(); i++){ for (size_t i = 1; i < currentWord.length(); i++) {
if (currentWord[i] != '*' && currentWord[i] != '/' && if (currentWord[i] != '*' && currentWord[i] != '/' && currentWord[i] != '!') {
currentWord[i] != '!') {
isPlainString = true; isPlainString = true;
break; break;
} }
} }
} }
if(isPlainString) if (isPlainString)
m_tokenList.push_back(Token(PLAINSTRING, currentWord)); m_tokenList.push_back(Token(PLAINSTRING, currentWord));
} else if (!currentWord.empty()) { } else if (!currentWord.empty()) {
@ -111,59 +108,58 @@ TokenList::TokenList(const std::string &doxygenStringConst){
} }
TokenList:: ~TokenList(){ TokenList::~TokenList() {
} }
Token TokenList::peek(){ Token TokenList::peek() {
if(m_tokenListIter!= m_tokenList.end()){ if (m_tokenListIter != m_tokenList.end()) {
Token returnedToken = (*m_tokenListIter); Token returnedToken = (*m_tokenListIter);
return returnedToken; return returnedToken;
} } else
else
return Token(0, ""); return Token(0, "");
} }
Token TokenList::next(){ Token TokenList::next() {
if(m_tokenListIter != m_tokenList.end()){ if (m_tokenListIter != m_tokenList.end()) {
Token returnedToken = (*m_tokenListIter); Token returnedToken = (*m_tokenListIter);
m_tokenListIter++; m_tokenListIter++;
return (returnedToken); return (returnedToken);
} } else
else
return Token(0, ""); return Token(0, "");
} }
list<Token>::iterator TokenList::end(){ list < Token >::iterator TokenList::end() {
return m_tokenList.end(); return m_tokenList.end();
} }
list<Token>::iterator TokenList::current(){ list < Token >::iterator TokenList::current() {
return m_tokenListIter; return m_tokenListIter;
} }
list<Token>::iterator TokenList::iteratorCopy(){ list < Token >::iterator TokenList::iteratorCopy() {
return m_tokenListIter; return m_tokenListIter;
} }
void TokenList::setIterator(list<Token>::iterator newPosition){ void TokenList::setIterator(list < Token >::iterator newPosition) {
m_tokenListIter = newPosition; m_tokenListIter = newPosition;
} }
void TokenList::printList(){ void TokenList::printList() {
list<Token>::iterator p = m_tokenList.begin(); list < Token >::iterator p = m_tokenList.begin();
int i = 1; int i = 1;
int b = 0; int b = 0;
while (p != m_tokenList.end()){ while (p != m_tokenList.end()) {
cout << (*p).toString() << " "; cout << (*p).toString() << " ";
b = i%TOKENSPERLINE; b = i % TOKENSPERLINE;
if (b == 0) cout << endl; if (b == 0)
p++; i++; cout << endl;
p++;
i++;
} }
} }

View file

@ -10,25 +10,25 @@
* that can be derived from a formatted doxygen string * that can be derived from a formatted doxygen string
*/ */
class TokenList{ class TokenList {
private: private:
std::list<Token> m_tokenList; std::list < Token > m_tokenList;
std::list<Token>::iterator m_tokenListIter; std::list < Token >::iterator m_tokenListIter;
public: public:
TokenList(const std::string &doxygenString); /* constructor takes a blob of Doxygen comment */ TokenList(const std::string & doxygenString); /* constructor takes a blob of Doxygen comment */
~TokenList(); ~TokenList();
Token peek(); /* returns next token without advancing */ Token peek(); /* returns next token without advancing */
Token next(); /* returns next token and advances */ Token next(); /* returns next token and advances */
std::list<Token>::iterator end(); /* returns an end iterator */ std::list < Token >::iterator end(); /* returns an end iterator */
std::list<Token>::iterator current(); /* returns the current iterator */ std::list < Token >::iterator current(); /* returns the current iterator */
std::list<Token>::iterator iteratorCopy(); /* returns a copy of the current iterator */ std::list < Token >::iterator iteratorCopy(); /* returns a copy of the current iterator */
void setIterator(list<Token>::iterator newPosition); /*moves up the iterator*/ void setIterator(list < Token >::iterator newPosition); /*moves up the iterator */
void printList(); /* prints out the sequence of tokens */ void printList(); /* prints out the sequence of tokens */
}; };
#endif /*TOKENLIST_H_*/ #endif