From 8d986f5d3a2a40e40d2c9f584f921ed4cc4dd105 Mon Sep 17 00:00:00 2001 From: dimitri Date: Sun, 15 Sep 2002 19:55:15 +0000 Subject: Release-1.2.17-20020915 --- INSTALL | 4 +- README | 4 +- VERSION | 2 +- doc/commands.doc | 36 +- doc/config.doc | 29 + doc/index.doc | 2 +- packages/rpm/doxygen.spec | 2 +- src/config.l | 35 +- src/doc.l | 2 +- src/docparser.cpp | 793 +++++++++++--------- src/docparser.h | 63 +- src/docvisitor.h | 3 +- src/dot.cpp | 1 + src/htmldocvisitor.cpp | 29 +- src/htmldocvisitor.h | 3 +- src/htmlgen.cpp | 16 +- src/latexdocvisitor.cpp | 99 ++- src/latexdocvisitor.h | 4 +- src/latexgen.cpp | 16 +- src/libdoxygen.pro.in | 4 +- src/mangen.cpp | 21 +- src/mangen.h | 2 + src/outputgen.h | 2 +- src/outputlist.cpp | 15 +- src/pre.l | 13 +- src/printdocvisitor.h | 15 +- src/rtfdocvisitor.cpp | 549 +++++++------- src/rtfdocvisitor.h | 5 +- src/rtfgen.cpp | 50 +- src/rtfgen.h | 2 + src/rtfstyle.cpp | 2 +- src/rtfstyle.h | 7 +- src/scanner.l | 19 +- src/section.h | 2 +- src/util.cpp | 4 +- src/xmldocvisitor.cpp | 737 +++++++++++++++++++ src/xmldocvisitor.h | 147 ++++ src/xmlgen.cpp | 1790 +++++++++++++++++++++++++-------------------- 38 files changed, 2993 insertions(+), 1536 deletions(-) create mode 100644 src/xmldocvisitor.cpp create mode 100644 src/xmldocvisitor.h diff --git a/INSTALL b/INSTALL index b679d97..15e5d56 100644 --- a/INSTALL +++ b/INSTALL @@ -1,6 +1,6 @@ -DOXYGEN Version 1.2.17-20020901 +DOXYGEN Version 1.2.17-20020915 Please read the installation section of the manual for instructions. -------- -Dimitri van Heesch (01 September 2002) +Dimitri van Heesch (15 September 2002) diff --git a/README b/README index d39ad5d..ef80b4e 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -DOXYGEN Version 1.2.17_20020901 +DOXYGEN Version 1.2.17_20020915 Please read INSTALL for compilation instructions. @@ -17,4 +17,4 @@ to subscribe to the lists or to visit the archives. Enjoy, -Dimitri van Heesch (dimitri@stack.nl) (01 September 2002) +Dimitri van Heesch (dimitri@stack.nl) (15 September 2002) diff --git a/VERSION b/VERSION index 98b96a6..6ab16e8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.17-20020901 +1.2.17-20020915 diff --git a/doc/commands.doc b/doc/commands.doc index 8a95ab6..42d4c8d 100644 --- a/doc/commands.doc +++ b/doc/commands.doc @@ -116,6 +116,7 @@ documentation: \refitem cmdskipline \\skipline \refitem cmdstruct \\struct \refitem cmdsubsection \\subsection +\refitem cmdsubsubsection \\subsubsection \refitem cmdtest \\test \refitem cmdthrow \\throw \refitem cmdtodo \\todo @@ -1106,7 +1107,8 @@ ALIASES = "english=\if english" \ subsection should be specified as the second argument of the \\subsection command. - \warning This command only works inside related page documentation and + \warning This command only works inside a section of a related page + documentation block and \e not in other documentation blocks! \sa @@ -1114,6 +1116,38 @@ ALIASES = "english=\if english" \ \ref cmdsubsection "\\subsection" command.
+\section cmdsubsubsection \subsubsection (subsubsection title) + + \addindex \\subsubsection + Creates a subsubsection with name \. The title of the + subsubsection should be specified as the second argument of the + \\subsubsection command. + + \warning This command only works inside a subsection of a + related page documentation block and + \e not in other documentation blocks! + + \sa + Section \ref cmdpage "\\page" for an example of the + \ref cmdsubsubsection "\\subsubsection" command. + +
+\section cmdparagraph \paragraph (paragraph title) + + \addindex \\paragraph + Creates a named paragraph with name \. The title of the + paragraph should be specified as the second argument of the + \\paragraph command. + + \warning This command only works inside a subsubsection of a + related page documentation block and + \e not in other documentation blocks! + + \sa + Section \ref cmdpage "\\page" for an example of the + \ref cmdparagraph "\\paragraph" command. + +

