From 6a7fe334beee85e9d169d7c3330e1d9756e2d105 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 13 Jul 2012 10:46:59 +0000 Subject: [PATCH] Implemented parsing support for missing commands: \xrefitem, \ref, \subpage, \dotfile, \mscfile, \image, fixed \par git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13319 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/DoxygenCommands.h | 8 +- .../DoxygenTranslator/src/DoxygenParser.cpp | 98 +++++++++++++++---- 2 files changed, 84 insertions(+), 22 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenCommands.h b/Source/DoxygenTranslator/src/DoxygenCommands.h index 8b933878b..1b24eff33 100644 --- a/Source/DoxygenTranslator/src/DoxygenCommands.h +++ b/Source/DoxygenTranslator/src/DoxygenCommands.h @@ -12,7 +12,7 @@ const char *commandArray[] = { "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "line", "link", "mainpage", "manonly", "msc", "mscfile", "n", "name", "namespace", "nosubgrouping", "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", "private", "privatesection", "property", "protected", "protectedsection", "protocol", "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "remark", "result", "return", "returns", "retval", @@ -37,7 +37,7 @@ const char *ignoredSimpleCommands[] = { const int ignoredSimpleCommandsSize = sizeof(ignoredSimpleCommands) / sizeof(*ignoredSimpleCommands); const char *commandWords[] = { - "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", + "a", "b", "c", "e", "em", "p", "def", "enum", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno"}; const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords); @@ -68,7 +68,7 @@ const char *commandEndCommands[] = { const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands); const char *commandWordParagraphs[] = { - "param", "tparam", "throw", "throws", "retval", "exception"}; + "param", "tparam", "throw", "throws", "retval", "exception", "example"}; const int commandWordParagraphsSize = sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs); const char *commandWordLines[] = { @@ -92,7 +92,7 @@ const int commandErrorThrowingsSize = sizeof(commandErrorThrowings) / sizeof(*co const char *commandUniques[] = { "xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li", - "if", "ifnot", "elseif", "else"}; + "if", "ifnot", "elseif", "else", "mscfile"}; const int commandUniquesSize = sizeof(commandUniques) / sizeof(*commandUniques); #endif diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index b47320268..4fee595a6 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -407,11 +407,28 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, } // \xrefitem "(heading)" "(std::list title)" {text} else if (theCommand == "xrefitem") { - //TODO Implement xrefitem if (noisy) - cout << "Not Adding " << theCommand << endl; + cout << "Parsing " << theCommand << endl; + std::string key = getNextWord(tokList); + if (key.empty()) { + tokList.printListError("No key followed " + theCommand + " command. Not added"); + return 0; + } + std::string heading = getNextWord(tokList); + if (key.empty()) { + tokList.printListError("No heading followed " + theCommand + " command. Not added"); + return 0; + } + std::string title = getNextWord(tokList); + if (title.empty()) { + tokList.printListError("No title followed " + theCommand + " command. Not added"); + return 0; + } std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); + aNewList = parse(endOfParagraph, tokList); + aNewList.push_front(DoxygenEntity("plainstd::string", title)); + aNewList.push_front(DoxygenEntity("plainstd::string", heading)); + aNewList.push_front(DoxygenEntity("plainstd::string", key)); return 1; } // \ingroup ( [ ]) @@ -432,7 +449,8 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, std::list < Token >::iterator endOfLine = getOneLine(tokList); aNewList = parse(endOfLine, tokList); std::list < DoxygenEntity > aNewList2; - aNewList2 = parse(endOfLine, tokList); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + aNewList2 = parse(endOfParagraph, tokList); aNewList.splice(aNewList.end(), aNewList2); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; @@ -478,31 +496,75 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, } // \ref ["(text)"] else if (theCommand == "ref") { - //TODO Implement ref if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + tokList.printListError("No key followed " + theCommand + " command. Not added"); + return 0; + } + std::string text = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + if (!text.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", text)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \subpage ["(text)"] else if (theCommand == "subpage") { - //TODO implement subpage if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + tokList.printListError("No name followed " + theCommand + " command. Not added"); + return 0; + } + std::string text = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + if (!text.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", text)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \dotfile ["caption"] - else if (theCommand == "dotfile") { - //TODO implement dotfile + // \mscfile ["caption"] + else if (theCommand == "dotfile" || theCommand == "mscfile") { if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); + cout << "Parsing " << theCommand << endl; + std::string file = getNextWord(tokList); + if (file.empty()) { + tokList.printListError("No file followed " + theCommand + " command. Not added"); + return 0; + } + std::string caption = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", file)); + if (!caption.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", caption)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \image ["caption"] [=] else if (theCommand == "image") { - //todo implement image + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string format = getNextWord(tokList); + if (format.empty()) { + tokList.printListError("No format followed " + theCommand + " command. Not added"); + return 0; + } + std::string file = getNextWord(tokList); + if (file.empty()) { + tokList.printListError("No name followed " + theCommand + " command. Not added"); + return 0; + } + std::string caption = getNextWord(tokList); + std::string size = getNextWord(tokList); + + std::list < DoxygenEntity > aNewList; + aNewList.push_back(DoxygenEntity("plainstd::string", format)); + aNewList.push_back(DoxygenEntity("plainstd::string", file)); + if (!caption.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", caption)); + if (!size.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", size)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \addtogroup [(title)] else if (theCommand == "addtogroup") {