Added support for parsing of missing doxygen commands. Now parser produces correct parse tree for every doxygen tag, at least for those included in the testcase. Also added the test with all the tags, even those that will be ignored later.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13322 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
34dc515a40
commit
4ce9f2361c
4 changed files with 401 additions and 17 deletions
338
Examples/test-suite/doxygen_translate_all_tags.i
Normal file
338
Examples/test-suite/doxygen_translate_all_tags.i
Normal file
|
|
@ -0,0 +1,338 @@
|
|||
%module doxygen_translate
|
||||
|
||||
%inline %{
|
||||
|
||||
/**
|
||||
* \a Hello
|
||||
*
|
||||
* \addindex SomeLatexIndex
|
||||
*
|
||||
* \addtogroup someGroup "Some title"
|
||||
*
|
||||
* \anchor theAnchor
|
||||
*
|
||||
* \arg some list item
|
||||
*
|
||||
* \attention This is attention!
|
||||
* You were warned!
|
||||
*
|
||||
* \authors lots of them
|
||||
*
|
||||
* \author Zubr
|
||||
*
|
||||
* \b boldword
|
||||
*
|
||||
* \brief Some brief description,
|
||||
* extended to many lines.
|
||||
*
|
||||
* \bug Not everything works right now...
|
||||
*
|
||||
* \c codeword
|
||||
*
|
||||
* \callgraph
|
||||
*
|
||||
* \callergraph
|
||||
*
|
||||
* \category someCategory headerFile.h headerName
|
||||
*
|
||||
* \cite citationword
|
||||
*
|
||||
* \class someClass headerFile.h headerName
|
||||
*
|
||||
* \code some test code \endcode
|
||||
*
|
||||
* \cond SOMECONDITION
|
||||
* Some conditional comment
|
||||
* \endcond
|
||||
*
|
||||
* \copybrief someClass::someMethod
|
||||
*
|
||||
* \copydetails someClass::someMethod2
|
||||
*
|
||||
* \copydoc someClass::someMethod3
|
||||
*
|
||||
* \copyright some copyright
|
||||
*
|
||||
* \date 1970 - 2012
|
||||
*
|
||||
* \def someDefine
|
||||
*
|
||||
* \defgroup someGroup Some titles
|
||||
*
|
||||
* \deprecated Now use another function
|
||||
*
|
||||
* \details This is very large
|
||||
* and detailed description of some thing
|
||||
*
|
||||
* \dir /somePath/someFolder
|
||||
*
|
||||
* \dontinclude someFile.h
|
||||
*
|
||||
* \dot
|
||||
* digraph example {
|
||||
* node [shape=record, fontname=Helvetica, fontsize=10];
|
||||
* b [ label="class B" URL="\ref B"];
|
||||
* c [ label="class C" URL="\ref C"];
|
||||
* b -> c [ arrowhead="open", style="dashed" ];
|
||||
* }
|
||||
* \enddot
|
||||
*
|
||||
* \dotfile dotFile.dot "The caption"
|
||||
*
|
||||
* \e italicword
|
||||
*
|
||||
* \em emphazedWord
|
||||
*
|
||||
* \enum someEnum
|
||||
*
|
||||
* \example someFile.txt
|
||||
* Some details on using the example
|
||||
*
|
||||
* \exception SuperError
|
||||
*
|
||||
* \extends someOtherFunction
|
||||
*
|
||||
* \f$ \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \f$
|
||||
*
|
||||
* \f[
|
||||
* \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}
|
||||
* \f]
|
||||
*
|
||||
* \f{
|
||||
* \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}
|
||||
* \f}
|
||||
*
|
||||
* \file file.h
|
||||
*
|
||||
* \fn someFn
|
||||
*
|
||||
* \headerfile someHeader.h "Header name"
|
||||
*
|
||||
* \hideinitializer
|
||||
*
|
||||
* \htmlinclude htmlFile.htm
|
||||
*
|
||||
* \htmlonly
|
||||
* This will only appear in hmtl
|
||||
* \endhtmlonly
|
||||
*
|
||||
* \if ANOTHERCONDITION
|
||||
* First part of comment
|
||||
* \if SECONDCONDITION
|
||||
* Nested condition text
|
||||
* \elseif THIRDCONDITION
|
||||
* The third condition text
|
||||
* \else
|
||||
* The last text block
|
||||
* \endif
|
||||
* \else
|
||||
* Second part of comment
|
||||
* \if CONDITION
|
||||
* Second part extended
|
||||
* \endif
|
||||
* \endif
|
||||
*
|
||||
* \ifnot SOMECONDITION
|
||||
* This is printed if not
|
||||
* \endif
|
||||
*
|
||||
* \image html testImage.bmp "Hello, world!" asd=10qwe
|
||||
*
|
||||
* \implements someFunction
|
||||
*
|
||||
* \include header.h
|
||||
*
|
||||
* \includelineno header2.h
|
||||
*
|
||||
* \ingroup someGroup anotherGroup
|
||||
*
|
||||
* \internal
|
||||
*
|
||||
* \invariant Some text
|
||||
* describing invariant.
|
||||
*
|
||||
* \interface someInterface someHeader.h "Header name"
|
||||
*
|
||||
* \latexonly
|
||||
* This will only appear in LATeX
|
||||
* \endlatexonly
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* \li Some unordered list
|
||||
* \li With lots of items
|
||||
* \li lots of lots of items
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* \line example
|
||||
*
|
||||
* \link someMember Some description follows \endlink
|
||||
*
|
||||
* \mainpage Some title
|
||||
*
|
||||
* \manonly
|
||||
* This will only appear in man
|
||||
* \endmanonly
|
||||
*
|
||||
* \memberof someThing
|
||||
*
|
||||
* \msc
|
||||
* Sender,Receiver;
|
||||
* Sender->Receiver [label="Command()", URL="\ref Receiver::Command()"];
|
||||
* Sender<-Receiver [label="Ack()", URL="\ref Ack()", ID="1"];
|
||||
* \endmsc
|
||||
*
|
||||
* \mscfile mscFile.msc "The caption"
|
||||
*
|
||||
* \n \n \n
|
||||
*
|
||||
* \name someHeader.h
|
||||
*
|
||||
* \namespace someNamespace
|
||||
*
|
||||
* \nosubgrouping
|
||||
*
|
||||
* \note Here
|
||||
* is the note!
|
||||
*
|
||||
* \overload
|
||||
*
|
||||
* \p someword
|
||||
*
|
||||
* \package superPackage
|
||||
*
|
||||
* \page somePage The title
|
||||
*
|
||||
* \par The paragraph title
|
||||
* The paragraph text.
|
||||
* Maybe even multiline
|
||||
*
|
||||
* \paragraph someParagraph Paragraph title
|
||||
*
|
||||
* \param a the first param
|
||||
*
|
||||
* \post Some description
|
||||
*
|
||||
* \pre Some description
|
||||
*
|
||||
* \private
|
||||
*
|
||||
* \privatesection
|
||||
*
|
||||
* \property someVar
|
||||
*
|
||||
* \protected
|
||||
*
|
||||
* \protectedsection
|
||||
*
|
||||
* \protocol someProtocol header.h "Header name"
|
||||
*
|
||||
* \public
|
||||
*
|
||||
* \publicsection
|
||||
*
|
||||
* \ref someAnchor
|
||||
*
|
||||
* \related toSomething
|
||||
*
|
||||
* \relates toSomethingElse
|
||||
*
|
||||
* \relatedalso someName
|
||||
*
|
||||
* \relatesalso someName
|
||||
*
|
||||
* \remark Some remark text
|
||||
*
|
||||
* \remarks Another remarks section
|
||||
*
|
||||
* \result Whatever
|
||||
*
|
||||
* \return it
|
||||
*
|
||||
* \returns may return
|
||||
*
|
||||
* \retval someValue Some description
|
||||
*
|
||||
* \rtfonly
|
||||
* This will only appear in RTF
|
||||
* \endrtfonly
|
||||
*
|
||||
* \sa someOtherMethod
|
||||
*
|
||||
* \section someSection Some title
|
||||
*
|
||||
* \see function
|
||||
*
|
||||
* \short Same as
|
||||
* brief description
|
||||
*
|
||||
* \showinitializer
|
||||
*
|
||||
* \since version 0.0.0.1
|
||||
*
|
||||
* \skip somePattern
|
||||
*
|
||||
* \skipline someLine
|
||||
*
|
||||
* \snippet example.h Some snippet
|
||||
*
|
||||
* \struct someStruct
|
||||
*
|
||||
* \subpage someSubpage "Some description"
|
||||
*
|
||||
* \subsection someSubsection Some title
|
||||
*
|
||||
* \subsubsection someSubsection Some title
|
||||
*
|
||||
* \tableofcontents
|
||||
*
|
||||
* \test Some
|
||||
* description of the
|
||||
* test case
|
||||
*
|
||||
* \throw superException
|
||||
*
|
||||
* \throws RuntimeError
|
||||
*
|
||||
* \todo Some very important task
|
||||
*
|
||||
* \tparam b B is mentioned again...
|
||||
*
|
||||
* \typedef someTypedef
|
||||
*
|
||||
* \union someUnion
|
||||
*
|
||||
* \until somePattern
|
||||
*
|
||||
* \var someVar
|
||||
*
|
||||
* \verbatim
|
||||
* very long
|
||||
* text with tags <sometag>
|
||||
* \endverbatim
|
||||
*
|
||||
* \verbinclude someFile.h
|
||||
*
|
||||
* \version 0.0.0.2
|
||||
*
|
||||
* \warning This is senseless!
|
||||
*
|
||||
* \weakgroup someGroup Some title
|
||||
*
|
||||
* \xmlonly
|
||||
* This will only appear in XML
|
||||
* \endxmlonly
|
||||
*
|
||||
* \xrefitem todo "Todo" "Todo List"
|
||||
*
|
||||
* Here goes test of symbols:
|
||||
* \$ \@ \\ \& \~ \< \> \# \% \" \. \::
|
||||
*
|
||||
* And here goes simple text
|
||||
*/
|
||||
int function(int a, float b)
|
||||
{
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
@ -29,7 +29,10 @@ const int sectionIndicatorsSize = sizeof(sectionIndicators) / sizeof(*sectionInd
|
|||
|
||||
/* All of the doxygen commands divided up by how they are parsed */
|
||||
const char *simpleCommands[] = {
|
||||
"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%", "\"", ".", "::", "endcond"};
|
||||
"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%", "\"", ".", "::", "endcond",
|
||||
"callgraph", "callergraph", "showinitializer", "hideinitializer", "internal",
|
||||
"nosubgrouping", "public", "publicsection", "private", "privatesection",
|
||||
"protected", "protectedsection", "tableofcontents"};
|
||||
const int simpleCommandsSize = sizeof(simpleCommands) / sizeof(*simpleCommands);
|
||||
|
||||
const char *ignoredSimpleCommands[] = {
|
||||
|
|
@ -38,11 +41,12 @@ const int ignoredSimpleCommandsSize = sizeof(ignoredSimpleCommands) / sizeof(*ig
|
|||
|
||||
const char *commandWords[] = {
|
||||
"a", "b", "c", "e", "em", "p", "def", "enum", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include",
|
||||
"includelineno"};
|
||||
"includelineno", "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude", "extends", "implements", "memberof", "related",
|
||||
"relatedalso"};
|
||||
const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords);
|
||||
|
||||
const char *ignoredCommandWords[] = {
|
||||
"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"};
|
||||
"nothing at the moment"};
|
||||
const int ignoredCommandWordsSize = sizeof(ignoredCommandWords) / sizeof(*ignoredCommandWords);
|
||||
|
||||
const char *commandLines[] = {
|
||||
|
|
@ -56,7 +60,7 @@ const int ignoreCommandLinesSize = sizeof(ignoreCommandLines) / sizeof(*ignoreCo
|
|||
const char *commandParagraph[] = {
|
||||
"partofdescription", "result", "return", "returns", "remarks", "remark", "since", "test", "sa", "see", "pre", "post", "details", "invariant",
|
||||
"deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author", "authors", "cite",
|
||||
"copyright"};
|
||||
"copyright", "short"};
|
||||
const int commandParagraphSize = sizeof(commandParagraph) / sizeof(*commandParagraph);
|
||||
|
||||
const char *ignoreCommandParagraphs[] = {
|
||||
|
|
@ -64,7 +68,7 @@ const char *ignoreCommandParagraphs[] = {
|
|||
const int ignoreCommandParagraphsSize = sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs);
|
||||
|
||||
const char *commandEndCommands[] = {
|
||||
"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "link"};
|
||||
"htmlonly", "latexonly", "manonly", "xmlonly", "link", "rtfonly"};
|
||||
const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands);
|
||||
|
||||
const char *commandWordParagraphs[] = {
|
||||
|
|
@ -72,7 +76,7 @@ const char *commandWordParagraphs[] = {
|
|||
const int commandWordParagraphsSize = sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs);
|
||||
|
||||
const char *commandWordLines[] = {
|
||||
"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"};
|
||||
"page", "subsection", "subsubsection", "section", "paragraph", "defgroup", "snippet", "mainpage"};
|
||||
const int commandWordLinesSize = sizeof(commandWordLines) / sizeof(*commandWordLines);
|
||||
|
||||
const char *commandWordOWordOWords[] = {
|
||||
|
|
@ -85,14 +89,14 @@ const int commandOWordsSize = sizeof(commandOWords) / sizeof(*commandOWords);
|
|||
|
||||
const char *commandErrorThrowings[] = {
|
||||
"annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header",
|
||||
"headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected",
|
||||
"protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly",
|
||||
"endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endif", "else"};
|
||||
"headerfilestd::list", "inherit", "l", "postheader", "endcode", "enddot", "endmsc", "endhtmlonly",
|
||||
"endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endif", "else",
|
||||
"endrtfonly"};
|
||||
const int commandErrorThrowingsSize = sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings);
|
||||
|
||||
const char *commandUniques[] = {
|
||||
"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li",
|
||||
"if", "ifnot", "elseif", "else", "mscfile"};
|
||||
"if", "ifnot", "elseif", "else", "mscfile", "code", "verbatim", "f{", "f[", "f$", "dot", "msc"};
|
||||
const int commandUniquesSize = sizeof(commandUniques) / sizeof(*commandUniques);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -227,11 +227,11 @@ std::list < Token >::iterator DoxygenParser::getEndOfSection(std::string theComm
|
|||
std::list < Token >::iterator DoxygenParser::getEndCommand(std::string theCommand, TokenList & tokList) {
|
||||
std::list < Token >::iterator endOfCommand = tokList.iteratorCopy();
|
||||
while (endOfCommand != tokList.end()) {
|
||||
endOfCommand++;
|
||||
if ((*endOfCommand).tokenType == COMMAND) {
|
||||
if (theCommand == (*endOfCommand).tokenString) {
|
||||
return endOfCommand;
|
||||
}
|
||||
endOfCommand++;
|
||||
}
|
||||
}
|
||||
//End command not found
|
||||
|
|
@ -263,7 +263,9 @@ int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, s
|
|||
cout << "Parsing " << theCommand << endl;
|
||||
std::string name = getNextWord(tokList);
|
||||
if (!name.empty()) {
|
||||
doxyList.push_back(DoxygenEntity(theCommand, name));
|
||||
std::list < DoxygenEntity > aNewList;
|
||||
aNewList.push_back(DoxygenEntity("plainstd::string", name));
|
||||
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
|
||||
return 1;
|
||||
} else
|
||||
tokList.printListError("No word followed " + theCommand + " command. Not added");
|
||||
|
|
@ -322,8 +324,15 @@ int DoxygenParser::ignoreCommandParagraph(std::string theCommand, TokenList & to
|
|||
int DoxygenParser::addCommandEndCommand(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
|
||||
if (noisy)
|
||||
cout << "Parsing " << theCommand << endl;
|
||||
std::string description = getStringTilEndCommand("end" + theCommand, tokList);
|
||||
doxyList.push_back(DoxygenEntity(theCommand, description));
|
||||
std::list < Token >::iterator endCommand = getEndCommand("end" + theCommand, tokList);
|
||||
if (endCommand == tokList.end()) {
|
||||
tokList.printListError("Expected end" + theCommand);
|
||||
return 0;
|
||||
}
|
||||
std::list < DoxygenEntity > aNewList;
|
||||
aNewList = parse(endCommand, tokList);
|
||||
tokList.next();
|
||||
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -398,6 +407,7 @@ int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokL
|
|||
}
|
||||
|
||||
int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) {
|
||||
static std::map<std::string, std::string> endCommands;
|
||||
std::list < DoxygenEntity > aNewList;
|
||||
if (theCommand == "arg" || theCommand == "li") {
|
||||
std::list < Token >::iterator endOfSection = getEndOfSection(theCommand, tokList);
|
||||
|
|
@ -524,6 +534,39 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList,
|
|||
aNewList.push_back(DoxygenEntity("plainstd::string", text));
|
||||
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
|
||||
}
|
||||
// \code ... \endcode
|
||||
// \verbatim ... \endverbatim
|
||||
// \dot dotcode \enddot
|
||||
// \msc msccode \endmsc
|
||||
// \f[ ... \f]
|
||||
// \f{ ... \f}
|
||||
// \f{env}{ ... \f}
|
||||
// \f$ ... \f$
|
||||
else if (theCommand == "code" || theCommand == "verbatim"
|
||||
|| theCommand == "dot" || theCommand == "msc"
|
||||
|| theCommand == "f[" || theCommand == "f{"
|
||||
|| theCommand == "f$") {
|
||||
if (!endCommands.size()) {
|
||||
// fill in static table of end commands
|
||||
endCommands["f["] = "f]";
|
||||
endCommands["f{"] = "f}";
|
||||
endCommands["f$"] = "f$";
|
||||
}
|
||||
if (noisy)
|
||||
cout << "Parsing " << theCommand << endl;
|
||||
|
||||
std::string endCommand;
|
||||
std::map <std::string, std::string>::iterator it;
|
||||
it = endCommands.find(theCommand);
|
||||
if (it != endCommands.end())
|
||||
endCommand = it->second;
|
||||
else
|
||||
endCommand = "end" + theCommand;
|
||||
|
||||
std::string content = getStringTilEndCommand(endCommand, tokList);
|
||||
aNewList.push_back(DoxygenEntity("plainstd::string", content));
|
||||
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
|
||||
}
|
||||
// \dotfile <file> ["caption"]
|
||||
// \mscfile <file> ["caption"]
|
||||
else if (theCommand == "dotfile" || theCommand == "mscfile") {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c
|
|||
string::size_type pos, lastPos = 0;
|
||||
string currentWord;
|
||||
while (true) {
|
||||
isPlainString = false;
|
||||
pos = doxygenComment.find_first_of("\t\n ", lastPos);
|
||||
if (pos == string::npos)
|
||||
pos = doxygenComment.size();
|
||||
|
|
@ -55,9 +56,7 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c
|
|||
|
||||
if (isPlainString) {
|
||||
// handle quoted words
|
||||
string::size_type qPos = currentWord.find('"', 0);
|
||||
if (qPos != string::npos) {
|
||||
lastPos += qPos;
|
||||
if (currentWord[0] == '"') {
|
||||
pos = doxygenComment.find_first_of("\"\n", lastPos + 1);
|
||||
if (pos == string::npos)
|
||||
pos = doxygenComment.size();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue