summaryrefslogtreecommitdiffstats
path: root/src/docparser.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2019-12-25 09:09:33 (GMT)
committerGitHub <noreply@github.com>2019-12-25 09:09:33 (GMT)
commit80f1f380f199f470ef9678a413d537feba68d87a (patch)
tree57ad379d75b0ede4af42ec20e1d21fd04c9b5360 /src/docparser.cpp
parent36c549da50d685fd8be82e88cb63db5cf13c57f5 (diff)
parentff3fdb3ac14a1f90334ca6c40eac46c772b5af63 (diff)
downloadDoxygen-80f1f380f199f470ef9678a413d537feba68d87a.zip
Doxygen-80f1f380f199f470ef9678a413d537feba68d87a.tar.gz
Doxygen-80f1f380f199f470ef9678a413d537feba68d87a.tar.bz2
Merge branch 'master' into feature/bug_style_change
Diffstat (limited to 'src/docparser.cpp')
-rw-r--r--src/docparser.cpp189
1 files changed, 99 insertions, 90 deletions
diff --git a/src/docparser.cpp b/src/docparser.cpp
index 3afde48..bd757a4 100644
--- a/src/docparser.cpp
+++ b/src/docparser.cpp
@@ -287,8 +287,17 @@ static QCString findAndCopyImage(const char *fileName,DocImage::Type type, bool
bool ambig;
FileDef *fd;
//printf("Search for %s\n",fileName);
- if ((fd=findFileDef(Doxygen::imageNameDict,fileName,ambig)) && !ambig)
+ if (fd=findFileDef(Doxygen::imageNameDict,fileName,ambig))
{
+ if (ambig & dowarn)
+ {
+ QCString text;
+ text.sprintf("image file name %s is ambiguous.\n",qPrint(fileName));
+ text+="Possible candidates:\n";
+ text+=showFileDefMatches(Doxygen::imageNameDict,fileName);
+ warn_doc_error(g_fileName,doctokenizerYYlineno,text);
+ }
+
QCString inputFile = fd->absFilePath();
QFile inImage(inputFile);
if (inImage.open(IO_ReadOnly))
@@ -369,26 +378,15 @@ static QCString findAndCopyImage(const char *fileName,DocImage::Type type, bool
epstopdfArgs.sprintf("\"%s/%s.eps\" --outfile=\"%s/%s.pdf\"",
outputDir.data(), baseName.data(),
outputDir.data(), baseName.data());
- portable_sysTimerStart();
- if (portable_system("epstopdf",epstopdfArgs)!=0)
+ Portable::sysTimerStart();
+ if (Portable::system("epstopdf",epstopdfArgs)!=0)
{
err("Problems running epstopdf. Check your TeX installation!\n");
}
- portable_sysTimerStop();
+ Portable::sysTimerStop();
return baseName;
}
}
- else if (ambig)
- {
- if (dowarn)
- {
- QCString text;
- text.sprintf("image file name %s is ambiguous.\n",qPrint(fileName));
- text+="Possible candidates:\n";
- text+=showFileDefMatches(Doxygen::imageNameDict,fileName);
- warn_doc_error(g_fileName,doctokenizerYYlineno,text);
- }
- }
else
{
result=fileName;
@@ -413,12 +411,12 @@ static void checkArgumentName(const QCString &name)
{
if (!Config_getBool(WARN_IF_DOC_ERROR)) return;
if (g_memberDef==0) return; // not a member
- const ArgumentList *al=g_memberDef->isDocsForDefinition() ?
+ const ArgumentList &al=g_memberDef->isDocsForDefinition() ?
g_memberDef->argumentList() :
g_memberDef->declArgumentList();
SrcLangExt lang = g_memberDef->getLanguage();
//printf("isDocsForDefinition()=%d\n",g_memberDef->isDocsForDefinition());
- if (al==0) return; // no argument list
+ if (al.empty()) return; // no argument list
static QRegExp re("$?[a-zA-Z0-9_\\x80-\\xFF]+\\.*");
int p=0,i=0,l;
@@ -427,12 +425,10 @@ static void checkArgumentName(const QCString &name)
QCString aName=name.mid(i,l);
if (lang==SrcLangExt_Fortran) aName=aName.lower();
//printf("aName='%s'\n",aName.data());
- ArgumentListIterator ali(*al);
- const Argument *a;
bool found=FALSE;
- for (ali.toFirst();(a=ali.current());++ali)
+ for (const Argument &a : al)
{
- QCString argName = g_memberDef->isDefine() ? a->type : a->name;
+ QCString argName = g_memberDef->isDefine() ? a.type : a.name;
if (lang==SrcLangExt_Fortran) argName=argName.lower();
argName=argName.stripWhiteSpace();
//printf("argName='%s' aName=%s\n",argName.data(),aName.data());
@@ -460,7 +456,6 @@ static void checkArgumentName(const QCString &name)
inheritedMd->docLine(),qPrint(inheritedMd->docFile()));
docFile = g_memberDef->getDefFileName();
docLine = g_memberDef->getDefLine();
-
}
QCString alStr = argListToString(al);
warn_doc_error(docFile,docLine,
@@ -500,30 +495,28 @@ static void checkUnOrMultipleDocumentedParams()
{
if (g_memberDef && g_hasParamCommand && Config_getBool(WARN_IF_DOC_ERROR))
{
- const ArgumentList *al=g_memberDef->isDocsForDefinition() ?
+ const ArgumentList &al=g_memberDef->isDocsForDefinition() ?
g_memberDef->argumentList() :
g_memberDef->declArgumentList();
SrcLangExt lang = g_memberDef->getLanguage();
- if (al!=0)
+ if (!al.empty())
{
- ArgumentListIterator ali(*al);
- const Argument *a;
- bool found=FALSE;
- for (ali.toFirst();(a=ali.current());++ali)
+ int notArgCnt=0;
+ for (const Argument &a: al)
{
int count = 0;
- QCString argName = g_memberDef->isDefine() ? a->type : a->name;
+ QCString argName = g_memberDef->isDefine() ? a.type : a.name;
if (lang==SrcLangExt_Fortran) argName = argName.lower();
argName=argName.stripWhiteSpace();
QCString aName = argName;
if (argName.right(3)=="...") argName=argName.left(argName.length()-3);
if (lang==SrcLangExt_Python && (argName=="self" || argName=="cls"))
- {
+ {
// allow undocumented self / cls parameter for Python
}
- else if (!argName.isEmpty() && g_paramsFound.find(argName)==0 && a->docs.isEmpty())
+ else if (!argName.isEmpty() && g_paramsFound.find(argName)==0 && a.docs.isEmpty())
{
- found = TRUE;
+ notArgCnt++;
}
else
{
@@ -544,24 +537,26 @@ static void checkUnOrMultipleDocumentedParams()
" has multiple @param documentation sections");
}
}
- if (found)
+ if (notArgCnt>0)
{
bool first=TRUE;
QCString errMsg=
- "The following parameters of "+
+ "The following parameter";
+ errMsg+= (notArgCnt>1 ? "s" : "");
+ errMsg+=" of "+
QCString(g_memberDef->qualifiedName()) +
QCString(argListToString(al)) +
- " are not documented:\n";
- for (ali.toFirst();(a=ali.current());++ali)
+ (notArgCnt>1 ? " are" : " is") + " not documented:\n";
+ for (const Argument &a : al)
{
- QCString argName = g_memberDef->isDefine() ? a->type : a->name;
+ QCString argName = g_memberDef->isDefine() ? a.type : a.name;
if (lang==SrcLangExt_Fortran) argName = argName.lower();
argName=argName.stripWhiteSpace();
if (lang==SrcLangExt_Python && (argName=="self" || argName=="cls"))
- {
+ {
// allow undocumented self / cls parameter for Python
}
- else if (!argName.isEmpty() && g_paramsFound.find(argName)==0)
+ else if (!argName.isEmpty() && g_paramsFound.find(argName)==0)
{
if (!first)
{
@@ -806,14 +801,15 @@ static bool findDocsForMemberOrCompound(const char *commandName,
inline void errorHandleDefaultToken(DocNode *parent,int tok,
QList<DocNode> &children,const char *txt)
{
+ const char *cmd_start = "\\";
switch (tok)
{
case TK_COMMAND_AT:
- // fall through
+ cmd_start = "@";
case TK_COMMAND_BS:
children.append(new DocWord(parent,TK_COMMAND_CHAR(tok) + g_token->name));
warn_doc_error(g_fileName,doctokenizerYYlineno,"Illegal command %s as part of a %s",
- qPrint(TK_COMMAND_CHAR(tok) + g_token->name), txt);
+ qPrint(cmd_start + g_token->name),txt);
break;
case TK_SYMBOL:
warn_doc_error(g_fileName,doctokenizerYYlineno,"Unsupported symbol %s found found as part of a %s",
@@ -1826,7 +1822,7 @@ static int internalValidatingParseDoc(DocNode *parent,QList<DocNode> &children,
static void readTextFileByName(const QCString &file,QCString &text)
{
- if (portable_isAbsolutePath(file.data()))
+ if (Portable::isAbsolutePath(file.data()))
{
QFileInfo fi(file);
if (fi.exists())
@@ -1839,7 +1835,7 @@ static void readTextFileByName(const QCString &file,QCString &text)
char *s=examplePathList.first();
while (s)
{
- QCString absFileName = QCString(s)+portable_pathSeparator()+file;
+ QCString absFileName = QCString(s)+Portable::pathSeparator()+file;
QFileInfo fi(absFileName);
if (fi.exists())
{
@@ -1852,16 +1848,16 @@ static void readTextFileByName(const QCString &file,QCString &text)
// as a fallback we also look in the exampleNameDict
bool ambig;
FileDef *fd;
- if ((fd=findFileDef(Doxygen::exampleNameDict,file,ambig)) && !ambig)
+ if (fd=findFileDef(Doxygen::exampleNameDict,file,ambig))
{
text = fileToString(fd->absFilePath(),Config_getBool(FILTER_SOURCE_FILES));
- }
- else if (ambig)
- {
- warn_doc_error(g_fileName,doctokenizerYYlineno,"included file name %s is ambiguous"
+ if (ambig)
+ {
+ warn_doc_error(g_fileName,doctokenizerYYlineno,"included file name %s is ambiguous"
"Possible candidates:\n%s",qPrint(file),
qPrint(showFileDefMatches(Doxygen::exampleNameDict,file))
);
+ }
}
else
{
@@ -2321,6 +2317,7 @@ void DocSecRefList::parse()
{
if (tok==TK_COMMAND_AT || tok == TK_COMMAND_BS)
{
+ const char *cmd_start = (tok==TK_COMMAND_AT ? "@" : "\\");
switch (Mappers::cmdMapper->map(g_token->name))
{
case CMD_SECREFITEM:
@@ -2348,7 +2345,7 @@ void DocSecRefList::parse()
goto endsecreflist;
default:
warn_doc_error(g_fileName,doctokenizerYYlineno,"Illegal command %s as part of a \\secreflist",
- qPrint(g_token->name));
+ qPrint(cmd_start + g_token->name));
goto endsecreflist;
}
}
@@ -2655,9 +2652,11 @@ QCString DocLink::parse(bool isJavaLink,bool isXmlLink)
{
if (!defaultHandleToken(this,tok,m_children,FALSE))
{
+ const char *cmd_start = "\\";
switch (tok)
{
case TK_COMMAND_AT:
+ cmd_start = "@";
// fall through
case TK_COMMAND_BS:
switch (Mappers::cmdMapper->map(g_token->name))
@@ -2670,7 +2669,7 @@ QCString DocLink::parse(bool isJavaLink,bool isXmlLink)
goto endlink;
default:
warn_doc_error(g_fileName,doctokenizerYYlineno,"Illegal command %s as part of a \\link",
- qPrint(g_token->name));
+ qPrint(cmd_start + g_token->name));
break;
}
break;
@@ -2754,17 +2753,17 @@ bool DocDotFile::parse()
{
fd = findFileDef(Doxygen::dotFileNameDict,m_name+".dot",ambig);
}
- if (fd && !ambig)
+ if (fd)
{
m_file = fd->absFilePath();
ok = true;
- }
- else if (ambig)
- {
- warn_doc_error(g_fileName,doctokenizerYYlineno,"included dot file name %s is ambiguous.\n"
+ if (ambig)
+ {
+ warn_doc_error(g_fileName,doctokenizerYYlineno,"included dot file name %s is ambiguous.\n"
"Possible candidates:\n%s",qPrint(m_name),
qPrint(showFileDefMatches(Doxygen::dotFileNameDict,m_name))
);
+ }
}
else
{
@@ -2791,17 +2790,17 @@ bool DocMscFile::parse()
{
fd = findFileDef(Doxygen::mscFileNameDict,m_name+".msc",ambig);
}
- if (fd && !ambig)
+ if (fd)
{
m_file = fd->absFilePath();
ok = true;
- }
- else if (ambig)
- {
- warn_doc_error(g_fileName,doctokenizerYYlineno,"included msc file name %s is ambiguous.\n"
+ if (ambig)
+ {
+ warn_doc_error(g_fileName,doctokenizerYYlineno,"included msc file name %s is ambiguous.\n"
"Possible candidates:\n%s",qPrint(m_name),
qPrint(showFileDefMatches(Doxygen::mscFileNameDict,m_name))
);
+ }
}
else
{
@@ -2830,17 +2829,17 @@ bool DocDiaFile::parse()
{
fd = findFileDef(Doxygen::diaFileNameDict,m_name+".dia",ambig);
}
- if (fd && !ambig)
+ if (fd)
{
m_file = fd->absFilePath();
ok = true;
- }
- else if (ambig)
- {
- warn_doc_error(g_fileName,doctokenizerYYlineno,"included dia file name %s is ambiguous.\n"
+ if (ambig)
+ {
+ warn_doc_error(g_fileName,doctokenizerYYlineno,"included dia file name %s is ambiguous.\n"
"Possible candidates:\n%s",qPrint(m_name),
qPrint(showFileDefMatches(Doxygen::diaFileNameDict,m_name))
);
+ }
}
else
{
@@ -2899,7 +2898,7 @@ bool DocImage::isSVG() const
QCString locName = m_url.isEmpty() ? m_name : m_url;
int len = locName.length();
int fnd = locName.find('?'); // ignore part from ? until end
- if (fnd!=-1) fnd=len;
+ if (fnd==-1) fnd=len;
return fnd>=4 && locName.mid(fnd-4,4)==".svg";
}
@@ -3802,9 +3801,11 @@ int DocHtmlDescTitle::parse()
{
if (!defaultHandleToken(this,tok,m_children))
{
+ const char *cmd_start = "\\";
switch (tok)
{
case TK_COMMAND_AT:
+ cmd_start = "@";
// fall through
case TK_COMMAND_BS:
{
@@ -3875,8 +3876,8 @@ int DocHtmlDescTitle::parse()
break;
default:
- warn_doc_error(g_fileName,doctokenizerYYlineno,"Illegal command \\%s found as part of a <dt> tag",
- qPrint(g_token->name));
+ warn_doc_error(g_fileName,doctokenizerYYlineno,"Illegal command %s found as part of a <dt> tag",
+ qPrint(cmd_start + g_token->name));
}
}
break;
@@ -4571,7 +4572,7 @@ void DocSimpleSect::appendLinkWord(const QCString &word)
{
p = (DocPara *)m_children.getLast();
- // Comma-seperate <seealso> links.
+ // Comma-separate <seealso> links.
p->injectToken(TK_WORD,",");
p->injectToken(TK_WHITESPACE," ");
}
@@ -5906,6 +5907,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
switch (tagId)
{
case HTML_UL:
+ if (!g_token->emptyTag)
{
DocHtmlList *list = new DocHtmlList(this,tagHtmlAttribs,DocHtmlList::Unordered);
m_children.append(list);
@@ -5913,6 +5915,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
}
break;
case HTML_OL:
+ if (!g_token->emptyTag)
{
DocHtmlList *list = new DocHtmlList(this,tagHtmlAttribs,DocHtmlList::Ordered);
m_children.append(list);
@@ -5920,6 +5923,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
}
break;
case HTML_LI:
+ if (g_token->emptyTag) break;
if (!insideUL(this) && !insideOL(this))
{
warn_doc_error(g_fileName,doctokenizerYYlineno,"lonely <li> tag found");
@@ -5930,21 +5934,22 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
}
break;
case HTML_BOLD:
- handleStyleEnter(this,m_children,DocStyleChange::Bold,tagName,&g_token->attribs);
+ if (!g_token->emptyTag) handleStyleEnter(this,m_children,DocStyleChange::Bold,tagName,&g_token->attribs);
break;
case HTML_STRIKE:
- handleStyleEnter(this,m_children,DocStyleChange::Strike,tagName,&g_token->attribs);
+ if (!g_token->emptyTag) handleStyleEnter(this,m_children,DocStyleChange::Strike,tagName,&g_token->attribs);
break;
case HTML_DEL:
- handleStyleEnter(this,m_children,DocStyleChange::Del,tagName,&g_token->attribs);
+ if (!g_token->emptyTag) handleStyleEnter(this,m_children,DocStyleChange::Del,tagName,&g_token->attribs);
break;
case HTML_UNDERLINE:
- handleStyleEnter(this,m_children,DocStyleChange::Underline,tagName,&g_token->attribs);
+ if (!g_token->emptyTag) handleStyleEnter(this,m_children,DocStyleChange::Underline,tagName,&g_token->attribs);
break;
case HTML_INS:
- handleStyleEnter(this,m_children,DocStyleChange::Ins,tagName,&g_token->attribs);
+ if (!g_token->emptyTag) handleStyleEnter(this,m_children,DocStyleChange::Ins,tagName,&g_token->attribs);
break;
case HTML_CODE:
+ if (g_token->emptyTag) break;
if (/*getLanguageFromFileName(g_fileName)==SrcLangExt_CSharp ||*/ g_xmlComment)
// for C# source or inside a <summary> or <remark> section we
// treat <code> as an XML tag (so similar to @code)
@@ -5958,27 +5963,28 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
}
break;
case HTML_EMPHASIS:
- handleStyleEnter(this,m_children,DocStyleChange::Italic,tagName,&g_token->attribs);
+ if (!g_token->emptyTag) handleStyleEnter(this,m_children,DocStyleChange::Italic,tagName,&g_token->attribs);
break;
case HTML_DIV:
- handleStyleEnter(this,m_children,DocStyleChange::Div,tagName,&g_token->attribs);
+ if (!g_token->emptyTag) handleStyleEnter(this,m_children,DocStyleChange::Div,tagName,&g_token->attribs);
break;
case HTML_SPAN:
- handleStyleEnter(this,m_children,DocStyleChange::Span,tagName,&g_token->attribs);
+ if (!g_token->emptyTag) handleStyleEnter(this,m_children,DocStyleChange::Span,tagName,&g_token->attribs);
break;
case HTML_SUB:
- handleStyleEnter(this,m_children,DocStyleChange::Subscript,tagName,&g_token->attribs);
+ if (!g_token->emptyTag) handleStyleEnter(this,m_children,DocStyleChange::Subscript,tagName,&g_token->attribs);
break;
case HTML_SUP:
- handleStyleEnter(this,m_children,DocStyleChange::Superscript,tagName,&g_token->attribs);
+ if (!g_token->emptyTag) handleStyleEnter(this,m_children,DocStyleChange::Superscript,tagName,&g_token->attribs);
break;
case HTML_CENTER:
- handleStyleEnter(this,m_children,DocStyleChange::Center,tagName,&g_token->attribs);
+ if (!g_token->emptyTag) handleStyleEnter(this,m_children,DocStyleChange::Center,tagName,&g_token->attribs);
break;
case HTML_SMALL:
- handleStyleEnter(this,m_children,DocStyleChange::Small,tagName,&g_token->attribs);
+ if (!g_token->emptyTag) handleStyleEnter(this,m_children,DocStyleChange::Small,tagName,&g_token->attribs);
break;
case HTML_PRE:
+ if (g_token->emptyTag) break;
handleStyleEnter(this,m_children,DocStyleChange::Preformatted,tagName,&g_token->attribs);
setInsidePreformatted(TRUE);
doctokenizerYYsetInsidePre(TRUE);
@@ -5987,6 +5993,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
retval=TK_NEWPARA;
break;
case HTML_DL:
+ if (!g_token->emptyTag)
{
DocHtmlDescList *list = new DocHtmlDescList(this,tagHtmlAttribs);
m_children.append(list);
@@ -6000,6 +6007,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
warn_doc_error(g_fileName,doctokenizerYYlineno,"Unexpected tag <dd> found");
break;
case HTML_TABLE:
+ if (!g_token->emptyTag)
{
DocHtmlTable *table = new DocHtmlTable(this,tagHtmlAttribs);
m_children.append(table);
@@ -6034,22 +6042,22 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
retval=handleAHref(this,m_children,tagHtmlAttribs);
break;
case HTML_H1:
- retval=handleHtmlHeader(tagHtmlAttribs,1);
+ if (!g_token->emptyTag) retval=handleHtmlHeader(tagHtmlAttribs,1);
break;
case HTML_H2:
- retval=handleHtmlHeader(tagHtmlAttribs,2);
+ if (!g_token->emptyTag) retval=handleHtmlHeader(tagHtmlAttribs,2);
break;
case HTML_H3:
- retval=handleHtmlHeader(tagHtmlAttribs,3);
+ if (!g_token->emptyTag) retval=handleHtmlHeader(tagHtmlAttribs,3);
break;
case HTML_H4:
- retval=handleHtmlHeader(tagHtmlAttribs,4);
+ if (!g_token->emptyTag) retval=handleHtmlHeader(tagHtmlAttribs,4);
break;
case HTML_H5:
- retval=handleHtmlHeader(tagHtmlAttribs,5);
+ if (!g_token->emptyTag) retval=handleHtmlHeader(tagHtmlAttribs,5);
break;
case HTML_H6:
- retval=handleHtmlHeader(tagHtmlAttribs,6);
+ if (!g_token->emptyTag) retval=handleHtmlHeader(tagHtmlAttribs,6);
break;
case HTML_IMG:
{
@@ -6057,6 +6065,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
}
break;
case HTML_BLOCKQUOTE:
+ if (!g_token->emptyTag)
{
DocHtmlBlockQuote *block = new DocHtmlBlockQuote(this,tagHtmlAttribs);
m_children.append(block);
@@ -6287,7 +6296,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
break;
case HTML_UNKNOWN:
warn_doc_error(g_fileName,doctokenizerYYlineno,"Unsupported xml/html tag <%s> found", qPrint(tagName));
- m_children.append(new DocWord(this, "<"+tagName+tagHtmlAttribs.toString()+">"));
+ m_children.append(new DocWord(this, "<"+tagName+g_token->attribsStr+">"));
break;
case XML_INHERITDOC:
handleInheritDoc();
@@ -7529,7 +7538,7 @@ QCString getDirHtmlClassOfPage(QCString pageTitle)
return result;
}
-QCString getHtmlDirEmbedingChar(QString::Direction textDir)
+QCString getHtmlDirEmbeddingChar(QString::Direction textDir)
{
if (textDir == QString::DirLTR)
return "&#x202A;";
@@ -7538,7 +7547,7 @@ QCString getHtmlDirEmbedingChar(QString::Direction textDir)
return "";
}
-QCString getJsDirEmbedingChar(QString::Direction textDir)
+QCString getJsDirEmbeddingChar(QString::Direction textDir)
{
if (textDir == QString::DirLTR)
return "\\u202A";