\htmlonly
--- \endhtmlonly Commands for displaying examples diff --git a/doc/config.doc b/doc/config.doc index 3f38ee0..974f7f4 100644 --- a/doc/config.doc +++ b/doc/config.doc @@ -113,6 +113,7 @@ followed by the descriptions of the tags grouped by category. \refitem cfg_generate_testlist GENERATE_TESTLIST \refitem cfg_generate_todolist GENERATE_TODOLIST \refitem cfg_generate_treeview GENERATE_TREEVIEW +\refitem cfg_generate_xml GENERATE_XML \refitem cfg_graphical_hierarchy GRAPHICAL_HIERARCHY \refitem cfg_have_dot HAVE_DOT \refitem cfg_hhc_location HHC_LOCATION @@ -190,6 +191,8 @@ followed by the descriptions of the tags grouped by category. \refitem cfg_warn_if_undocumented WARN_IF_UNDOCUMENTED \refitem cfg_warn_logfile WARN_LOGFILE \refitem cfg_warnings WARNINGS +\refitem cfg_xml_dtd XML_DTD +\refitem cfg_xml_schema XML_SCHEMA \endsecreflist \section config_general General options @@ -1132,6 +1135,32 @@ EXTRA_PACKAGES = times +\section xml_output XML related options +\anchor cfg_generate_xml +
+ +
\c GENERATE_XML
+ \addindex GENERATE_XML + If the GENERATE_XML tag is set to YES Doxygen will + generate an XML file that captures the structure of + the code including all documentation. + +\anchor cfg_xml_schema +
\c XML_SCHEMA
+ \addindex XML_SCHEMA + The XML_SCHEMA file can be used to specify an XML schema, + which can be used by a validating XML parser to check the + syntax of the XML files. + +\anchor cfg_xml_dtd +
\c XML_DTD
+ \addindex XML_DTD + The XML_DTD file can be used to specify an XML DTD, + which can be used by a validating XML parser to check the + syntax of the XML files. + +
+ \section config_prepro Preprocessor related options \anchor cfg_enable_preprocessing
diff --git a/doc/index.doc b/doc/index.doc index da5246a..5639b61 100644 --- a/doc/index.doc +++ b/doc/index.doc @@ -180,7 +180,7 @@ Thanks go to: All language maintainers for providing translations into many languages.
  • Erik Jan Lingen of Habanera, Mark Roddy, Paul Schwartz, Charles Duffy, Vadym Voznyuk, Philip Walton, - Dwight Browne, and Andreas Fredriksson for donating money. + Dwight Browne, Andreas Fredriksson, and Karel Lindveld for donating money.
  • The Comms group of Symbian for donating an ultra cool Revo plus organizer! diff --git a/packages/rpm/doxygen.spec b/packages/rpm/doxygen.spec index a75c06a..034ada1 100644 --- a/packages/rpm/doxygen.spec +++ b/packages/rpm/doxygen.spec @@ -1,6 +1,6 @@ Summary: A documentation system for C/C++. Name: doxygen -Version: 1.2.17_20020901 +Version: 1.2.17_20020915 Release: 1 Epoch: 1 Source0: ftp://ftp.stack.nl/pub/users/dimitri/%{name}-%{version}.src.tar.gz diff --git a/src/config.l b/src/config.l index 86b11eb..07fde20 100644 --- a/src/config.l +++ b/src/config.l @@ -1186,12 +1186,31 @@ void Config::check() } #undef PUTENV +#undef GETENV +#undef SEP #if defined(_WIN32) && !defined(__GNUC__) && (__BORLANDC__ < 0x0550) #define PUTENV _putenv -#else +#define GETENV _getenv +#define SEP ";" +#else #define PUTENV putenv +#define GETENV getenv +#define SEP ":" #endif - if (Config_getBool("HAVE_DOT")) PUTENV("DOTFONTPATH=."); + if (Config_getBool("HAVE_DOT")) + { + char *curFontPath = GETENV("DOTFONTPATH"); + int l=curFontPath ? strlen(curFontPath)+1 : 0; + static char *buf = 0; + buf = (char *)realloc(buf,strlen("DOTFONTPATH=.")+l+1); + strcpy(buf,"DOTFONTPATH=."); + if (l>0) + { + strcat(buf,SEP); + strcat(buf,curFontPath); + } + PUTENV(buf); + } } @@ -2148,6 +2167,18 @@ void Config::create() "moment. \n", FALSE ); + cs = addString( + "XML_SCHEMA", + "The XML_SCHEMA file can be used to specify an XML schema, \n" + "which can be used by a validating XML parser to check the \n" + "syntax of the XML files. \n" + ); + cs = addString( + "XML_DTD", + "The XML_DTD file can be used to specify an XML DTD, \n" + "which can be used by a validating XML parser to check the \n" + "syntax of the XML files. \n" + ); //-------------------------------------------------------------------------- addInfo( "DEF","configuration options for the AutoGen Definitions output"); //-------------------------------------------------------------------------- diff --git a/src/doc.l b/src/doc.l index 42dd41f..2ce0a96 100644 --- a/src/doc.l +++ b/src/doc.l @@ -2763,7 +2763,7 @@ LINKMASK [^ \t\n\r\\@<&$]+("("[^\n)]*")")?({B}*("const"|"volatile"))? { outDoc->newParagraph(); } - if (ib && currentListIndent.top()=="P") + if (ib && *currentListIndent.top()=='P') { // inside paragraph block endBlock(); } diff --git a/src/docparser.cpp b/src/docparser.cpp index 5e4a79c..415e9cd 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "doxygen.h" @@ -35,24 +36,30 @@ #include "doctokenizer.h" #include "cmdmapper.h" #include "printdocvisitor.h" +#include "message.h" #define DBG(x) do {} while(0) //#define DBG(x) printf x //--------------------------------------------------------------------------- +static bool g_hasParamCommand; +static MemberDef * g_memberDef; +static QDict g_paramsFound; + // include file state static QCString g_includeFileText; static uint g_includeFileOffset; static uint g_includeFileLength; // parser state -static QCString g_context; -static bool g_inSeeBlock; -static bool g_insideHtmlLink; -static QStack g_nodeStack; +static QCString g_context; +static bool g_inSeeBlock; +static bool g_insideHtmlLink; +static QStack g_nodeStack; static QStack g_styleStack; -static QList g_copyStack; +static QList g_copyStack; +static QCString g_fileName; struct DocParserContext { @@ -62,6 +69,8 @@ struct DocParserContext QStack nodeStack; QStack styleStack; QList copyStack; + MemberDef *memberDef; + QCString fileName; }; static QStack g_parserStack; @@ -78,6 +87,7 @@ static void docParserPushContext() ctx->nodeStack = g_nodeStack; ctx->styleStack = g_styleStack; ctx->copyStack = g_copyStack; + ctx->fileName = g_fileName; g_parserStack.push(ctx); } @@ -90,12 +100,105 @@ static void docParserPopContext() g_nodeStack = ctx->nodeStack; g_styleStack = ctx->styleStack; g_copyStack = ctx->copyStack; + g_fileName = ctx->fileName; delete ctx; doctokenizerYYpopContext(); } //--------------------------------------------------------------------------- +static void checkArgumentName(const QCString &name,bool isParam) +{ + if (g_memberDef==0) return; // not a member + ArgumentList *al=g_memberDef->isDocsForDefinition() ? + g_memberDef->argumentList() : + g_memberDef->declArgumentList(); + if (al==0) return; // no argument list + if (!Config_getBool("WARN_IF_UNDOCUMENTED")) return; + + static QRegExp re("[a-zA-Z0-9_]+\\.*"); + int p=0,i=0,l; + while ((i=re.match(name,p,&l))!=-1) + { + QCString aName=name.mid(i,l); + //printf("aName=%s\n",aName.data()); + ArgumentListIterator ali(*al); + Argument *a; + bool found=FALSE; + for (ali.toFirst();(a=ali.current());++ali) + { + QCString argName = g_memberDef->isDefine() ? a->type : a->name; + if (argName.right(3)=="...") argName=argName.left(argName.length()-3); + if (aName==argName) + { + //printf("adding `%s'\n",aName.data()); + g_paramsFound.insert(aName,(void *)(0x8)); + found=TRUE; + break; + } + } + if (!found && isParam) + { + //printf("member type=%d\n",memberDef->memberType()); + QCString scope=g_memberDef->getScopeString(); + if (!scope.isEmpty()) scope+="::"; else scope=""; + warn(g_memberDef->docFile(),g_memberDef->docLine(), + "Warning: argument `%s' of command @param " + "is not found in the argument list of %s%s%s", + aName.data(),scope.data(),g_memberDef->name().data(), + argListToString(al).data() + ); + } + p=i+l; + } +} + +static void checkUndocumentedParams() +{ + if (g_memberDef && g_hasParamCommand && Config_getBool("WARN_IF_UNDOCUMENTED")) + { + ArgumentList *al=g_memberDef->isDocsForDefinition() ? + g_memberDef->argumentList() : + g_memberDef->declArgumentList(); + if (al) + { + ArgumentListIterator ali(*al); + Argument *a; + bool found=FALSE; + for (ali.toFirst();(a=ali.current());++ali) + { + QCString argName = g_memberDef->isDefine() ? a->type : a->name; + if (argName.right(3)=="...") argName=argName.left(argName.length()-3); + if (!argName.isEmpty() && g_paramsFound.find(argName)==0) + { + found = TRUE; + break; + } + } + if (found) + { + QCString scope=g_memberDef->getScopeString(); + if (!scope.isEmpty()) scope+="::"; else scope=""; + warn(g_memberDef->docFile(),g_memberDef->docLine(), + "Warning: The following parameters of " + "%s%s%s are not documented:", + scope.data(),g_memberDef->name().data(), + argListToString(al).data()); + for (ali.toFirst();(a=ali.current());++ali) + { + QCString argName = g_memberDef->isDefine() ? a->type : a->name; + if (!argName.isEmpty() && g_paramsFound.find(argName)==0) + { + warn_cont( " parameter %s\n",argName.data()); + } + } + } + } + } +} + +//--------------------------------------------------------------------------- + static QCString stripKnownExtensions(const char *text) { QCString result=text; @@ -300,8 +403,8 @@ static int handleStyleArgument(DocNode *parent,QList &children, int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + cmdName.data()); return tok; } while ((tok=doctokenizerYYlex()) && tok!=TK_WHITESPACE && tok!=TK_NEWPARA) @@ -311,16 +414,16 @@ static int handleStyleArgument(DocNode *parent,QList &children, switch (tok) { case TK_COMMAND: - printf("Error: Illegal command \\%s as the argument of a \\%s command at line %d\n", - g_token->name.data(),cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command \\%s as the argument of a \\%s command", + g_token->name.data(),cmdName.data()); break; case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unsupported symbol %s found", + g_token->name.data()); break; default: - printf("Error: Unexpected token %s at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", + g_token->name.data()); break; } } @@ -344,8 +447,8 @@ static void handleStyleLeave(DocNode *parent,QList &children,DocStyleCh g_styleStack.top()->position()!=g_nodeStack.count() // wrong position ) { - printf("Error: found tag at line %d without matching <%s> in the same paragraph\n", - tagName,doctokenizerYYlineno,tagName); + warn(g_fileName,doctokenizerYYlineno,"Error: found tag without matching <%s> in the same paragraph", + tagName,tagName); } else // end the section { @@ -373,8 +476,8 @@ static void handlePendingStyleCommands(DocNode *parent,QList &children) case DocStyleChange::Subscript: cmd = "subscript"; break; case DocStyleChange::Superscript: cmd = "superscript"; break; } - printf("Error: end of paragraph at line %d without end of style " - "command \n",doctokenizerYYlineno,cmd); + warn(g_fileName,doctokenizerYYlineno,"Error: end of paragraph without end of style " + "command ",cmd); children.append(new DocStyleChange(parent,g_nodeStack.count(),sc->style(),FALSE)); g_styleStack.pop(); sc = g_styleStack.top(); @@ -496,8 +599,7 @@ static bool defaultHandleToken(DocNode *parent,int tok, QList &children doctokenizerYYsetStateHtmlOnly(); int retval = doctokenizerYYlex(); children.append(new DocVerbatim(parent,g_context,g_token->verb,DocVerbatim::HtmlOnly)); - if (retval==0) printf("Error: htmlonly section ended without end marker at line %d\n", - doctokenizerYYlineno); + if (retval==0) warn(g_fileName,doctokenizerYYlineno,"Error: htmlonly section ended without end marker"); doctokenizerYYsetStatePara(); } break; @@ -506,8 +608,7 @@ static bool defaultHandleToken(DocNode *parent,int tok, QList &children doctokenizerYYsetStateLatexOnly(); int retval = doctokenizerYYlex(); children.append(new DocVerbatim(parent,g_context,g_token->verb,DocVerbatim::LatexOnly)); - if (retval==0) printf("Error: latexonly section ended without end marker at line %d\n", - doctokenizerYYlineno); + if (retval==0) warn(g_fileName,doctokenizerYYlineno,"Error: latexonly section ended without end marker",doctokenizerYYlineno); doctokenizerYYsetStatePara(); } break; @@ -522,21 +623,21 @@ static bool defaultHandleToken(DocNode *parent,int tok, QList &children int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - tokenName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + tokenName.data()); break; } tok=doctokenizerYYlex(); if (tok==0) { - printf("Error: unexpected end of comment block at line %d while parsing the " - "argument of command %s\n",doctokenizerYYlineno, tokenName.data()); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment block while parsing the " + "argument of command %s",tokenName.data()); break; } else if (tok!=TK_WORD && tok!=TK_LNKWORD) { - printf("Error: unexpected token %s as the argument of %s at line %d.\n", - tokToString(tok),tokenName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of %s", + tokToString(tok),tokenName.data()); break; } DocAnchor *anchor = new DocAnchor(parent,g_token->name,FALSE); @@ -548,8 +649,8 @@ static bool defaultHandleToken(DocNode *parent,int tok, QList &children int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - tokenName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + tokenName.data()); break; } doctokenizerYYsetStateInternalRef(); @@ -557,8 +658,8 @@ static bool defaultHandleToken(DocNode *parent,int tok, QList &children DocInternalRef *ref=0; if (tok!=TK_WORD && tok!=TK_LNKWORD) { - printf("Error: unexpected token %s as the argument of %s at line %d.\n", - tokToString(tok),tokenName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of %s", + tokToString(tok),tokenName.data()); doctokenizerYYsetStatePara(); break; } @@ -796,15 +897,15 @@ static void readTextFileByName(const QCString &file,QCString &text) } else if (ambig) { - printf("Error: included file name %s at line %d is ambigious.\n" - "Possible candidates:\n%s",file.data(),doctokenizerYYlineno, + warn(g_fileName,doctokenizerYYlineno,"Error: included file name %s is ambigious" + "Possible candidates:\n%s",file.data(), showFileDefMatches(Doxygen::exampleNameDict,file).data() ); } else { - printf("Error: included file %s at line %d is not found. " - "Check you EXAMPLE_PATH",file.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: included file %s is not found" + "Check you EXAMPLE_PATH",file.data()); } } @@ -815,7 +916,7 @@ DocAnchor::DocAnchor(DocNode *parent,const QCString &id,bool newAnchor) { if (id.isEmpty()) { - printf("Error: Empty anchor label at line %d!\n",doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Empty anchor label"); } if (newAnchor) // found { @@ -831,7 +932,7 @@ DocAnchor::DocAnchor(DocNode *parent,const QCString &id,bool newAnchor) } else { - printf("Error: Invalid anchor id `%s' at line %d\n",id.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Invalid anchor id `%s'",id.data()); } } } @@ -998,14 +1099,14 @@ void DocCopy::parse() } else // oops, recursion { - printf("Error: recursive call chain of \\copydoc commands detected at %d\n", + warn(g_fileName,doctokenizerYYlineno,"Error: recursive call chain of \\copydoc commands detected at %d\n", doctokenizerYYlineno); } } else { - printf("Error: target %s of \\copydoc command at line %d not found\n", - m_link.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: target %s of \\copydoc command not found", + m_link.data()); } } @@ -1047,7 +1148,8 @@ DocFormula::DocFormula(DocNode *parent,int id) : Formula *formula=Doxygen::formulaNameDict[formCmd]; if (formula) { - m_name.sprintf("form_%d",formula->getId()); + m_id = formula->getId(); + m_name.sprintf("form_%d",m_id); m_text = formula->getFormulaText(); } } @@ -1095,16 +1197,16 @@ void DocSecRefItem::parse() switch (tok) { case TK_COMMAND: - printf("Error: Illegal command %s as part of a \\refitem at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command %s as part of a \\refitem", + g_token->name.data()); break; case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unsupported symbol %s found", + g_token->name.data()); break; default: - printf("Error: Unexpected token %s at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", + g_token->name.data()); break; } } @@ -1123,14 +1225,13 @@ void DocSecRefItem::parse() } else { - printf("Error reference to unknown section %s at line %d\n", - m_target.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error reference to unknown section %s", + m_target.data()); } } else { - printf("Error reference to empty target at line %d\n", - doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error reference to empty target"); } DBG(("DocSecRefItem::parse() end\n")); @@ -1160,15 +1261,14 @@ void DocSecRefList::parse() int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after \\refitem command at line %d\n", - doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after \\refitem command"); break; } tok=doctokenizerYYlex(); if (tok!=TK_WORD && tok!=TK_LNKWORD) { - printf("Error: unexpected token %s as the argument of \\refitem at line %d.\n", - tokToString(tok),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of \\refitem", + tokToString(tok)); break; } @@ -1180,8 +1280,8 @@ void DocSecRefList::parse() case CMD_ENDSECREFLIST: goto endsecreflist; default: - printf("Error: Illegal command %s as part of a \\secreflist at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command %s as part of a \\secreflist", + g_token->name.data()); goto endsecreflist; } } @@ -1191,8 +1291,8 @@ void DocSecRefList::parse() } else { - printf("Error: Unexpected token %s inside section reference list at line %d\n", - tokToString(tok),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s inside section reference list", + tokToString(tok)); goto endsecreflist; } tok=doctokenizerYYlex(); @@ -1234,16 +1334,16 @@ void DocInternalRef::parse() switch (tok) { case TK_COMMAND: - printf("Error: Illegal command %s as part of a \\ref at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command %s as part of a \\ref", + g_token->name.data()); break; case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unsupported symbol %s found", + g_token->name.data()); break; default: - printf("Error: Unexpected token %s at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", + g_token->name.data()); break; } } @@ -1291,8 +1391,8 @@ DocRef::DocRef(DocNode *parent,const QCString &target) : } else // oops, bogus target { - printf("Error: unable to resolve reference to `%s' for \\ref command at line %d\n", - target.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unable to resolve reference to `%s' for \\ref command", + target.data()); } } @@ -1309,16 +1409,16 @@ void DocRef::parse() switch (tok) { case TK_COMMAND: - printf("Error: Illegal command %s as part of a \\ref at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command %s as part of a \\ref", + g_token->name.data()); break; case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unsupported symbol %s found", + g_token->name.data()); break; default: - printf("Error: Unexpected token %s at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", + g_token->name.data()); break; } } @@ -1353,8 +1453,8 @@ DocLink::DocLink(DocNode *parent,const QCString &target) : } else // oops, bogus target { - printf("Error: unable to resolve link to `%s' for \\link command at line %d\n", - target.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unable to resolve link to `%s' for \\link command", + target.data()); } } @@ -1378,19 +1478,18 @@ QCString DocLink::parse(bool isJavaLink) case CMD_ENDLINK: if (isJavaLink) { - printf("Error: {@link.. ended with @endlink command at line %d\n", - doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: {@link.. ended with @endlink command"); } goto endlink; default: - printf("Error: Illegal command %s as part of a \\ref at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command %s as part of a \\ref", + g_token->name.data()); break; } break; case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unsupported symbol %s found", + g_token->name.data()); break; case TK_LNKWORD: case TK_WORD: @@ -1416,16 +1515,16 @@ QCString DocLink::parse(bool isJavaLink) m_children.append(new DocWord(this,g_token->name)); break; default: - printf("Error: Unexpected token %s at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", + g_token->name.data()); break; } } } if (tok==0) { - printf("Error: Unexpected end of comment at line %d while inside" - " link command\n",doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected end of comment while inside" + " link command\n"); } endlink: @@ -1453,16 +1552,16 @@ void DocDotFile::parse() switch (tok) { case TK_COMMAND: - printf("Error: Illegal command %s as part of a \\dotfile at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command %s as part of a \\dotfile", + g_token->name.data()); break; case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unsupported symbol %s found", + g_token->name.data()); break; default: - printf("Error: Unexpected token %s at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", + g_token->name.data()); break; } } @@ -1480,8 +1579,8 @@ void DocDotFile::parse() } else { - printf("Error: Unknown option %s after image title at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unknown option %s after image title", + g_token->name.data()); } tok=doctokenizerYYlex(); } @@ -1497,15 +1596,15 @@ void DocDotFile::parse() } else if (ambig) { - printf("Error: included dot file name %s at line %d is ambigious.\n" - "Possible candidates:\n%s",m_name.data(),doctokenizerYYlineno, + warn(g_fileName,doctokenizerYYlineno,"Error: included dot file name %s is ambigious.\n" + "Possible candidates:\n%s",m_name.data(), showFileDefMatches(Doxygen::exampleNameDict,m_name).data() ); } else { - printf("Error: included dot file %s at line %d is not found " - "in any of the paths specified via DOTFILE_DIRS!",m_name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: included dot file %s is not found " + "in any of the paths specified via DOTFILE_DIRS!",m_name.data()); } DBG(("DocDotFile::parse() end\n")); @@ -1530,16 +1629,16 @@ void DocImage::parse() switch (tok) { case TK_COMMAND: - printf("Error: Illegal command %s as part of a \\image at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command %s as part of a \\image", + g_token->name.data()); break; case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unsupported symbol %s found", + g_token->name.data()); break; default: - printf("Error: Unexpected token %s at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", + g_token->name.data()); break; } } @@ -1557,8 +1656,8 @@ void DocImage::parse() } else { - printf("Error: Unknown option %s after image title at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unknown option %s after image title", + g_token->name.data()); } tok=doctokenizerYYlex(); } @@ -1588,8 +1687,8 @@ int DocHtmlHeader::parse() switch (tok) { case TK_COMMAND: - printf("Error: Illegal command %s as part of a tag at line %d\n", - g_token->name.data(),m_level,doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command %s as part of a tag", + g_token->name.data(),m_level); break; case TK_HTMLTAG: { @@ -1598,8 +1697,8 @@ int DocHtmlHeader::parse() { if (m_level!=1) { - printf("Error: ended with
  • at line %d\n", - m_level,doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: ended with ", + m_level); } goto endheader; } @@ -1607,8 +1706,8 @@ int DocHtmlHeader::parse() { if (m_level!=2) { - printf("Error: ended with at line %d\n", - m_level,doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: ended with ", + m_level); } goto endheader; } @@ -1616,33 +1715,33 @@ int DocHtmlHeader::parse() { if (m_level!=3) { - printf("Error: ended with at line %d\n", - m_level,doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: ended with ", + m_level); } goto endheader; } else { - printf("Error: Unexpected html tag <%s%s> found at line %d within context\n", - g_token->endTag?"/":"",g_token->name.data(),doctokenizerYYlineno,m_level); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected html tag <%s%s> found within context", + g_token->endTag?"/":"",g_token->name.data(),m_level); } } break; case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unsupported symbol %s found", + g_token->name.data()); break; default: - printf("Error: Unexpected token %s at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", + g_token->name.data()); break; } } } if (tok==0) { - printf("Error: Unexpected end of comment at line %d while inside" - " tag\n",doctokenizerYYlineno,m_level); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected end of comment while inside" + " tag\n",m_level); } endheader: handlePendingStyleCommands(this,m_children); @@ -1668,12 +1767,12 @@ int DocHRef::parse() switch (tok) { case TK_COMMAND: - printf("Error: Illegal command %s as part of a .. block at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command %s as part of a .. block", + g_token->name.data()); break; case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unsupported symbol %s found", + g_token->name.data()); break; case TK_HTMLTAG: { @@ -1684,13 +1783,13 @@ int DocHRef::parse() } else { - printf("Error: Unexpected html tag <%s%s> found at line %d within context\n", + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected html tag <%s%s> found within context", g_token->endTag?"/":"",g_token->name.data(),doctokenizerYYlineno); } } break; default: - printf("Error: Unexpected token %s at line %d\n", + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", g_token->name.data(),doctokenizerYYlineno); break; } @@ -1698,8 +1797,8 @@ int DocHRef::parse() } if (tok==0) { - printf("Error: Unexpected end of comment at line %d while inside" - " tag\n",doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected end of comment while inside" + " tag",doctokenizerYYlineno); } endhref: handlePendingStyleCommands(this,m_children); @@ -1736,7 +1835,7 @@ int DocInternal::parse() } if (retval==TK_LISTITEM) { - printf("Error: Invalid list item found at line %d!\n",doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Invalid list item found",doctokenizerYYlineno); } } while (retval!=0 && retval!=RetVal_Section); if (lastPar) lastPar->markLast(); @@ -1748,7 +1847,7 @@ int DocInternal::parse() int secLev = sec->type==SectionInfo::Subsection ? 2 : 1; if (secLev!=1) // wrong level { - printf("Error: Expected level 1 section, found a section with level %d at line %d.\n",secLev,doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Expected level 1 section, found a section with level %d.",secLev); break; } else @@ -1761,7 +1860,7 @@ int DocInternal::parse() if (retval==RetVal_Internal) { - printf("Error: \\internal command found inside internal section\n"); + warn(g_fileName,doctokenizerYYlineno,"Error: \\internal command found inside internal section"); } DBG(("DocInternal::parse() end\n")); @@ -1780,35 +1879,66 @@ int DocIndexEntry::parse() int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after \\addindex command at line %d\n", - doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after \\addindex command"); goto endindexentry; } + m_entry.resize(0); while ((tok=doctokenizerYYlex()) && tok!=TK_WHITESPACE && tok!=TK_NEWPARA) { - if (!defaultHandleToken(this,tok,m_children)) + switch (tok) { - switch (tok) + case TK_WORD: + case TK_LNKWORD: + m_entry+=g_token->name; + break; + case TK_SYMBOL: + { + char letter='\0'; + DocSymbol::SymType s = DocSymbol::decodeSymbol(g_token->name,&letter); + switch (s) + { + case DocSymbol::BSlash: m_entry+='\\'; break; + case DocSymbol::At: m_entry+='@'; break; + case DocSymbol::Less: m_entry+='<'; break; + case DocSymbol::Greater: m_entry+='>'; break; + case DocSymbol::Amp: m_entry+='&'; break; + case DocSymbol::Dollar: m_entry+='$'; break; + case DocSymbol::Hash: m_entry+='#'; break; + case DocSymbol::Percent: m_entry+='%'; break; + case DocSymbol::Apos: m_entry+='\''; break; + case DocSymbol::Quot: m_entry+='"'; break; + default: + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected symbol found as argument of \\addindex"); + break; + } + } + break; + case TK_COMMAND: + switch (CmdMapper::map(g_token->name)) { - case TK_COMMAND: - printf("Error: Illegal command %s as part of a \\addindex at line %d\n", - g_token->name.data(),doctokenizerYYlineno); - break; - case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); - break; + case CMD_BSLASH: m_entry+='\\'; break; + case CMD_AT: m_entry+='@'; break; + case CMD_LESS: m_entry+='<'; break; + case CMD_GREATER: m_entry+='>'; break; + case CMD_AMP: m_entry+='&'; break; + case CMD_DOLLAR: m_entry+='$'; break; + case CMD_HASH: m_entry+='#'; break; + case CMD_PERCENT: m_entry+='%'; break; default: - printf("Error: Unexpected token %s at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected command %s found as argument of \\addindex", + g_token->name.data()); break; } + break; + default: + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", + g_token->name.data()); + break; } } if (tok!=TK_WHITESPACE) retval=tok; endindexentry: - handlePendingStyleCommands(this,m_children); - DBG(("DocIndexEntry::parse() end\n")); + DBG(("DocIndexEntry::parse() end retval=%x\n",retval)); DocNode *n=g_nodeStack.pop(); ASSERT(n==this); return retval; @@ -1829,12 +1959,12 @@ int DocHtmlCaption::parse() switch (tok) { case TK_COMMAND: - printf("Error: Illegal command %s as part of a tag at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command %s as part of a tag", + g_token->name.data()); break; case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unsupported symbol %s found", + g_token->name.data()); break; case TK_HTMLTAG: { @@ -1846,22 +1976,22 @@ int DocHtmlCaption::parse() } else { - printf("Error: Unexpected html tag <%s%s> found at line %d within context\n", - g_token->endTag?"/":"",g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected html tag <%s%s> found within context", + g_token->endTag?"/":"",g_token->name.data()); } } break; default: - printf("Error: Unexpected token %s at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", + g_token->name.data()); break; } } } if (tok==0) { - printf("Error: Unexpected end of comment at line %d while inside" - " tag\n",doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected end of comment while inside" + " tag",doctokenizerYYlineno); } endcaption: handlePendingStyleCommands(this,m_children); @@ -1927,21 +2057,21 @@ int DocHtmlRow::parse() } else // found some other tag { - printf("Error: expected or tag at line %d but " - "found <%s> instead!\n",doctokenizerYYlineno,g_token->name.data()); + warn(g_fileName,doctokenizerYYlineno,"Error: expected or tag but " + "found <%s> instead!",g_token->name.data()); goto endrow; } } else if (tok==0) // premature end of comment { - printf("Error: unexpected end of comment at line %d while looking" - " for a html description title\n",doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment while looking" + " for a html description title"); goto endrow; } else // token other than html token { - printf("Error: expected or tag at line %d but found %s token instead!\n", - doctokenizerYYlineno,tokToString(tok)); + warn(g_fileName,doctokenizerYYlineno,"Error: expected or tag but found %s token instead!", + tokToString(tok)); goto endrow; } @@ -1991,8 +2121,7 @@ getrow: { if (m_caption) { - printf("Error: table already has a caption, found another one at line %d\n", - doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: table already has a caption, found another one"); } else { @@ -2007,20 +2136,19 @@ getrow: } else // found wrong token { - printf("Error: expected or tag at line %d but " - "found <%s%s> instead!\n",doctokenizerYYlineno, - g_token->endTag ? "/" : "", g_token->name.data()); + warn(g_fileName,doctokenizerYYlineno,"Error: expected or tag but " + "found <%s%s> instead!", g_token->endTag ? "/" : "", g_token->name.data()); } } else if (tok==0) // premature end of comment { - printf("Error: unexpected end of comment at line %d while looking" - " for a or tag\n",doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment while looking" + " for a or tag"); } else // token other than html token { - printf("Error: expected tag at line %d but found %s token instead!\n", - doctokenizerYYlineno,tokToString(tok)); + warn(g_fileName,doctokenizerYYlineno,"Error: expected tag but found %s token instead!", + tokToString(tok)); } // parse one or more rows @@ -2053,12 +2181,12 @@ int DocHtmlDescTitle::parse() switch (tok) { case TK_COMMAND: - printf("Error: Illegal command %s as part of a
    tag at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command %s as part of a
    tag", + g_token->name.data()); break; case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unsupported symbol %s found", + g_token->name.data()); break; case TK_HTMLTAG: { @@ -2074,22 +2202,22 @@ int DocHtmlDescTitle::parse() } else { - printf("Error: Unexpected html tag <%s%s> found at line %d within
    context\n", - g_token->endTag?"/":"",g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected html tag <%s%s> found within
    context", + g_token->endTag?"/":"",g_token->name.data()); } } break; default: - printf("Error: Unexpected token %s at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", + g_token->name.data()); break; } } } if (tok==0) { - printf("Error: Unexpected end of comment at line %d while inside" - "
    tag\n",doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected end of comment while inside" + "
    tag"); } endtitle: handlePendingStyleCommands(this,m_children); @@ -2147,21 +2275,21 @@ int DocHtmlDescList::parse() } else // found some other tag { - printf("Error: expected
    tag at line %d but " - "found <%s> instead!\n",doctokenizerYYlineno,g_token->name.data()); + warn(g_fileName,doctokenizerYYlineno,"Error: expected
    tag but " + "found <%s> instead!",g_token->name.data()); goto enddesclist; } } else if (tok==0) // premature end of comment { - printf("Error: unexpected end of comment at line %d while looking" - " for a html description title\n",doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment while looking" + " for a html description title"); goto enddesclist; } else // token other than html token { - printf("Error: expected
    tag at line %d but found %s token instead!\n", - doctokenizerYYlineno,tokToString(tok)); + warn(g_fileName,doctokenizerYYlineno,"Error: expected
    tag but found %s token instead!", + tokToString(tok)); goto enddesclist; } @@ -2185,8 +2313,7 @@ int DocHtmlDescList::parse() if (retval==0) { - printf("Error: unexpected end of comment at line %d while inside
    block\n", - doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment while inside
    block"); } enddesclist: @@ -2270,21 +2397,21 @@ int DocHtmlList::parse() } else // found some other tag { - printf("Error: expected
  • tag at line %d but " - "found <%s> instead!\n",doctokenizerYYlineno,g_token->name.data()); + warn(g_fileName,doctokenizerYYlineno,"Error: expected
  • tag but " + "found <%s> instead!",g_token->name.data()); goto endlist; } } else if (tok==0) // premature end of comment { - printf("Error: unexpected end of comment at line %d while looking" - " for a html list item\n",doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment while looking" + " for a html list item"); goto endlist; } else // token other than html token { - printf("Error: expected
  • tag at line %d but found %s token instead!\n", - doctokenizerYYlineno,tokToString(tok)); + warn(g_fileName,doctokenizerYYlineno,"Error: expected
  • tag but found %s token instead!", + tokToString(tok)); goto endlist; } @@ -2297,8 +2424,8 @@ int DocHtmlList::parse() if (retval==0) { - printf("Error: unexpected end of comment at line %d while inside <%cl> block\n", - doctokenizerYYlineno,m_type==Unordered ? 'u' : 'o'); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment while inside <%cl> block", + m_type==Unordered ? 'u' : 'o'); } endlist: @@ -2390,16 +2517,16 @@ void DocTitle::parse() switch (tok) { case TK_COMMAND: - printf("Error: Illegal command %s as part of a title section at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Illegal command %s as part of a title section", + g_token->name.data()); break; case TK_SYMBOL: - printf("Error: Unsupported symbol %s found at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unsupported symbol %s found", + g_token->name.data()); break; default: - printf("Error: Unexpected token %s at line %d\n", - g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s", + g_token->name.data()); break; } } @@ -2480,21 +2607,31 @@ int DocParamList::parse(const QCString &cmdName) int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + cmdName.data()); } doctokenizerYYsetStateParam(); tok=doctokenizerYYlex(); while (tok==TK_WORD) /* there is a parameter name */ { + if (m_type==DocParamSect::Param) + { + g_hasParamCommand=TRUE; + checkArgumentName(g_token->name,TRUE); + } + else if (m_type==DocParamSect::RetVal) + { + g_hasParamCommand=TRUE; + checkArgumentName(g_token->name,FALSE); + } m_params.append(g_token->name); tok=doctokenizerYYlex(); } doctokenizerYYsetStatePara(); if (tok==0) /* premature end of comment block */ { - printf("Error: unexpected end of comment block at line %d while parsing the " - "argument of command %s\n",doctokenizerYYlineno, cmdName.data()); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment block while parsing the " + "argument of command %s",cmdName.data()); return 0; } ASSERT(tok==TK_WHITESPACE); @@ -2517,7 +2654,7 @@ int DocParamSect::parse(const QCString &cmdName) DBG(("DocParamSect::parse() start\n")); g_nodeStack.push(this); - DocParamList *pl = new DocParamList(this); + DocParamList *pl = new DocParamList(this,m_type); m_children.append(pl); retval = pl->parse(cmdName); @@ -2590,8 +2727,8 @@ void DocPara::handleIncludeOperator(const QCString &cmdName,DocIncOperator::Type int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + cmdName.data()); return; } doctokenizerYYsetStatePattern(); @@ -2599,14 +2736,14 @@ void DocPara::handleIncludeOperator(const QCString &cmdName,DocIncOperator::Type doctokenizerYYsetStatePara(); if (tok==0) { - printf("Error: unexpected end of comment block at line %d while parsing the " - "argument of command %s\n",doctokenizerYYlineno, cmdName.data()); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment block while parsing the " + "argument of command %s", cmdName.data()); return; } else if (tok!=TK_WORD) { - printf("Error: unexpected token %s as the argument of %s at line %d.\n", - tokToString(tok),cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of %s", + tokToString(tok),cmdName.data()); return; } DocIncOperator *op = new DocIncOperator(this,t,g_token->name,g_context); @@ -2640,22 +2777,22 @@ void DocPara::handleImage(const QCString &cmdName) int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + cmdName.data()); return; } tok=doctokenizerYYlex(); if (tok!=TK_WORD && tok!=TK_LNKWORD) { - printf("Error: unexpected token %s as the argument of %s at line %d.\n", - tokToString(tok),cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of %s", + tokToString(tok),cmdName.data()); return; } tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + cmdName.data()); return; } DocImage::Type t; @@ -2665,17 +2802,17 @@ void DocPara::handleImage(const QCString &cmdName) else if (imgType=="rtf") t=DocImage::Rtf; else { - printf("Error: image type %s specified as the first argument of " - "%s at line %d is not valid.\n", - imgType.data(),cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: image type %s specified as the first argument of " + "%s is not valid", + imgType.data(),cmdName.data()); return; } doctokenizerYYsetStateFile(); tok=doctokenizerYYlex(); if (tok!=TK_WORD) { - printf("Error: unexpected token %s as the argument of %s at line %d.\n", - tokToString(tok),cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of %s", + tokToString(tok),cmdName.data()); return; } doctokenizerYYsetStatePara(); @@ -2689,16 +2826,16 @@ void DocPara::handleDotFile(const QCString &cmdName) int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + cmdName.data()); return; } doctokenizerYYsetStateFile(); tok=doctokenizerYYlex(); if (tok!=TK_WORD) { - printf("Error: unexpected token %s as the argument of %s at line %d.\n", - tokToString(tok),cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of %s", + tokToString(tok),cmdName.data()); return; } doctokenizerYYsetStatePara(); @@ -2712,16 +2849,16 @@ void DocPara::handleLink(const QCString &cmdName,bool isJavaLink) int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + cmdName.data()); return; } doctokenizerYYsetStateLink(); tok=doctokenizerYYlex(); if (tok!=TK_WORD) { - printf("Error: unexpected token %s as the argument of %s at line %d.\n", - tokToString(tok),cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of %s", + tokToString(tok),cmdName.data()); return; } doctokenizerYYsetStatePara(); @@ -2739,8 +2876,8 @@ void DocPara::handleRef(const QCString &cmdName) int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + cmdName.data()); return; } doctokenizerYYsetStateRef(); @@ -2748,8 +2885,8 @@ void DocPara::handleRef(const QCString &cmdName) DocRef *ref=0; if (tok!=TK_WORD) { - printf("Error: unexpected token %s as the argument of %s at line %d.\n", - tokToString(tok),cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of %s", + tokToString(tok),cmdName.data()); goto endref; } ref = new DocRef(this,g_token->name); @@ -2789,8 +2926,8 @@ int DocPara::handleLanguageSwitch() } else { - printf("Error: Unexpected token %s as parameter of \\~ at line %d\n", - tokToString(tok),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Unexpected token %s as parameter of \\~", + tokToString(tok)); goto endlang; } } @@ -2809,8 +2946,8 @@ void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t) int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + cmdName.data()); return; } doctokenizerYYsetStateFile(); @@ -2818,14 +2955,14 @@ void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t) doctokenizerYYsetStatePara(); if (tok==0) { - printf("Error: unexpected end of comment block at line %d while parsing the " - "argument of command %s\n",doctokenizerYYlineno, cmdName.data()); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment block while parsing the " + "argument of command %s",cmdName.data()); return; } else if (tok!=TK_WORD) { - printf("Error: unexpected token %s as the argument of %s at line %d.\n", - tokToString(tok),cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of %s", + tokToString(tok),cmdName.data()); return; } DocInclude *inc = new DocInclude(this,g_token->name,g_context,t); @@ -2840,7 +2977,7 @@ int DocPara::handleCommand(const QCString &cmdName) switch (CmdMapper::map(cmdName)) { case CMD_UNKNOWN: - printf("Error: Found unknown command `\\%s' at line %d\n",cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: Found unknown command `\\%s'",cmdName.data()); break; case CMD_EMPHASIS: m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,TRUE)); @@ -2941,21 +3078,21 @@ int DocPara::handleCommand(const QCString &cmdName) int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + cmdName.data()); break; } tok=doctokenizerYYlex(); if (tok==0) { - printf("Error: unexpected end of comment block at line %d while parsing the " - "argument of command %s\n",doctokenizerYYlineno, cmdName.data()); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment block while parsing the " + "argument of command %s\n", cmdName.data()); break; } else if (tok!=TK_WORD && tok!=TK_LNKWORD) { - printf("Error: unexpected token %s as the argument of %s at line %d.\n", - tokToString(tok),cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of %s", + tokToString(tok),cmdName.data()); break; } g_token->sectionId = g_token->name; @@ -2967,8 +3104,7 @@ int DocPara::handleCommand(const QCString &cmdName) doctokenizerYYsetStateCode(); retval = doctokenizerYYlex(); m_children.append(new DocVerbatim(this,g_context,g_token->verb,DocVerbatim::Code)); - if (retval==0) printf("Error: code section ended without end marker at line %d\n", - doctokenizerYYlineno); + if (retval==0) warn(g_fileName,doctokenizerYYlineno,"Error: code section ended without end marker"); doctokenizerYYsetStatePara(); } break; @@ -2977,8 +3113,7 @@ int DocPara::handleCommand(const QCString &cmdName) doctokenizerYYsetStateHtmlOnly(); retval = doctokenizerYYlex(); m_children.append(new DocVerbatim(this,g_context,g_token->verb,DocVerbatim::HtmlOnly)); - if (retval==0) printf("Error: htmlonly section ended without end marker at line %d\n", - doctokenizerYYlineno); + if (retval==0) warn(g_fileName,doctokenizerYYlineno,"Error: htmlonly section ended without end marker"); doctokenizerYYsetStatePara(); } break; @@ -2987,8 +3122,7 @@ int DocPara::handleCommand(const QCString &cmdName) doctokenizerYYsetStateLatexOnly(); retval = doctokenizerYYlex(); m_children.append(new DocVerbatim(this,g_context,g_token->verb,DocVerbatim::LatexOnly)); - if (retval==0) printf("Error: latexonly section ended without end marker at line %d\n", - doctokenizerYYlineno); + if (retval==0) warn(g_fileName,doctokenizerYYlineno,"Error: latexonly section ended without end marker"); doctokenizerYYsetStatePara(); } break; @@ -2997,8 +3131,7 @@ int DocPara::handleCommand(const QCString &cmdName) doctokenizerYYsetStateVerbatim(); retval = doctokenizerYYlex(); m_children.append(new DocVerbatim(this,g_context,g_token->verb,DocVerbatim::Verbatim)); - if (retval==0) printf("Error: verbatim section ended without end marker at line %d\n", - doctokenizerYYlineno); + if (retval==0) warn(g_fileName,doctokenizerYYlineno,"Error: verbatim section ended without end marker"); doctokenizerYYsetStatePara(); } break; @@ -3007,7 +3140,7 @@ int DocPara::handleCommand(const QCString &cmdName) case CMD_ENDLATEXONLY: case CMD_ENDLINK: case CMD_ENDVERBATIM: - printf("Error: unexpected command %s at line %d\n",g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected command %s",g_token->name.data()); break; case CMD_PARAM: retval = handleParamSection(cmdName,DocParamSect::Param); @@ -3041,21 +3174,21 @@ int DocPara::handleCommand(const QCString &cmdName) int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + cmdName.data()); break; } tok=doctokenizerYYlex(); if (tok==0) { - printf("Error: unexpected end of comment block at line %d while parsing the " - "argument of command %s\n",doctokenizerYYlineno, cmdName.data()); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment block while parsing the " + "argument of command %s",cmdName.data()); break; } else if (tok!=TK_WORD && tok!=TK_LNKWORD) { - printf("Error: unexpected token %s as the argument of %s at line %d.\n", - tokToString(tok),cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of %s", + tokToString(tok),cmdName.data()); break; } DocAnchor *anchor = new DocAnchor(this,g_token->name,FALSE); @@ -3077,21 +3210,21 @@ int DocPara::handleCommand(const QCString &cmdName) int tok=doctokenizerYYlex(); if (tok!=TK_WHITESPACE) { - printf("Error: expected whitespace after %s command at line %d\n", - cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: expected whitespace after %s command", + cmdName.data()); break; } tok=doctokenizerYYlex(); if (tok==0) { - printf("Error: unexpected end of comment block at line %d while parsing the " - "argument of command %s\n",doctokenizerYYlineno, cmdName.data()); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected end of comment block while parsing the " + "argument of command %s\n", cmdName.data()); break; } else if (tok!=TK_WORD && tok!=TK_LNKWORD) { - printf("Error: unexpected token %s as the argument of %s at line %d.\n", - tokToString(tok),cmdName.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected token %s as the argument of %s", + tokToString(tok),cmdName.data()); break; } DocCopy *cpy = new DocCopy(this,g_token->name); @@ -3146,10 +3279,10 @@ int DocPara::handleCommand(const QCString &cmdName) } break; case CMD_SECREFITEM: - printf("Error: unexpected command %s at line %d\n",g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected command %s",g_token->name.data()); break; case CMD_ENDSECREFLIST: - printf("Error: unexpected command %s at line %d\n",g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected command %s",g_token->name.data()); break; case CMD_FORMULA: { @@ -3161,7 +3294,7 @@ int DocPara::handleCommand(const QCString &cmdName) retval = handleLanguageSwitch(); break; case CMD_INTERNALREF: - printf("Error: unexpected command %s at line %d\n",g_token->name.data(),doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: unexpected command %s",g_token->name.data()); break; default: // we should not get here! @@ -3201,7 +3334,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const QList
  • tag found at line %d\n",doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: lonely
  • tag found"); } else { @@ -3250,8 +3383,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const QList
    found"); break; case HTML_TABLE: { @@ -3270,8 +3402,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const QList tag at line %d with name option but without value!\n", - doctokenizerYYlineno); + warn(g_fileName,doctokenizerYYlineno,"Error: found tag with name option but without value!"); } } else if (opt->name=="href") // .. tag @@ -3356,8 +3486,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const QList
  • \n
    "; doc += item->text; doc += "
    \n"; - addRelatedPage(refList->listName(),refList->pageTitle(),doc,0,"generated",1,0,0,0); + addRelatedPage(refList->listName(),refList->pageTitle(),doc,0,refList->listName(),1,0,0,0); item->written=TRUE; } } @@ -3937,7 +3937,7 @@ QCString rtfFormatBmkStr(const char *name) { if ( ( ++(*nxtTag) ) > 'Z' ) { - (*nxtTag) = 'A'; + *nxtTag = 'A'; } else { diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp new file mode 100644 index 0000000..d65d2fa --- /dev/null +++ b/src/xmldocvisitor.cpp @@ -0,0 +1,737 @@ +/****************************************************************************** + * + * + * + * + * Copyright (C) 1997-2002 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + +#include "xmldocvisitor.h" +#include "docparser.h" +#include "language.h" +#include "doxygen.h" +#include "outputgen.h" +#include "xmlgen.h" +#include "code.h" +#include "dot.h" +#include "message.h" + +XmlDocVisitor::XmlDocVisitor(QTextStream &t,BaseCodeDocInterface &ci) + : m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) +{ +} + + //-------------------------------------- + // visitor functions for leaf nodes + //-------------------------------------- + +void XmlDocVisitor::visit(DocWord *w) +{ + if (m_hide) return; + filter(w->word()); +} + +void XmlDocVisitor::visit(DocLinkedWord *w) +{ + if (m_hide) return; + startLink(w->ref(),w->file(),w->anchor()); + filter(w->word()); + endLink(); +} + +void XmlDocVisitor::visit(DocWhiteSpace *w) +{ + if (m_hide) return; + if (m_insidePre) + { + m_t << w->chars(); + } + else + { + m_t << " "; + } +} + +void XmlDocVisitor::visit(DocSymbol *s) +{ + if (m_hide) return; + switch(s->symbol()) + { + case DocSymbol::BSlash: m_t << "\\"; break; + case DocSymbol::At: m_t << "@"; break; + case DocSymbol::Less: m_t << "<"; break; + case DocSymbol::Greater: m_t << ">"; break; + case DocSymbol::Amp: m_t << "&"; break; + case DocSymbol::Dollar: m_t << "$"; break; + case DocSymbol::Hash: m_t << "#"; break; + case DocSymbol::Percent: m_t << "%"; break; + case DocSymbol::Copy: m_t << ""; break; + case DocSymbol::Apos: m_t << "'"; break; + case DocSymbol::Quot: m_t << "\""; break; + case DocSymbol::Uml: m_t << "letter() << "\"/>"; break; + case DocSymbol::Acute: m_t << "letter() << "\"/>"; break; + case DocSymbol::Grave: m_t << "letter() << "\"/>"; break; + case DocSymbol::Circ: m_t << "letter() << "\"/>"; break; + case DocSymbol::Tilde: m_t << "letter() << "\"/>"; break; + case DocSymbol::Szlig: m_t << ""; break; + case DocSymbol::Cedil: m_t << "letter() << "\"/>"; break; + case DocSymbol::Ring: m_t << "letter() << "\"/>"; break; + case DocSymbol::Nbsp: m_t << ""; break; + default: + err("Error: unknown symbol found\n"); + } +} + +void XmlDocVisitor::visit(DocURL *u) +{ + if (m_hide) return; + m_t << "url() << "\">"; + filter(u->url()); + m_t << ""; +} + +void XmlDocVisitor::visit(DocLineBreak *) +{ + if (m_hide) return; + m_t << "\n"; +} + +void XmlDocVisitor::visit(DocHorRuler *) +{ + if (m_hide) return; + m_t << "\n"; +} + +void XmlDocVisitor::visit(DocStyleChange *s) +{ + if (m_hide) return; + switch (s->style()) + { + case DocStyleChange::Bold: + if (s->enable()) m_t << ""; else m_t << " "; + break; + case DocStyleChange::Italic: + if (s->enable()) m_t << ""; else m_t << " "; + break; + case DocStyleChange::Code: + if (s->enable()) m_t << ""; else m_t << " "; + break; + case DocStyleChange::Subscript: + if (s->enable()) m_t << ""; else m_t << " "; + break; + case DocStyleChange::Superscript: + if (s->enable()) m_t << ""; else m_t << " "; + break; + case DocStyleChange::Center: + if (s->enable()) m_t << "
    "; else m_t << "
    "; + break; + case DocStyleChange::Small: + if (s->enable()) m_t << ""; else m_t << " "; + break; + } +} + +void XmlDocVisitor::visit(DocVerbatim *s) +{ + if (m_hide) return; + switch(s->type()) + { + case DocVerbatim::Code: // fall though + m_t << ""; + parseCode(m_ci,s->context(),s->text(),FALSE,0); + m_t << ""; + break; + case DocVerbatim::Verbatim: + m_t << ""; + filter(s->text()); + m_t << ""; + break; + case DocVerbatim::HtmlOnly: + m_t << ""; + filter(s->text()); + m_t << ""; + break; + case DocVerbatim::LatexOnly: + m_t << ""; + filter(s->text()); + m_t << ""; + break; + } +} + +void XmlDocVisitor::visit(DocAnchor *anc) +{ + if (m_hide) return; + m_t << "file() << "_1" << anc->anchor() << "\"/>"; +} + +void XmlDocVisitor::visit(DocInclude *inc) +{ + if (m_hide) return; + switch(inc->type()) + { + case DocInclude::Include: + m_t << ""; + parseCode(m_ci,inc->context(),inc->text(),FALSE,0); + m_t << ""; + break; + case DocInclude::DontInclude: + break; + case DocInclude::HtmlInclude: + m_t << ""; + filter(inc->text()); + m_t << ""; + break; + case DocInclude::VerbInclude: + m_t << ""; + filter(inc->text()); + m_t << ""; + break; + } +} + +void XmlDocVisitor::visit(DocIncOperator *op) +{ + //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n", + // op->type(),op->isFirst(),op->isLast(),op->text().data()); + if (op->isFirst()) + { + m_t << ""; + m_hide = TRUE; + } + if (op->type()!=DocIncOperator::Skip) + { + parseCode(m_ci,op->context(),op->text(),FALSE,0); + } + if (op->isLast()) + { + m_hide = FALSE; + m_t << ""; + } + else + { + m_t << endl; + } +} + +void XmlDocVisitor::visit(DocFormula *f) +{ + if (m_hide) return; + m_t << "id() << "\">"; + filter(f->text()); + m_t << ""; +} + +void XmlDocVisitor::visit(DocIndexEntry *ie) +{ + m_t << "" + ""; + filter(ie->entry()); + m_t << "" + "" + ""; +} + +//-------------------------------------- +// visitor functions for compound nodes +//-------------------------------------- + +void XmlDocVisitor::visitPre(DocAutoList *l) +{ + if (l->isEnumList()) + { + m_t << "\n"; + } + else + { + m_t << "\n"; + } +} + +void XmlDocVisitor::visitPost(DocAutoList *l) +{ + if (l->isEnumList()) + { + m_t << "\n"; + } + else + { + m_t << "\n"; + } +} + +void XmlDocVisitor::visitPre(DocAutoListItem *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPost(DocAutoListItem *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPre(DocPara *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPost(DocPara *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPre(DocRoot *) +{ + //m_t << "

    New parser:

    \n"; +} + +void XmlDocVisitor::visitPost(DocRoot *) +{ + //m_t << "

    Old parser:

    \n"; +} + +void XmlDocVisitor::visitPre(DocSimpleSect *s) +{ + m_t << ""; + switch(s->type()) + { + case DocSimpleSect::See: + m_t << "see"; break; + case DocSimpleSect::Return: + m_t << "return"; break; + case DocSimpleSect::Author: + m_t << "author"; break; + case DocSimpleSect::Authors: + m_t << "authors"; break; + case DocSimpleSect::Version: + m_t << "version"; break; + case DocSimpleSect::Since: + m_t << "since"; break; + case DocSimpleSect::Date: + m_t << "date"; break; + case DocSimpleSect::Note: + m_t << "bug"; break; + case DocSimpleSect::Warning: + m_t << "warning"; break; + case DocSimpleSect::Pre: + m_t << "pre"; break; + case DocSimpleSect::Post: + m_t << "post"; break; + case DocSimpleSect::Invar: + m_t << "invariant"; break; + case DocSimpleSect::Remark: + m_t << "remark"; break; + case DocSimpleSect::Attention: + m_t << "attention"; break; + case DocSimpleSect::User: + m_t << "par"; break; + case DocSimpleSect::Unknown: break; + } + m_t << "\">"; +} + +void XmlDocVisitor::visitPost(DocSimpleSect *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPre(DocTitle *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPost(DocTitle *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPre(DocSimpleList *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPost(DocSimpleList *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPre(DocSimpleListItem *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPost(DocSimpleListItem *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPre(DocSection *s) +{ + m_t << "level()+1 << ">"; + filter(s->title()); + m_t << "level()+1 << ">\n"; +} + +void XmlDocVisitor::visitPost(DocSection *) +{ +} + +void XmlDocVisitor::visitPre(DocHtmlList *s) +{ + if (s->type()==DocHtmlList::Ordered) + m_t << "\n"; + else + m_t << "\n"; +} + +void XmlDocVisitor::visitPost(DocHtmlList *s) +{ + if (s->type()==DocHtmlList::Ordered) + m_t << "\n"; + else + m_t << "\n"; +} + +void XmlDocVisitor::visitPre(DocHtmlListItem *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPost(DocHtmlListItem *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPre(DocHtmlPre *) +{ + m_t << "\n"; + m_insidePre=TRUE; +} + +void XmlDocVisitor::visitPost(DocHtmlPre *) +{ + m_insidePre=FALSE; + m_t << "\n"; +} + +void XmlDocVisitor::visitPre(DocHtmlDescList *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPost(DocHtmlDescList *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPre(DocHtmlDescTitle *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPost(DocHtmlDescTitle *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPre(DocHtmlDescData *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPost(DocHtmlDescData *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPre(DocHtmlTable *t) +{ + m_t << "numRows() + << "\" cols=\"" << t->numCols() << "\">" ; +} + +void XmlDocVisitor::visitPost(DocHtmlTable *) +{ + m_t << "
    \n"; +} + +void XmlDocVisitor::visitPre(DocHtmlRow *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPost(DocHtmlRow *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPre(DocHtmlCell *c) +{ + if (c->isHeading()) m_t << ""; else m_t << ""; +} + +void XmlDocVisitor::visitPost(DocHtmlCell *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPre(DocHtmlCaption *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPost(DocHtmlCaption *) +{ + m_t << "\n"; +} + +void XmlDocVisitor::visitPre(DocInternal *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPost(DocInternal *) +{ + m_t << "" << endl; +} + +void XmlDocVisitor::visitPre(DocHRef *href) +{ + m_t << "url() << "\">"; +} + +void XmlDocVisitor::visitPost(DocHRef *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPre(DocHtmlHeader *header) +{ + m_t << "level() << ">"; +} + +void XmlDocVisitor::visitPost(DocHtmlHeader *header) +{ + m_t << "level() << ">\n"; +} + +void XmlDocVisitor::visitPre(DocImage *img) +{ + m_t << "type()) + { + case DocImage::Html: m_t << "html"; break; + case DocImage::Latex: m_t << "latex"; break; + case DocImage::Rtf: m_t << "rtf"; break; + } + m_t << "\""; + + QCString baseName=img->name(); + int i; + if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1) + { + baseName=baseName.right(baseName.length()-i-1); + } + m_t << " name=\"" << baseName << "\""; + if (!img->width().isEmpty()) + { + m_t << " width=\""; + filter(img->width()); + m_t << "\""; + } + else if (!img->height().isEmpty()) + { + m_t << " height=\""; + filter(img->height()); + m_t << "\""; + } + m_t << ">"; +} + +void XmlDocVisitor::visitPost(DocImage *) +{ + m_t << "" << endl; +} + +void XmlDocVisitor::visitPre(DocDotFile *df) +{ + m_t << "file() << "\">"; +} + +void XmlDocVisitor::visitPost(DocDotFile *) +{ + m_t << "" << endl; +} + +void XmlDocVisitor::visitPre(DocLink *lnk) +{ + startLink(lnk->ref(),lnk->file(),lnk->anchor()); +} + +void XmlDocVisitor::visitPost(DocLink *) +{ + endLink(); +} + +void XmlDocVisitor::visitPre(DocRef *ref) +{ + startLink(ref->ref(),ref->file(),ref->anchor()); + if (!ref->hasLinkText()) filter(ref->targetTitle()); +} + +void XmlDocVisitor::visitPost(DocRef *) +{ + endLink(); + m_t << " "; +} + +void XmlDocVisitor::visitPre(DocSecRefItem *ref) +{ + m_t << "file() << "_1" << ref->anchor() << "\">"; +} + +void XmlDocVisitor::visitPost(DocSecRefItem *) +{ + m_t << "" << endl; +} + +void XmlDocVisitor::visitPre(DocSecRefList *) +{ + m_t << "" << endl; +} + +void XmlDocVisitor::visitPost(DocSecRefList *) +{ + m_t << "" << endl; +} + +void XmlDocVisitor::visitPre(DocLanguage *l) +{ + m_t << "id() << "\">"; +} + +void XmlDocVisitor::visitPost(DocLanguage *) +{ + m_t << "" << endl; +} + +void XmlDocVisitor::visitPre(DocParamSect *s) +{ + m_t << "type()) + { + case DocParamSect::Param: + m_t << "param"; break; + case DocParamSect::RetVal: + m_t << "retval"; break; + case DocParamSect::Exception: + m_t << "exception"; break; + default: + ASSERT(0); + } + m_t << "\">"; +} + +void XmlDocVisitor::visitPost(DocParamSect *) +{ + m_t << "" << endl; +} + +void XmlDocVisitor::visitPre(DocParamList *pl) +{ + QStrListIterator li(pl->parameters()); + const char *s; + for (li.toFirst();(s=li.current());++li) + { + m_t << ""; + filter(s); + m_t << "" << endl; + } + m_t << "" << endl; +} + +void XmlDocVisitor::visitPost(DocParamList *) +{ + m_t << ""; +} + +void XmlDocVisitor::visitPre(DocXRefItem *x) +{ + m_t << "file() << "_1" << x->anchor(); + m_t << "\">"; + m_t << ""; + filter(x->title()); + m_t << ""; + m_t << ""; +} + +void XmlDocVisitor::visitPost(DocXRefItem *) +{ + m_t << ""; + m_t << ""; +} + +void XmlDocVisitor::visitPre(DocInternalRef *ref) +{ + startLink(0,ref->file(),ref->anchor()); +} + +void XmlDocVisitor::visitPost(DocInternalRef *) +{ + endLink(); + m_t << " "; +} + +void XmlDocVisitor::visitPre(DocCopy *) +{ +} + +void XmlDocVisitor::visitPost(DocCopy *) +{ +} + +void XmlDocVisitor::filter(const char *str) +{ + if (str==0) return; + const char *p=str; + char c; + while (*p) + { + c=*p++; + switch(c) + { + case '<': m_t << "<"; break; + case '>': m_t << ">"; break; + case '&': m_t << "&"; break; + default: m_t << c; + } + } +} + +void XmlDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor) +{ + m_t << ""; +} + +void XmlDocVisitor::endLink() +{ + m_t << ""; +} + diff --git a/src/xmldocvisitor.h b/src/xmldocvisitor.h new file mode 100644 index 0000000..381c2b6 --- /dev/null +++ b/src/xmldocvisitor.h @@ -0,0 +1,147 @@ +/****************************************************************************** + * + * + * + * + * Copyright (C) 1997-2002 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + +#ifndef _XMLDOCVISITOR_H +#define _XMLDOCVISITOR_H + +#include "docvisitor.h" + +class QTextStream; +class BaseCodeDocInterface; +class QCString; + +/*! @brief Concrete visitor implementation for HTML output. */ +class XmlDocVisitor : public DocVisitor +{ + public: + XmlDocVisitor(QTextStream &t,BaseCodeDocInterface &ci); + + //-------------------------------------- + // visitor functions for leaf nodes + //-------------------------------------- + + void visit(DocWord *); + void visit(DocLinkedWord *); + void visit(DocWhiteSpace *); + void visit(DocSymbol *); + void visit(DocURL *); + void visit(DocLineBreak *); + void visit(DocHorRuler *); + void visit(DocStyleChange *); + void visit(DocVerbatim *); + void visit(DocAnchor *); + void visit(DocInclude *); + void visit(DocIncOperator *); + void visit(DocFormula *); + void visit(DocIndexEntry *); + + //-------------------------------------- + // visitor functions for compound nodes + //-------------------------------------- + + void visitPre(DocAutoList *); + void visitPost(DocAutoList *); + void visitPre(DocAutoListItem *); + void visitPost(DocAutoListItem *); + void visitPre(DocPara *) ; + void visitPost(DocPara *); + void visitPre(DocRoot *); + void visitPost(DocRoot *); + void visitPre(DocSimpleSect *); + void visitPost(DocSimpleSect *); + void visitPre(DocTitle *); + void visitPost(DocTitle *); + void visitPre(DocSimpleList *); + void visitPost(DocSimpleList *); + void visitPre(DocSimpleListItem *); + void visitPost(DocSimpleListItem *); + void visitPre(DocSection *); + void visitPost(DocSection *); + void visitPre(DocHtmlList *); + void visitPost(DocHtmlList *) ; + void visitPre(DocHtmlListItem *); + void visitPost(DocHtmlListItem *); + void visitPre(DocHtmlPre *); + void visitPost(DocHtmlPre *); + void visitPre(DocHtmlDescList *); + void visitPost(DocHtmlDescList *); + void visitPre(DocHtmlDescTitle *); + void visitPost(DocHtmlDescTitle *); + void visitPre(DocHtmlDescData *); + void visitPost(DocHtmlDescData *); + void visitPre(DocHtmlTable *); + void visitPost(DocHtmlTable *); + void visitPre(DocHtmlRow *); + void visitPost(DocHtmlRow *) ; + void visitPre(DocHtmlCell *); + void visitPost(DocHtmlCell *); + void visitPre(DocHtmlCaption *); + void visitPost(DocHtmlCaption *); + void visitPre(DocInternal *); + void visitPost(DocInternal *); + void visitPre(DocHRef *); + void visitPost(DocHRef *); + void visitPre(DocHtmlHeader *); + void visitPost(DocHtmlHeader *); + void visitPre(DocImage *); + void visitPost(DocImage *); + void visitPre(DocDotFile *); + void visitPost(DocDotFile *); + void visitPre(DocLink *); + void visitPost(DocLink *); + void visitPre(DocRef *); + void visitPost(DocRef *); + void visitPre(DocSecRefItem *); + void visitPost(DocSecRefItem *); + void visitPre(DocSecRefList *); + void visitPost(DocSecRefList *); + void visitPre(DocLanguage *); + void visitPost(DocLanguage *); + void visitPre(DocParamSect *); + void visitPost(DocParamSect *); + void visitPre(DocParamList *); + void visitPost(DocParamList *); + void visitPre(DocXRefItem *); + void visitPost(DocXRefItem *); + void visitPre(DocInternalRef *); + void visitPost(DocInternalRef *); + void visitPre(DocCopy *); + void visitPost(DocCopy *); + + private: + + //-------------------------------------- + // helper functions + //-------------------------------------- + + void filter(const char *str); + void startLink(const QCString &ref,const QCString &file, + const QCString &anchor); + void endLink(); + + //-------------------------------------- + // state variables + //-------------------------------------- + + QTextStream &m_t; + BaseCodeDocInterface &m_ci; + bool m_insidePre; + bool m_hide; +}; + +#endif diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp index 5bb7226..f29af33 100644 --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -33,6 +33,8 @@ #include "page.h" #include "filename.h" #include "version.h" +#include "xmldocvisitor.h" +#include "docparser.h" #include #include @@ -47,34 +49,34 @@ // debug inside output //#define XML_DB(x) QCString __t;__t.sprintf x;m_t << __t -QCString sectionTypeToString(BaseOutputDocInterface::SectionTypes t) -{ - switch (t) - { - case BaseOutputDocInterface::See: return "see"; - case BaseOutputDocInterface::Return: return "return"; - case BaseOutputDocInterface::Author: return "author"; - case BaseOutputDocInterface::Version: return "version"; - case BaseOutputDocInterface::Since: return "since"; - case BaseOutputDocInterface::Date: return "date"; - case BaseOutputDocInterface::Bug: return "bug"; - case BaseOutputDocInterface::Note: return "note"; - case BaseOutputDocInterface::Warning: return "warning"; - case BaseOutputDocInterface::Par: return "par"; - case BaseOutputDocInterface::Deprecated: return "deprecated"; - case BaseOutputDocInterface::Pre: return "pre"; - case BaseOutputDocInterface::Post: return "post"; - case BaseOutputDocInterface::Invar: return "invariant"; - case BaseOutputDocInterface::Remark: return "remark"; - case BaseOutputDocInterface::Attention: return "attention"; - case BaseOutputDocInterface::Todo: return "todo"; - case BaseOutputDocInterface::Test: return "test"; - case BaseOutputDocInterface::RCS: return "rcs"; - case BaseOutputDocInterface::EnumValues: return "enumvalues"; - case BaseOutputDocInterface::Examples: return "examples"; - } - return "illegal"; -} +// static QCString sectionTypeToString(BaseOutputDocInterface::SectionTypes t) +// { +// switch (t) +// { +// case BaseOutputDocInterface::See: return "see"; +// case BaseOutputDocInterface::Return: return "return"; +// case BaseOutputDocInterface::Author: return "author"; +// case BaseOutputDocInterface::Version: return "version"; +// case BaseOutputDocInterface::Since: return "since"; +// case BaseOutputDocInterface::Date: return "date"; +// case BaseOutputDocInterface::Bug: return "bug"; +// case BaseOutputDocInterface::Note: return "note"; +// case BaseOutputDocInterface::Warning: return "warning"; +// case BaseOutputDocInterface::Par: return "par"; +// case BaseOutputDocInterface::Deprecated: return "deprecated"; +// case BaseOutputDocInterface::Pre: return "pre"; +// case BaseOutputDocInterface::Post: return "post"; +// case BaseOutputDocInterface::Invar: return "invariant"; +// case BaseOutputDocInterface::Remark: return "remark"; +// case BaseOutputDocInterface::Attention: return "attention"; +// case BaseOutputDocInterface::Todo: return "todo"; +// case BaseOutputDocInterface::Test: return "test"; +// case BaseOutputDocInterface::RCS: return "rcs"; +// case BaseOutputDocInterface::EnumValues: return "enumvalues"; +// case BaseOutputDocInterface::Examples: return "examples"; +// } +// return "illegal"; +// } inline void writeXMLString(QTextStream &t,const char *s) @@ -82,6 +84,26 @@ inline void writeXMLString(QTextStream &t,const char *s) t << convertToXML(s); } +static void writeXMLHeader(QTextStream &t) +{ + QCString dtdName = Config_getString("XML_DTD"); + QCString schemaName = Config_getString("XML_SCHEMA"); + t << "" << endl; + if (!dtdName.isEmpty()) + { + t << "" << endl; + } + t << "" << endl; +} + void writeXMLLink(QTextStream &t,const char *extRef,const char *compoundId, const char *anchorId,const char *text) { @@ -168,683 +190,86 @@ template class ValStack int m_size; }; -/*! This class is used by the documentation parser. - * Its methods are called when some XML text or markup - * needs to be written. - */ -class XMLGenerator : public OutputDocInterface + +class XMLCodeGenerator : public BaseCodeDocInterface { public: - // helper functions + XMLCodeGenerator(QTextStream &t) : m_t(t), m_lineNumber(-1), + m_insideCodeLine(FALSE), m_normalHLNeedStartTag(TRUE), + m_insideSpecialHL(FALSE) {} + virtual ~XMLCodeGenerator() {} - void startParMode() - { - if (!m_inParStack.isEmpty() && !m_inParStack.top()) - { - m_inParStack.top() = TRUE; - m_t << ""; - XML_DB(("start par at level=%d\n",m_inParStack.count())); - } - else if (m_inParStack.isEmpty()) - { - m_inParStack.push(TRUE); - m_t << ""; - XML_DB(("start par at level=%d\n",m_inParStack.count())); - } - } - void endParMode() - { - if (!m_inParStack.isEmpty() && m_inParStack.top()) - { - m_inParStack.top() = FALSE; - m_t << "" << endl; - XML_DB(("end par at level=%d\n",m_inParStack.count())); - } - } - void startNestedPar() - { - m_inParStack.push(FALSE); - XML_DB(("enter par level=%d\n",m_inParStack.count())); - } - void endNestedPar() - { - XML_DB(("leave par level=%d\n",m_inParStack.count())); - if (m_inParStack.pop()) - { - m_t << "" << endl; - } - else - { - //XML_DB(("ILLEGAL par level!\n")); - } - } - - // Standard generator functions to be implemented by all generators - - void docify(const char *s) - { - if (m_outputEnabled) - { - XML_DB(("(docify \"%s\")\n",s)); - startParMode(); - writeXMLString(m_t,s); - } - } - void writeChar(char c) - { - char s[2];s[0]=c;s[1]=0; - docify(s); - } - void writeString(const char *text) - { - //m_t << text; - docify(text); - } - void startItemList() - { - XML_DB(("(startItemList)\n")); - startParMode(); - m_t << "" << endl;; - m_inListStack.push(TRUE); - } - void startEnumList() - { - XML_DB(("(startEnumList)\n")); - startParMode(); - m_t << ""; - m_inListStack.push(TRUE); - } - void writeListItem() - { - XML_DB(("(writeListItem)\n")); - if (!m_inListStack.isEmpty() && m_inListStack.top()) // first element - { - m_inListStack.top()=FALSE; - } - else // not first element, end previous element first - { - endParMode(); - endNestedPar(); - m_t << "" << endl; - } - m_t << ""; - startNestedPar(); - } - void endItemList() - { - XML_DB(("(endItemList)\n")); - if (!m_inListStack.isEmpty() && !m_inListStack.pop()) // first element - { - endParMode(); - endNestedPar(); - m_t << "" << endl; - } - m_t << "" << endl; - } - void endEnumList() - { - XML_DB(("(endEnumList)\n")); - if (!m_inListStack.isEmpty() && !m_inListStack.pop()) // first element - { - endParMode(); - m_t << "" << endl; - endNestedPar(); - } - m_t << "" << endl; - } - void newParagraph() - { - XML_DB(("(newParagraph)\n")); - endParMode(); - startParMode(); - } - void startBold() - { - XML_DB(("(startBold)\n")); - startParMode(); - m_t << ""; // non DocBook - } - void endBold() - { - XML_DB(("(endBold)\n")); - m_t << ""; // non DocBook - } - void startTypewriter() - { - XML_DB(("(startTypewriter)\n")); - startParMode(); - m_t << ""; - } - void endTypewriter() - { - XML_DB(("(endTypewriter)\n")); - m_t << ""; - } - void startEmphasis() - { - XML_DB(("(startEmphasis)\n")); - startParMode(); - m_t << ""; - } - void endEmphasis() - { - XML_DB(("(endEmphasis)\n")); - m_t << ""; - } - void startCodeFragment() - { - XML_DB(("(startCodeFragment)\n")); - startParMode(); - m_t << ""; - } - void endCodeFragment() - { - XML_DB(("(endCodeFragment)\n")); - m_t << ""; - } - void startPreFragment() - { - XML_DB(("(startPreFragment)\n")); - startParMode(); - m_t << ""; - } - void endPreFragment() - { - XML_DB(("(endPreFragment)\n")); - m_t << ""; - } - void startVerbatimFragment() - { - XML_DB(("(startVerbatimFragment)\n")); - startParMode(); - m_t << ""; - } - void endVerbatimFragment() - { - XML_DB(("(endVerbatimFragment)\n")); - m_t << ""; - } - void writeRuler() - { - XML_DB(("(startParMode)\n")); - startParMode(); - m_t << ""; - } - void startDescription() - { - XML_DB(("(startDescription)\n")); - startParMode(); - m_t << ""; - m_inListStack.push(TRUE); - } - void endDescription() - { - XML_DB(("(endDescription)\n")); - if (!m_inListStack.isEmpty() && !m_inListStack.pop()) // first element - { - endNestedPar(); - m_t << "" << endl; - } - m_t << ""; - if (!m_inListStack.isEmpty()) m_inListStack.pop(); - } - void startDescItem() - { - XML_DB(("(startDescItem)\n")); - if (!m_inListStack.isEmpty() && m_inListStack.top()) // first element - { - m_inListStack.top()=FALSE; - } - else // not first element, end previous element first - { - endNestedPar(); - m_t << ""; - } - m_t << ""; - } - void endDescItem() - { - XML_DB(("(endDescItem)\n")); - m_t << ""; - startNestedPar(); - } - void startDescList(SectionTypes st) - { - XML_DB(("(startDescList)\n")); - endParMode(); - m_t << ""; - startNestedPar(); - m_inParStack.top() = TRUE; - } - void endDescList() - { - XML_DB(("(endDescList)\n")); - endNestedPar(); - m_t << "</simplesect>"; - } - void startSimpleSect(SectionTypes st,const char *,const char *,const char *) - { - XML_DB(("(startSimpleSect)\n")); - m_t << "<simplesect kind=\"" << sectionTypeToString(st) << "\">"; - startNestedPar(); - } - void endSimpleSect() + void codify(const char *text) { - XML_DB(("(endSimpleSect)\n")); - endNestedPar(); - m_t << "</simplesect>"; - } - void startParamList(ParamListTypes t,const char *) - { - XML_DB(("(startParamList)\n")); - startParMode(); - QCString kind; - switch(t) + XML_DB(("(codify \"%s\")\n",text)); + if (m_insideCodeLine && !m_insideSpecialHL && m_normalHLNeedStartTag) { - case Param: kind="param"; break; - case RetVal: kind="retval"; break; - case Exception: kind="exception"; break; + m_t << "<highlight class=\"normal\">"; + m_normalHLNeedStartTag=FALSE; } - m_t << "<parameterlist kind=\"" << kind << "\">"; // non DocBook - startNestedPar(); - m_inParStack.top() = TRUE; - m_inParamList = TRUE; - } - void endParamList() - { - XML_DB(("(endParamList)\n")); - m_inParamList = FALSE; - m_t << "</parameterlist>"; - } - void endDescTitle() - { - m_inParStack.top() = FALSE; - endNestedPar(); - XML_DB(("(endDescTitle)\n")); - m_t << ""; - if (!m_inParamList) startNestedPar(); - } - void writeDescItem() - { - XML_DB(("(writeDescItem)\n")); - } - void startDescTable() - { - XML_DB(("(startDescTable)\n")); - } - void endDescTable() - { - XML_DB(("(endDescTable)\n")); - } - void startDescTableTitle() - { - XML_DB(("(startDescTableTitle)\n")); - m_t << ""; // non docbook - } - void endDescTableTitle() - { - XML_DB(("(endDescTableTitle)\n")); - m_t << ""; // non docbook - } - void startDescTableData() - { - XML_DB(("(startDescTableData)\n")); - m_t << ""; // non docbook - startNestedPar(); - } - void endDescTableData() - { - XML_DB(("(endDescTableData)\n")); - endNestedPar(); - m_t << ""; // non docbook - } - void lineBreak() - { - XML_DB(("(lineBreak)\n")); - startParMode(); - m_t << ""; // non docbook - } - void writeNonBreakableSpace(int num) - { - XML_DB(("(writeNonBreakableSpace)\n")); - int i;for (i=0;i"; - } - void endHtmlLink() - { - XML_DB(("(endHtmlLink)\n")); - m_t << ""; - } - void writeMailLink(const char *url) - { - XML_DB(("(writeMailLink)\n")); - startParMode(); - m_t << ""; - docify(url); - m_t << ""; - } - void startSection(const char *id,const char *,SectionInfo::SectionType type) - { - XML_DB(("(startSection)\n")); - endParMode(); - m_t << ""; - startNestedPar(); - m_inParStack.top() = TRUE; - } - void endSection(const char *,SectionInfo::SectionType type) - { - XML_DB(("(endSection)\n")); - m_t << ""; - m_inParStack.top() = FALSE; - endNestedPar(); - } - void startSubsection() - { - XML_DB(("(startSubsection)\n")); - endParMode(); - m_t << ""; - startNestedPar(); - m_inParStack.top() = TRUE; - } - void endSubsection() - { - XML_DB(("(endSubsection)\n")); - m_t << ""; - m_inParStack.top() = FALSE; - endNestedPar(); - } - void startSubsubsection() - { - XML_DB(("(startSubsubsection)\n")); - endParMode(); - m_t << ""; - startNestedPar(); - m_inParStack.top() = TRUE; - } - void endSubsubsection() - { - XML_DB(("(endSubsubsection)\n")); - m_t << ""; - m_inParStack.top() = FALSE; - endNestedPar(); - } - void startCenter() - { - XML_DB(("(startCenter)\n")); - startParMode(); - m_t << "
    "; // non docbook - } - void endCenter() - { - XML_DB(("(endCenter)\n")); - m_t << "
    "; // non docbook - } - void startSmall() - { - XML_DB(("(startSmall)\n")); - startParMode(); - m_t << ""; // non docbook - } - void endSmall() - { - XML_DB(("(endSmall)\n")); - m_t << ""; // non docbook - } - void startSubscript() - { - XML_DB(("(startSubscript)\n")); - startParMode(); - m_t << ""; - } - void endSubscript() - { - XML_DB(("(endSubscript)\n")); - m_t << ""; - } - void startSuperscript() - { - XML_DB(("(startSuperscript)\n")); - startParMode(); - m_t << ""; - } - void endSuperscript() - { - XML_DB(("(endSuperscript)\n")); - m_t << ""; - } - void startTable(bool,int cols) - { - XML_DB(("startTable\n")); - startParMode(); - m_t << "\n"; - } - void endTable(bool hasCaption) - { - XML_DB(("endTable\n")); - if (!hasCaption) m_t << "\n"; - m_t << "
    "; - } - void startCaption() - { - XML_DB(("startCaption")); - m_t << ""; - } - void endCaption() - { - XML_DB(("encCaption")); - m_t << ""; - } - void nextTableRow() - { - XML_DB(("(nextTableRow)\n")); - m_t << ""; - - // we need manually add a para here because cells are - // parsed before the table is generated, and thus - // are already parsed as if they are inside a paragraph. - m_t << ""; - } - void endTableRow() - { - XML_DB(("(endTableRow)\n")); - m_t << "" << endl; - } - void nextTableColumn() - { - XML_DB(("(nextTableColumn)\n")); - m_t << ""; - - // we need manually add a para here because cells are - // parsed before the table is generated, and thus - // are already parsed as if they are inside a paragraph. - m_t << ""; - } - void endTableColumn() - { - XML_DB(("(endTableColumn)\n")); - // we need manually add a para here because cells are - // parsed before the table is generated, and thus - // are already parsed as if they are inside a paragraph. - m_t << ""; - m_t << ""; - } - - void writeQuote() { m_t << "\""; } - void writeCopyright() { m_t << "©"; } - void writeUmlaut(char c) { m_t << "&" << c << "uml;"; } - void writeAcute(char c) { m_t << "&" << c << "acute;"; } - void writeGrave(char c) { m_t << "&" << c << "grave;"; } - void writeCirc(char c) { m_t << "&" << c << "circ;"; } - void writeTilde(char c) { m_t << "&" << c << "tilde;"; } - void writeRing(char c) { m_t << "&" << c << "ring;"; } - void writeSharpS() { m_t << "ß"; } - void writeCCedil(char c) { m_t << "&" << c << "cedil;"; } - - void startTitle() - { - XML_DB(("(startTitle)\n")); - m_t << ""; - startNestedPar(); - m_inParStack.top() = TRUE; - } - void endTitle() - { - m_inParStack.top() = FALSE; - endNestedPar(); - XML_DB(("(endTitle)\n")); - m_t << "" << endl; - } - void writeAnchor(const char *id,const char *name) - { - XML_DB(("(writeAnchor)\n")); - startParMode(); - m_t << ""; - } - void writeSectionRef(const char *,const char *id, - const char *name,const char *text) - { - XML_DB(("(writeSectionRef)\n")); - startParMode(); - m_t << ""; - docify(text); - m_t << ""; - } - void writeSectionRefItem(const char *,const char *,const char *) - { - m_t << "(writeSectionRefItem)"; - } - void addIndexItem(const char *primaryie,const char *secondaryie) - { - XML_DB(("(addIndexItem)\n")); - startParMode(); - m_t << ""; - docify(primaryie); - m_t << ""; - docify(secondaryie); - m_t << ""; - } - void writeFormula(const char *id,const char *text) - { - XML_DB(("(writeFormula)\n")); - startParMode(); - m_t << ""; // non Docbook - docify(text); - m_t << ""; - } - void startImage(const char *name,const char *size,bool /*caption*/) - { - XML_DB(("(startImage)\n")); - startParMode(); - m_t << ""; // non docbook - } - void endImage(bool) - { - XML_DB(("(endImage)\n")); - m_t << ""; - } - void startDotFile(const char *name,bool /*caption*/) - { - XML_DB(("(startDotFile)\n")); - startParMode(); - m_t << ""; // non docbook - } - void endDotFile(bool) - { - XML_DB(("(endDotFile)\n")); - m_t << ""; - } - void startTextLink(const char *name,const char *anchor) - { - XML_DB(("(startTextLink)\n")); - startParMode(); - m_t << ""; - } - void endTextLink() - { - XML_DB(("(endTextLink)\n")); - m_t << ""; - } - void startPageRef() - { - XML_DB(("(startPageRef)\n")); - m_outputEnabled = FALSE; - } - void endPageRef(const char *,const char *) - { - XML_DB(("(endPageRef)\n")); - m_outputEnabled = TRUE; - } - void writeLineNumber(const char *extRef,const char *compId, - const char *anchorId,int l) - { - XML_DB(("(writeLineNumber)\n")); - m_t << ""; + m_normalHLNeedStartTag=FALSE; } - m_t << "/>"; + writeXMLLink(m_t,ref,file,anchor,text); } void startCodeLine() { XML_DB(("(startCodeLine)\n")); - startParMode(); - m_t << ""; // non DocBook + m_t << ""; + m_insideCodeLine=TRUE; } void endCodeLine() { XML_DB(("(endCodeLine)\n")); + if (!m_insideSpecialHL && !m_normalHLNeedStartTag) + { + m_t << ""; + m_normalHLNeedStartTag=TRUE; + } m_t << "" << endl; // non DocBook + m_lineNumber = -1; + m_refId.resize(0); + m_external.resize(0); + m_insideCodeLine=FALSE; } void startCodeAnchor(const char *id) { XML_DB(("(startCodeAnchor)\n")); - startParMode(); + if (m_insideCodeLine && !m_insideSpecialHL && m_normalHLNeedStartTag) + { + m_t << ""; + m_normalHLNeedStartTag=FALSE; + } m_t << ""; } void endCodeAnchor() @@ -855,134 +280,867 @@ class XMLGenerator : public OutputDocInterface void startFontClass(const char *colorClass) { XML_DB(("(startFontClass)\n")); + if (m_insideCodeLine && !m_insideSpecialHL && !m_normalHLNeedStartTag) + { + m_t << ""; + m_normalHLNeedStartTag=TRUE; + } m_t << ""; // non DocBook + m_insideSpecialHL=TRUE; } void endFontClass() { XML_DB(("(endFontClass)\n")); m_t << ""; // non DocBook - } - void codify(const char *text) - { - XML_DB(("(codify \"%s\")\n",text)); - docify(text); - } - void startHtmlOnly() - { - XML_DB(("(startHtmlOnly)\n")); - m_t << "" << endl; - } - void endHtmlOnly() - { - XML_DB(("(endHtmlOnly)\n")); - m_t << "" << endl; - } - void startLatexOnly() - { - XML_DB(("(startLatexOnly)\n")); - m_t << "" << endl; - } - void endLatexOnly() - { - XML_DB(("(endLatexOnly)\n")); - m_t << "" << endl; - } - void startSectionRefList() - { - XML_DB(("(startSectionRefList)\n")); - } - void endSectionRefList() - { - XML_DB(("(endSectionRefList)\n")); + m_insideSpecialHL=FALSE; } void writeCodeAnchor(const char *) { XML_DB(("(writeCodeAnchor)\n")); } - - // Generator specific functions - - /*! Create a clone of this generator. Uses the copy constructor */ - OutputDocInterface *clone() + void writeLineNumber(const char *extRef,const char *compId, + const char *anchorId,int l) { - return new XMLGenerator(this); + XML_DB(("(writeLineNumber)\n")); + // we remember the information provided here to use it + // at the start tag. + m_lineNumber = l; + if (compId) + { + m_refId=compId; + if (anchorId) m_refId+=(QCString)"_1"+anchorId; + m_isMemberRef = anchorId!=0; + if (extRef) m_external=extRef; + } } - /*! Append the output written to generator \a g to this generator */ - void append(const OutputDocInterface *g) - { - const XMLGenerator *xg = (const XMLGenerator *)g; - //printf("Appending \n>>>>\n`%s'\n<<<<\n and \n>>>>\n`%s'\n<<<<\n",getContents().data(),xg->getContents().data()); - m_t << xg->getContents(); - m_inParStack = xg->m_inParStack; - m_inListStack = xg->m_inListStack; - m_inParamList = xg->m_inParamList; - } - /*! constructor. - */ - XMLGenerator() - { - m_b.setBuffer(m_a); - m_b.open( IO_WriteOnly ); - m_t.setDevice(&m_b); - m_t.setEncoding(QTextStream::Latin1); - m_inParamList = FALSE; - m_outputEnabled = TRUE; - } - /*! copy constructor */ - XMLGenerator(const XMLGenerator *xg) - { - m_b.setBuffer(m_a); - m_b.open( IO_WriteOnly ); - m_t.setDevice(&m_b); - m_t.setEncoding(QTextStream::Latin1); - - //printf("Cloning >>%s<< m_parStack.count()=%d\n", - // xg->getContents().data(),xg->m_inParStack.count()); - - // copy state variables - m_inParStack = xg->m_inParStack; - m_inListStack = xg->m_inListStack; - m_inParamList = xg->m_inParamList; - m_outputEnabled = xg->m_outputEnabled; - } - /*! destructor */ - virtual ~XMLGenerator() - { - } - /*! Returns the output written to this generator as a string */ - QCString getContents() const - { - QCString s; - s.resize(m_a.size()+1); - memcpy(s.data(),m_a.data(),m_a.size()); - s.at(m_a.size())='\0'; - return s; - } - private: - // only one destination stream, so these do not have to be implemented - void pushGeneratorState() {} - void popGeneratorState() {} - void disableAllBut(OutputGenerator::OutputType) {} - void enableAll() {} - void disableAll() {} - void disable(OutputGenerator::OutputType) {} - void enable(OutputGenerator::OutputType) {} - bool isEnabled(OutputGenerator::OutputType) { return TRUE; } - - QTextStream m_t; - QByteArray m_a; - QBuffer m_b; - - ValStack m_inParStack; - ValStack m_inListStack; - bool m_inParamList; - bool m_outputEnabled; - - friend void writeXMLCodeBlock(QTextStream &t,FileDef *fd); + QTextStream &m_t; + QCString m_refId; + QCString m_external; + int m_lineNumber; + bool m_isMemberRef; + + bool m_insideCodeLine; + bool m_normalHLNeedStartTag; + bool m_insideSpecialHL; }; +// /*! This class is used by the documentation parser. +// * Its methods are called when some XML text or markup +// * needs to be written. +// */ +// class XMLGenerator : public OutputDocInterface +// { +// public: +// +// // helper functions +// +// void startParMode() +// { +// if (!m_inParStack.isEmpty() && !m_inParStack.top()) +// { +// m_inParStack.top() = TRUE; +// m_t << ""; +// XML_DB(("start par at level=%d\n",m_inParStack.count())); +// } +// else if (m_inParStack.isEmpty()) +// { +// m_inParStack.push(TRUE); +// m_t << ""; +// XML_DB(("start par at level=%d\n",m_inParStack.count())); +// } +// } +// void endParMode() +// { +// if (!m_inParStack.isEmpty() && m_inParStack.top()) +// { +// m_inParStack.top() = FALSE; +// m_t << "" << endl; +// XML_DB(("end par at level=%d\n",m_inParStack.count())); +// } +// } +// void startNestedPar() +// { +// m_inParStack.push(FALSE); +// XML_DB(("enter par level=%d\n",m_inParStack.count())); +// } +// void endNestedPar() +// { +// XML_DB(("leave par level=%d\n",m_inParStack.count())); +// if (m_inParStack.pop()) +// { +// m_t << "" << endl; +// } +// else +// { +// //XML_DB(("ILLEGAL par level!\n")); +// } +// } +// +// // Standard generator functions to be implemented by all generators +// +// void docify(const char *s) +// { +// if (m_outputEnabled) +// { +// XML_DB(("(docify \"%s\")\n",s)); +// startParMode(); +// writeXMLString(m_t,s); +// } +// } +// void writeChar(char c) +// { +// char s[2];s[0]=c;s[1]=0; +// docify(s); +// } +// void writeString(const char *text) +// { +// //m_t << text; +// docify(text); +// } +// void startItemList() +// { +// XML_DB(("(startItemList)\n")); +// startParMode(); +// m_t << "" << endl;; +// m_inListStack.push(TRUE); +// } +// void startEnumList() +// { +// XML_DB(("(startEnumList)\n")); +// startParMode(); +// m_t << ""; +// m_inListStack.push(TRUE); +// } +// void writeListItem() +// { +// XML_DB(("(writeListItem)\n")); +// if (!m_inListStack.isEmpty() && m_inListStack.top()) // first element +// { +// m_inListStack.top()=FALSE; +// } +// else // not first element, end previous element first +// { +// endParMode(); +// endNestedPar(); +// m_t << "
    " << endl; +// } +// m_t << ""; +// startNestedPar(); +// } +// void endItemList() +// { +// XML_DB(("(endItemList)\n")); +// if (!m_inListStack.isEmpty() && !m_inListStack.pop()) // first element +// { +// endParMode(); +// endNestedPar(); +// m_t << "" << endl; +// } +// m_t << "" << endl; +// } +// void endEnumList() +// { +// XML_DB(("(endEnumList)\n")); +// if (!m_inListStack.isEmpty() && !m_inListStack.pop()) // first element +// { +// endParMode(); +// m_t << "" << endl; +// endNestedPar(); +// } +// m_t << "" << endl; +// } +// void newParagraph() +// { +// XML_DB(("(newParagraph)\n")); +// endParMode(); +// startParMode(); +// } +// void startBold() +// { +// XML_DB(("(startBold)\n")); +// startParMode(); +// m_t << ""; // non DocBook +// } +// void endBold() +// { +// XML_DB(("(endBold)\n")); +// m_t << ""; // non DocBook +// } +// void startTypewriter() +// { +// XML_DB(("(startTypewriter)\n")); +// startParMode(); +// m_t << ""; +// } +// void endTypewriter() +// { +// XML_DB(("(endTypewriter)\n")); +// m_t << ""; +// } +// void startEmphasis() +// { +// XML_DB(("(startEmphasis)\n")); +// startParMode(); +// m_t << ""; +// } +// void endEmphasis() +// { +// XML_DB(("(endEmphasis)\n")); +// m_t << ""; +// } +// void startCodeFragment() +// { +// XML_DB(("(startCodeFragment)\n")); +// startParMode(); +// m_t << ""; +// } +// void endCodeFragment() +// { +// XML_DB(("(endCodeFragment)\n")); +// m_t << ""; +// } +// void startPreFragment() +// { +// XML_DB(("(startPreFragment)\n")); +// startParMode(); +// m_t << ""; +// } +// void endPreFragment() +// { +// XML_DB(("(endPreFragment)\n")); +// m_t << ""; +// } +// void startVerbatimFragment() +// { +// XML_DB(("(startVerbatimFragment)\n")); +// startParMode(); +// m_t << ""; +// } +// void endVerbatimFragment() +// { +// XML_DB(("(endVerbatimFragment)\n")); +// m_t << ""; +// } +// void writeRuler() +// { +// XML_DB(("(startParMode)\n")); +// startParMode(); +// m_t << ""; +// } +// void startDescription() +// { +// XML_DB(("(startDescription)\n")); +// startParMode(); +// m_t << ""; +// m_inListStack.push(TRUE); +// } +// void endDescription() +// { +// XML_DB(("(endDescription)\n")); +// if (!m_inListStack.isEmpty() && !m_inListStack.pop()) // first element +// { +// endNestedPar(); +// m_t << "" << endl; +// } +// m_t << ""; +// if (!m_inListStack.isEmpty()) m_inListStack.pop(); +// } +// void startDescItem() +// { +// XML_DB(("(startDescItem)\n")); +// if (!m_inListStack.isEmpty() && m_inListStack.top()) // first element +// { +// m_inListStack.top()=FALSE; +// } +// else // not first element, end previous element first +// { +// endNestedPar(); +// m_t << ""; +// } +// m_t << ""; +// } +// void endDescItem() +// { +// XML_DB(("(endDescItem)\n")); +// m_t << ""; +// startNestedPar(); +// } +// void startDescList(SectionTypes st) +// { +// XML_DB(("(startDescList)\n")); +// endParMode(); +// m_t << ""; +// startNestedPar(); +// m_inParStack.top() = TRUE; +// } +// void endDescList() +// { +// XML_DB(("(endDescList)\n")); +// endNestedPar(); +// m_t << "</simplesect>"; +// } +// void startSimpleSect(SectionTypes st,const char *,const char *,const char *) +// { +// XML_DB(("(startSimpleSect)\n")); +// m_t << "<simplesect kind=\"" << sectionTypeToString(st) << "\">"; +// startNestedPar(); +// } +// void endSimpleSect() +// { +// XML_DB(("(endSimpleSect)\n")); +// endNestedPar(); +// m_t << "</simplesect>"; +// } +// void startParamList(ParamListTypes t,const char *) +// { +// XML_DB(("(startParamList)\n")); +// startParMode(); +// QCString kind; +// switch(t) +// { +// case Param: kind="param"; break; +// case RetVal: kind="retval"; break; +// case Exception: kind="exception"; break; +// } +// m_t << "<parameterlist kind=\"" << kind << "\">"; // non DocBook +// startNestedPar(); +// m_inParStack.top() = TRUE; +// m_inParamList = TRUE; +// } +// void endParamList() +// { +// XML_DB(("(endParamList)\n")); +// m_inParamList = FALSE; +// m_t << "</parameterlist>"; +// } +// void endDescTitle() +// { +// m_inParStack.top() = FALSE; +// endNestedPar(); +// XML_DB(("(endDescTitle)\n")); +// m_t << ""; +// if (!m_inParamList) startNestedPar(); +// } +// void writeDescItem() +// { +// XML_DB(("(writeDescItem)\n")); +// } +// void startDescTable() +// { +// XML_DB(("(startDescTable)\n")); +// } +// void endDescTable() +// { +// XML_DB(("(endDescTable)\n")); +// } +// void startDescTableTitle() +// { +// XML_DB(("(startDescTableTitle)\n")); +// m_t << ""; // non docbook +// } +// void endDescTableTitle() +// { +// XML_DB(("(endDescTableTitle)\n")); +// m_t << ""; // non docbook +// } +// void startDescTableData() +// { +// XML_DB(("(startDescTableData)\n")); +// m_t << ""; // non docbook +// startNestedPar(); +// } +// void endDescTableData() +// { +// XML_DB(("(endDescTableData)\n")); +// endNestedPar(); +// m_t << ""; // non docbook +// } +// void lineBreak() +// { +// XML_DB(("(lineBreak)\n")); +// startParMode(); +// m_t << ""; // non docbook +// } +// void writeNonBreakableSpace(int num) +// { +// XML_DB(("(writeNonBreakableSpace)\n")); +// int i;for (i=0;i"; +// } +// void endHtmlLink() +// { +// XML_DB(("(endHtmlLink)\n")); +// m_t << ""; +// } +// void writeMailLink(const char *url) +// { +// XML_DB(("(writeMailLink)\n")); +// startParMode(); +// m_t << ""; +// docify(url); +// m_t << ""; +// } +// void startSection(const char *id,const char *,SectionInfo::SectionType type) +// { +// XML_DB(("(startSection)\n")); +// endParMode(); +// m_t << ""; +// startNestedPar(); +// m_inParStack.top() = TRUE; +// } +// void endSection(const char *,SectionInfo::SectionType type) +// { +// XML_DB(("(endSection)\n")); +// m_t << ""; +// m_inParStack.top() = FALSE; +// endNestedPar(); +// } +// void startSubsection() +// { +// XML_DB(("(startSubsection)\n")); +// endParMode(); +// m_t << ""; +// startNestedPar(); +// m_inParStack.top() = TRUE; +// } +// void endSubsection() +// { +// XML_DB(("(endSubsection)\n")); +// m_t << ""; +// m_inParStack.top() = FALSE; +// endNestedPar(); +// } +// void startSubsubsection() +// { +// XML_DB(("(startSubsubsection)\n")); +// endParMode(); +// m_t << ""; +// startNestedPar(); +// m_inParStack.top() = TRUE; +// } +// void endSubsubsection() +// { +// XML_DB(("(endSubsubsection)\n")); +// m_t << ""; +// m_inParStack.top() = FALSE; +// endNestedPar(); +// } +// void startCenter() +// { +// XML_DB(("(startCenter)\n")); +// startParMode(); +// m_t << "
    "; // non docbook +// } +// void endCenter() +// { +// XML_DB(("(endCenter)\n")); +// m_t << "
    "; // non docbook +// } +// void startSmall() +// { +// XML_DB(("(startSmall)\n")); +// startParMode(); +// m_t << ""; // non docbook +// } +// void endSmall() +// { +// XML_DB(("(endSmall)\n")); +// m_t << ""; // non docbook +// } +// void startSubscript() +// { +// XML_DB(("(startSubscript)\n")); +// startParMode(); +// m_t << ""; +// } +// void endSubscript() +// { +// XML_DB(("(endSubscript)\n")); +// m_t << ""; +// } +// void startSuperscript() +// { +// XML_DB(("(startSuperscript)\n")); +// startParMode(); +// m_t << ""; +// } +// void endSuperscript() +// { +// XML_DB(("(endSuperscript)\n")); +// m_t << ""; +// } +// void startTable(bool,int cols) +// { +// XML_DB(("startTable\n")); +// startParMode(); +// m_t << "\n"; +// } +// void endTable(bool hasCaption) +// { +// XML_DB(("endTable\n")); +// if (!hasCaption) m_t << "\n"; +// m_t << "
    "; +// } +// void startCaption() +// { +// XML_DB(("startCaption")); +// m_t << ""; +// } +// void endCaption() +// { +// XML_DB(("encCaption")); +// m_t << ""; +// } +// void nextTableRow() +// { +// XML_DB(("(nextTableRow)\n")); +// m_t << ""; +// +// // we need manually add a para here because cells are +// // parsed before the table is generated, and thus +// // are already parsed as if they are inside a paragraph. +// m_t << ""; +// } +// void endTableRow() +// { +// XML_DB(("(endTableRow)\n")); +// m_t << "" << endl; +// } +// void nextTableColumn() +// { +// XML_DB(("(nextTableColumn)\n")); +// m_t << ""; +// +// // we need manually add a para here because cells are +// // parsed before the table is generated, and thus +// // are already parsed as if they are inside a paragraph. +// m_t << ""; +// } +// void endTableColumn() +// { +// XML_DB(("(endTableColumn)\n")); +// // we need manually add a para here because cells are +// // parsed before the table is generated, and thus +// // are already parsed as if they are inside a paragraph. +// m_t << ""; +// m_t << ""; +// } +// +// void writeQuote() { m_t << "\""; } +// void writeCopyright() { m_t << "©"; } +// void writeUmlaut(char c) { m_t << "&" << c << "uml;"; } +// void writeAcute(char c) { m_t << "&" << c << "acute;"; } +// void writeGrave(char c) { m_t << "&" << c << "grave;"; } +// void writeCirc(char c) { m_t << "&" << c << "circ;"; } +// void writeTilde(char c) { m_t << "&" << c << "tilde;"; } +// void writeRing(char c) { m_t << "&" << c << "ring;"; } +// void writeSharpS() { m_t << "ß"; } +// void writeCCedil(char c) { m_t << "&" << c << "cedil;"; } +// +// void startTitle() +// { +// XML_DB(("(startTitle)\n")); +// m_t << ""; +// startNestedPar(); +// m_inParStack.top() = TRUE; +// } +// void endTitle() +// { +// m_inParStack.top() = FALSE; +// endNestedPar(); +// XML_DB(("(endTitle)\n")); +// m_t << "" << endl; +// } +// void writeAnchor(const char *id,const char *name) +// { +// XML_DB(("(writeAnchor)\n")); +// startParMode(); +// m_t << ""; +// } +// void writeSectionRef(const char *,const char *id, +// const char *name,const char *text) +// { +// XML_DB(("(writeSectionRef)\n")); +// startParMode(); +// m_t << ""; +// docify(text); +// m_t << ""; +// } +// void writeSectionRefItem(const char *,const char *,const char *) +// { +// m_t << "(writeSectionRefItem)"; +// } +// void addIndexItem(const char *primaryie,const char *secondaryie) +// { +// XML_DB(("(addIndexItem)\n")); +// startParMode(); +// m_t << ""; +// docify(primaryie); +// m_t << ""; +// docify(secondaryie); +// m_t << ""; +// } +// void writeFormula(const char *id,const char *text) +// { +// XML_DB(("(writeFormula)\n")); +// startParMode(); +// m_t << ""; // non Docbook +// docify(text); +// m_t << ""; +// } +// void startImage(const char *name,const char *size,bool /*caption*/) +// { +// XML_DB(("(startImage)\n")); +// startParMode(); +// m_t << ""; // non docbook +// } +// void endImage(bool) +// { +// XML_DB(("(endImage)\n")); +// m_t << ""; +// } +// void startDotFile(const char *name,bool /*caption*/) +// { +// XML_DB(("(startDotFile)\n")); +// startParMode(); +// m_t << ""; // non docbook +// } +// void endDotFile(bool) +// { +// XML_DB(("(endDotFile)\n")); +// m_t << ""; +// } +// void startTextLink(const char *name,const char *anchor) +// { +// XML_DB(("(startTextLink)\n")); +// startParMode(); +// m_t << ""; +// } +// void endTextLink() +// { +// XML_DB(("(endTextLink)\n")); +// m_t << ""; +// } +// void startPageRef() +// { +// XML_DB(("(startPageRef)\n")); +// m_outputEnabled = FALSE; +// } +// void endPageRef(const char *,const char *) +// { +// XML_DB(("(endPageRef)\n")); +// m_outputEnabled = TRUE; +// } +// void writeLineNumber(const char *extRef,const char *compId, +// const char *anchorId,int l) +// { +// XML_DB(("(writeLineNumber)\n")); +// m_t << ""; +// } +// void startCodeLine() +// { +// XML_DB(("(startCodeLine)\n")); +// startParMode(); +// m_t << ""; // non DocBook +// } +// void endCodeLine() +// { +// XML_DB(("(endCodeLine)\n")); +// m_t << "" << endl; // non DocBook +// } +// void startCodeAnchor(const char *id) +// { +// XML_DB(("(startCodeAnchor)\n")); +// startParMode(); +// m_t << ""; +// } +// void endCodeAnchor() +// { +// XML_DB(("(endCodeAnchor)\n")); +// m_t << ""; +// } +// void startFontClass(const char *colorClass) +// { +// XML_DB(("(startFontClass)\n")); +// m_t << ""; // non DocBook +// } +// void endFontClass() +// { +// XML_DB(("(endFontClass)\n")); +// m_t << ""; // non DocBook +// } +// void codify(const char *text) +// { +// XML_DB(("(codify \"%s\")\n",text)); +// docify(text); +// } +// void startHtmlOnly() +// { +// XML_DB(("(startHtmlOnly)\n")); +// m_t << "" << endl; +// } +// void endHtmlOnly() +// { +// XML_DB(("(endHtmlOnly)\n")); +// m_t << "" << endl; +// } +// void startLatexOnly() +// { +// XML_DB(("(startLatexOnly)\n")); +// m_t << "" << endl; +// } +// void endLatexOnly() +// { +// XML_DB(("(endLatexOnly)\n")); +// m_t << "" << endl; +// } +// void startSectionRefList() +// { +// XML_DB(("(startSectionRefList)\n")); +// } +// void endSectionRefList() +// { +// XML_DB(("(endSectionRefList)\n")); +// } +// void writeCodeAnchor(const char *) +// { +// XML_DB(("(writeCodeAnchor)\n")); +// } +// +// // Generator specific functions +// +// /*! Create a clone of this generator. Uses the copy constructor */ +// OutputDocInterface *clone() +// { +// return new XMLGenerator(this); +// } +// /*! Append the output written to generator \a g to this generator */ +// void append(const OutputDocInterface *g) +// { +// const XMLGenerator *xg = (const XMLGenerator *)g; +// +// //printf("Appending \n>>>>\n`%s'\n<<<<\n and \n>>>>\n`%s'\n<<<<\n",getContents().data(),xg->getContents().data()); +// m_t << xg->getContents(); +// m_inParStack = xg->m_inParStack; +// m_inListStack = xg->m_inListStack; +// m_inParamList = xg->m_inParamList; +// } +// /*! constructor. +// */ +// XMLGenerator() +// { +// m_b.setBuffer(m_a); +// m_b.open( IO_WriteOnly ); +// m_t.setDevice(&m_b); +// m_t.setEncoding(QTextStream::Latin1); +// m_inParamList = FALSE; +// m_outputEnabled = TRUE; +// } +// /*! copy constructor */ +// XMLGenerator(const XMLGenerator *xg) +// { +// m_b.setBuffer(m_a); +// m_b.open( IO_WriteOnly ); +// m_t.setDevice(&m_b); +// m_t.setEncoding(QTextStream::Latin1); +// +// //printf("Cloning >>%s<< m_parStack.count()=%d\n", +// // xg->getContents().data(),xg->m_inParStack.count()); +// +// // copy state variables +// m_inParStack = xg->m_inParStack; +// m_inListStack = xg->m_inListStack; +// m_inParamList = xg->m_inParamList; +// m_outputEnabled = xg->m_outputEnabled; +// } +// /*! destructor */ +// virtual ~XMLGenerator() +// { +// } +// /*! Returns the output written to this generator as a string */ +// QCString getContents() const +// { +// QCString s; +// s.resize(m_a.size()+1); +// memcpy(s.data(),m_a.data(),m_a.size()); +// s.at(m_a.size())='\0'; +// return s; +// } +// +// private: +// // only one destination stream, so these do not have to be implemented +// void pushGeneratorState() {} +// void popGeneratorState() {} +// void disableAllBut(OutputGenerator::OutputType) {} +// void enableAll() {} +// void disableAll() {} +// void disable(OutputGenerator::OutputType) {} +// void enable(OutputGenerator::OutputType) {} +// bool isEnabled(OutputGenerator::OutputType) { return TRUE; } +// +// QTextStream m_t; +// QByteArray m_a; +// QBuffer m_b; +// +// ValStack m_inParStack; +// ValStack m_inListStack; +// bool m_inParamList; +// bool m_outputEnabled; +// +// friend void writeXMLCodeBlock(QTextStream &t,FileDef *fd); +// }; + static void writeTemplateArgumentList(ArgumentList *al,QTextStream &t,const char *name,int indent) { QCString indentStr; @@ -1037,11 +1195,25 @@ static void writeXMLDocBlock(QTextStream &t, const QCString &fileName, int lineNr, const QCString &scope, - MemberDef *md, + MemberDef * md, const QCString &text) { QCString stext = text.stripWhiteSpace(); if (text.isEmpty()) return; + // convert the documentation string into an abstract syntax tree + DocNode *root = validatingParseDoc(fileName,lineNr,scope,md,stext); + // create a code generator + XMLCodeGenerator *xmlCodeGen = new XMLCodeGenerator(t); + // create a parse tree visitor for XML + XmlDocVisitor *visitor = new XmlDocVisitor(t,*xmlCodeGen); + // visit all nodes + root->accept(visitor); + // clean up + delete visitor; + delete xmlCodeGen; + delete root; + +/* XMLGenerator *xmlGen = new XMLGenerator; //xmlGen->startParMode(); parseDoc(*xmlGen, @@ -1054,20 +1226,21 @@ static void writeXMLDocBlock(QTextStream &t, xmlGen->endParMode(); t << xmlGen->getContents(); delete xmlGen; +*/ } void writeXMLCodeBlock(QTextStream &t,FileDef *fd) { initParseCodeContext(); - XMLGenerator *xmlGen = new XMLGenerator; - xmlGen->m_inParStack.push(TRUE); + XMLCodeGenerator *xmlGen = new XMLCodeGenerator(t); + //xmlGen->m_inParStack.push(TRUE); parseCode(*xmlGen, 0, fileToString(fd->absFilePath(),Config_getBool("FILTER_SOURCE_FILES")), FALSE, 0, fd); - t << xmlGen->getContents(); + //t << xmlGen->getContents(); delete xmlGen; } @@ -1466,8 +1639,7 @@ static void generateXMLForClass(ClassDef *cd,QTextStream &ti) } QTextStream t(&f); - t << "" << endl; - t << "" << endl; + writeXMLHeader(t); t << " getOutputFileBase() << "\" kind=\"" << cd->compoundTypeString() << "\">" << endl; @@ -1652,8 +1824,7 @@ static void generateXMLForNamespace(NamespaceDef *nd,QTextStream &ti) } QTextStream t(&f); - t << "" << endl; - t << "" << endl; + writeXMLHeader(t); t << " getOutputFileBase() << "\" kind=\"namespace\">" << endl; t << " "; @@ -1743,8 +1914,7 @@ static void generateXMLForFile(FileDef *fd,QTextStream &ti) } QTextStream t(&f); - t << "" << endl; - t << "" << endl; + writeXMLHeader(t); t << " getOutputFileBase() << "\" kind=\"file\">" << endl; t << " "; @@ -1876,8 +2046,7 @@ static void generateXMLForGroup(GroupDef *gd,QTextStream &ti) } QTextStream t(&f); - t << "" << endl; - t << "" << endl; + writeXMLHeader(t); t << " getOutputFileBase() << "\" kind=\"group\">" << endl; t << " " << convertToXML(gd->name()) << "" << endl; @@ -1975,11 +2144,14 @@ static void generateXMLForPage(PageInfo *pi,QTextStream &ti) if (pi->isReference()) return; - ti << " getOutputFileBase() + QCString pageName = pi->getOutputFileBase(); + if (pageName=="index") pageName="indexpage"; // to prevent overwriting the generated index page. + + ti << " " << convertToXML(pi->name) << "" << endl; QCString outputDirectory = Config_getString("OUTPUT_DIRECTORY"); - QCString fileName=outputDirectory+"/xml/"+pi->getOutputFileBase()+".xml"; + QCString fileName=outputDirectory+"/xml/"+pageName+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { @@ -1988,8 +2160,7 @@ static void generateXMLForPage(PageInfo *pi,QTextStream &ti) } QTextStream t(&f); - t << "" << endl; - t << "" << endl; + writeXMLHeader(t); t << " name; else t << pi->name.lower(); t << "\" kind=\"page\">" << endl; @@ -2071,10 +2242,7 @@ void generateXML() return; } QTextStream t(&f); - t << "" << endl; - //t << "" << endl; - t << "" << endl; - //t << " " << endl; + writeXMLHeader(t); ClassSDict::Iterator cli(Doxygen::classSDict); ClassDef *cd; for (cli.toFirst();(cd=cli.current());++cli) @@ -2110,6 +2278,10 @@ void generateXML() { generateXMLForPage(pi,t); } + if (Doxygen::mainPage) + { + generateXMLForPage(Doxygen::mainPage,t); + } //t << " " << endl; t << "" << endl; -- cgit v0.12