summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoralbert-github <albert.tests@gmail.com>2019-10-20 11:41:13 (GMT)
committeralbert-github <albert.tests@gmail.com>2019-10-20 11:41:13 (GMT)
commit36c549da50d685fd8be82e88cb63db5cf13c57f5 (patch)
tree5422261c9398a0d395dced83600b66b769c76bbd /src
parentd0d748aee7fdd0469479d7feff16f337322a2175 (diff)
downloadDoxygen-36c549da50d685fd8be82e88cb63db5cf13c57f5.zip
Doxygen-36c549da50d685fd8be82e88cb63db5cf13c57f5.tar.gz
Doxygen-36c549da50d685fd8be82e88cb63db5cf13c57f5.tar.bz2
Warning with XML / HTML style commands
When having a problem like: ``` /// set <var> var start_interp </em> void fie(void); /// set <i> i start_interp void fie1(void); ``` we get the warnings (doubles omitted): ``` .../bb.h:5: warning: end of comment block while expecting command </em> ``` so - discrepancy between `<var>` and closing `</em>` is not reported, but wrong for as opening and closing tag should have the same tag name. - the missing `</i>` is reported as a missing `</em>` The problems here are due to the fact that `<var>`, `<i>` and `<em>` share all the style `HTML_EMPHASIS`, this problem has been fixed by adding the used tag name to the style information and testing o n the name and not the style type. The result is now: ``` .../bb.h:1: warning: found </em> tag while expecting </var> .../bb.h:2: warning: end of comment block while expecting command </var> .../bb.h:5: warning: end of comment block while expecting command </i> ``` so now the real problems are reported.
Diffstat (limited to 'src')
-rw-r--r--src/docparser.cpp134
-rw-r--r--src/docparser.h6
2 files changed, 74 insertions, 66 deletions
diff --git a/src/docparser.cpp b/src/docparser.cpp
index f655475..3afde48 100644
--- a/src/docparser.cpp
+++ b/src/docparser.cpp
@@ -886,10 +886,10 @@ static int handleStyleArgument(DocNode *parent,QList<DocNode> &children,
* encountered.
*/
static void handleStyleEnter(DocNode *parent,QList<DocNode> &children,
- DocStyleChange::Style s,const HtmlAttribList *attribs)
+ DocStyleChange::Style s,const QCString tagName,const HtmlAttribList *attribs)
{
DBG(("HandleStyleEnter\n"));
- DocStyleChange *sc= new DocStyleChange(parent,g_nodeStack.count(),s,TRUE,attribs);
+ DocStyleChange *sc= new DocStyleChange(parent,g_nodeStack.count(),s,tagName,TRUE,attribs);
children.append(sc);
g_styleStack.push(sc);
}
@@ -903,6 +903,7 @@ static void handleStyleLeave(DocNode *parent,QList<DocNode> &children,
DBG(("HandleStyleLeave\n"));
if (g_styleStack.isEmpty() || // no style change
g_styleStack.top()->style()!=s || // wrong style change
+ g_styleStack.top()->tagName()!=QCString(tagName).lower() || // wrong style change
g_styleStack.top()->position()!=g_nodeStack.count() // wrong position
)
{
@@ -911,10 +912,15 @@ static void handleStyleLeave(DocNode *parent,QList<DocNode> &children,
warn_doc_error(g_fileName,doctokenizerYYlineno,"found </%s> tag without matching <%s>",
qPrint(tagName),qPrint(tagName));
}
+ else if (g_styleStack.top()->tagName()!=QCString(tagName).lower())
+ {
+ warn_doc_error(g_fileName,doctokenizerYYlineno,"found </%s> tag while expecting </%s>",
+ qPrint(tagName),qPrint(g_styleStack.top()->tagName()));
+ }
else if (g_styleStack.top()->style()!=s)
{
warn_doc_error(g_fileName,doctokenizerYYlineno,"found </%s> tag while expecting </%s>",
- qPrint(tagName),qPrint(g_styleStack.top()->styleString()));
+ qPrint(tagName),qPrint(g_styleStack.top()->tagName()));
}
else
{
@@ -924,7 +930,7 @@ static void handleStyleLeave(DocNode *parent,QList<DocNode> &children,
}
else // end the section
{
- DocStyleChange *sc= new DocStyleChange(parent,g_nodeStack.count(),s,FALSE);
+ DocStyleChange *sc= new DocStyleChange(parent,g_nodeStack.count(),s,g_styleStack.top()->tagName(),FALSE);
children.append(sc);
g_styleStack.pop();
}
@@ -941,7 +947,7 @@ static void handlePendingStyleCommands(DocNode *parent,QList<DocNode> &children)
DocStyleChange *sc = g_styleStack.top();
while (sc && sc->position()>=g_nodeStack.count())
{ // there are unclosed style modifiers in the paragraph
- children.append(new DocStyleChange(parent,g_nodeStack.count(),sc->style(),FALSE));
+ children.append(new DocStyleChange(parent,g_nodeStack.count(),sc->style(),sc->tagName(),FALSE));
g_initialStyleStack.push(sc);
g_styleStack.pop();
sc = g_styleStack.top();
@@ -954,7 +960,7 @@ static void handleInitialStyleCommands(DocPara *parent,QList<DocNode> &children)
DocStyleChange *sc;
while ((sc=g_initialStyleStack.pop()))
{
- handleStyleEnter(parent,children,sc->style(),&sc->attribs());
+ handleStyleEnter(parent,children,sc->style(),sc->tagName(),&sc->attribs());
}
}
@@ -1036,7 +1042,7 @@ static void handleUnclosedStyleCommands()
handleUnclosedStyleCommands();
warn_doc_error(g_fileName,doctokenizerYYlineno,
"end of comment block while expecting "
- "command </%s>",qPrint(sc->styleString()));
+ "command </%s>",qPrint(sc->tagName()));
}
}
@@ -1392,9 +1398,9 @@ reparsetoken:
break;
case CMD_EMPHASIS:
{
- children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Italic,TRUE));
+ children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Italic,tokenName,TRUE));
tok=handleStyleArgument(parent,children,tokenName);
- children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Italic,FALSE));
+ children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Italic,tokenName,FALSE));
if (tok!=TK_WORD) children.append(new DocWhiteSpace(parent," "));
if (tok==TK_NEWPARA) goto handlepara;
else if (tok==TK_WORD || tok==TK_HTMLTAG)
@@ -1406,9 +1412,9 @@ reparsetoken:
break;
case CMD_BOLD:
{
- children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Bold,TRUE));
+ children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Bold,tokenName,TRUE));
tok=handleStyleArgument(parent,children,tokenName);
- children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Bold,FALSE));
+ children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Bold,tokenName,FALSE));
if (tok!=TK_WORD) children.append(new DocWhiteSpace(parent," "));
if (tok==TK_NEWPARA) goto handlepara;
else if (tok==TK_WORD || tok==TK_HTMLTAG)
@@ -1420,9 +1426,9 @@ reparsetoken:
break;
case CMD_CODE:
{
- children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Code,TRUE));
+ children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Code,tokenName,TRUE));
tok=handleStyleArgument(parent,children,tokenName);
- children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Code,FALSE));
+ children.append(new DocStyleChange(parent,g_nodeStack.count(),DocStyleChange::Code,tokenName,FALSE));
if (tok!=TK_WORD) children.append(new DocWhiteSpace(parent," "));
if (tok==TK_NEWPARA) goto handlepara;
else if (tok==TK_WORD || tok==TK_HTMLTAG)
@@ -1543,7 +1549,7 @@ reparsetoken:
case HTML_BOLD:
if (!g_token->endTag)
{
- handleStyleEnter(parent,children,DocStyleChange::Bold,&g_token->attribs);
+ handleStyleEnter(parent,children,DocStyleChange::Bold,tokenName,&g_token->attribs);
}
else
{
@@ -1553,7 +1559,7 @@ reparsetoken:
case HTML_STRIKE:
if (!g_token->endTag)
{
- handleStyleEnter(parent,children,DocStyleChange::Strike,&g_token->attribs);
+ handleStyleEnter(parent,children,DocStyleChange::Strike,tokenName,&g_token->attribs);
}
else
{
@@ -1563,7 +1569,7 @@ reparsetoken:
case HTML_DEL:
if (!g_token->endTag)
{
- handleStyleEnter(parent,children,DocStyleChange::Del,&g_token->attribs);
+ handleStyleEnter(parent,children,DocStyleChange::Del,tokenName,&g_token->attribs);
}
else
{
@@ -1573,7 +1579,7 @@ reparsetoken:
case HTML_UNDERLINE:
if (!g_token->endTag)
{
- handleStyleEnter(parent,children,DocStyleChange::Underline,&g_token->attribs);
+ handleStyleEnter(parent,children,DocStyleChange::Underline,tokenName,&g_token->attribs);
}
else
{
@@ -1583,7 +1589,7 @@ reparsetoken:
case HTML_INS:
if (!g_token->endTag)
{
- handleStyleEnter(parent,children,DocStyleChange::Ins,&g_token->attribs);
+ handleStyleEnter(parent,children,DocStyleChange::Ins,tokenName,&g_token->attribs);
}
else
{
@@ -1594,7 +1600,7 @@ reparsetoken:
case XML_C:
if (!g_token->endTag)
{
- handleStyleEnter(parent,children,DocStyleChange::Code,&g_token->attribs);
+ handleStyleEnter(parent,children,DocStyleChange::Code,tokenName,&g_token->attribs);
}
else
{
@@ -1604,7 +1610,7 @@ reparsetoken:
case HTML_EMPHASIS:
if (!g_token->endTag)
{
- handleStyleEnter(parent,children,DocStyleChange::Italic,&g_token->attribs);
+ handleStyleEnter(parent,children,DocStyleChange::Italic,tokenName,&g_token->attribs);
}
else
{
@@ -1614,7 +1620,7 @@ reparsetoken:
case HTML_SUB:
if (!g_token->endTag)
{
- handleStyleEnter(parent,children,DocStyleChange::Subscript,&g_token->attribs);
+ handleStyleEnter(parent,children,DocStyleChange::Subscript,tokenName,&g_token->attribs);
}
else
{
@@ -1624,7 +1630,7 @@ reparsetoken:
case HTML_SUP:
if (!g_token->endTag)
{
- handleStyleEnter(parent,children,DocStyleChange::Superscript,&g_token->attribs);
+ handleStyleEnter(parent,children,DocStyleChange::Superscript,tokenName,&g_token->attribs);
}
else
{
@@ -1634,7 +1640,7 @@ reparsetoken:
case HTML_CENTER:
if (!g_token->endTag)
{
- handleStyleEnter(parent,children,DocStyleChange::Center,&g_token->attribs);
+ handleStyleEnter(parent,children,DocStyleChange::Center,tokenName,&g_token->attribs);
}
else
{
@@ -1644,7 +1650,7 @@ reparsetoken:
case HTML_SMALL:
if (!g_token->endTag)
{
- handleStyleEnter(parent,children,DocStyleChange::Small,&g_token->attribs);
+ handleStyleEnter(parent,children,DocStyleChange::Small,tokenName,&g_token->attribs);
}
else
{
@@ -5385,21 +5391,21 @@ int DocPara::handleCommand(const QCString &cmdName, const int tok)
warn_doc_error(g_fileName,doctokenizerYYlineno,"Found unknown command '\\%s'",qPrint(cmdName));
break;
case CMD_EMPHASIS:
- m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,TRUE));
+ m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,cmdName,TRUE));
retval=handleStyleArgument(this,m_children,cmdName);
- m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,FALSE));
+ m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,cmdName,FALSE));
if (retval!=TK_WORD) m_children.append(new DocWhiteSpace(this," "));
break;
case CMD_BOLD:
- m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Bold,TRUE));
+ m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Bold,cmdName,TRUE));
retval=handleStyleArgument(this,m_children,cmdName);
- m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Bold,FALSE));
+ m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Bold,cmdName,FALSE));
if (retval!=TK_WORD) m_children.append(new DocWhiteSpace(this," "));
break;
case CMD_CODE:
- m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Code,TRUE));
+ m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Code,cmdName,TRUE));
retval=handleStyleArgument(this,m_children,cmdName);
- m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Code,FALSE));
+ m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Code,cmdName,FALSE));
if (retval!=TK_WORD) m_children.append(new DocWhiteSpace(this," "));
break;
case CMD_BSLASH:
@@ -5924,19 +5930,19 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
}
break;
case HTML_BOLD:
- handleStyleEnter(this,m_children,DocStyleChange::Bold,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Bold,tagName,&g_token->attribs);
break;
case HTML_STRIKE:
- handleStyleEnter(this,m_children,DocStyleChange::Strike,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Strike,tagName,&g_token->attribs);
break;
case HTML_DEL:
- handleStyleEnter(this,m_children,DocStyleChange::Del,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Del,tagName,&g_token->attribs);
break;
case HTML_UNDERLINE:
- handleStyleEnter(this,m_children,DocStyleChange::Underline,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Underline,tagName,&g_token->attribs);
break;
case HTML_INS:
- handleStyleEnter(this,m_children,DocStyleChange::Ins,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Ins,tagName,&g_token->attribs);
break;
case HTML_CODE:
if (/*getLanguageFromFileName(g_fileName)==SrcLangExt_CSharp ||*/ g_xmlComment)
@@ -5948,32 +5954,32 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
}
else // normal HTML markup
{
- handleStyleEnter(this,m_children,DocStyleChange::Code,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Code,tagName,&g_token->attribs);
}
break;
case HTML_EMPHASIS:
- handleStyleEnter(this,m_children,DocStyleChange::Italic,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Italic,tagName,&g_token->attribs);
break;
case HTML_DIV:
- handleStyleEnter(this,m_children,DocStyleChange::Div,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Div,tagName,&g_token->attribs);
break;
case HTML_SPAN:
- handleStyleEnter(this,m_children,DocStyleChange::Span,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Span,tagName,&g_token->attribs);
break;
case HTML_SUB:
- handleStyleEnter(this,m_children,DocStyleChange::Subscript,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Subscript,tagName,&g_token->attribs);
break;
case HTML_SUP:
- handleStyleEnter(this,m_children,DocStyleChange::Superscript,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Superscript,tagName,&g_token->attribs);
break;
case HTML_CENTER:
- handleStyleEnter(this,m_children,DocStyleChange::Center,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Center,tagName,&g_token->attribs);
break;
case HTML_SMALL:
- handleStyleEnter(this,m_children,DocStyleChange::Small,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Small,tagName,&g_token->attribs);
break;
case HTML_PRE:
- handleStyleEnter(this,m_children,DocStyleChange::Preformatted,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Preformatted,tagName,&g_token->attribs);
setInsidePreformatted(TRUE);
doctokenizerYYsetInsidePre(TRUE);
break;
@@ -6077,7 +6083,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
}
break;
case XML_C:
- handleStyleEnter(this,m_children,DocStyleChange::Code,&g_token->attribs);
+ handleStyleEnter(this,m_children,DocStyleChange::Code,tagName,&g_token->attribs);
break;
case XML_PARAM:
case XML_TYPEPARAM:
@@ -6113,9 +6119,9 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
if (findAttribute(tagHtmlAttribs,"name",&paramName))
{
//printf("paramName=%s\n",paramName.data());
- m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,TRUE));
+ m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,tagName,TRUE));
m_children.append(new DocWord(this,paramName));
- m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,FALSE));
+ m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Italic,tagName,FALSE));
if (retval!=TK_WORD) m_children.append(new DocWhiteSpace(this," "));
}
else
@@ -6205,9 +6211,9 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
bool inSeeBlock = g_inSeeBlock;
g_token->name = cref;
g_inSeeBlock = TRUE;
- m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Code,TRUE));
+ m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Code,tagName,TRUE));
handleLinkedWord(this,m_children,TRUE);
- m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Code,FALSE));
+ m_children.append(new DocStyleChange(this,g_nodeStack.count(),DocStyleChange::Code,tagName,FALSE));
g_inSeeBlock = inSeeBlock;
}
else
@@ -6345,46 +6351,46 @@ int DocPara::handleHtmlEndTag(const QCString &tagName)
// }
// break;
case HTML_BOLD:
- handleStyleLeave(this,m_children,DocStyleChange::Bold,"b");
+ handleStyleLeave(this,m_children,DocStyleChange::Bold,tagName);
break;
case HTML_STRIKE:
- handleStyleLeave(this,m_children,DocStyleChange::Strike,"strike");
+ handleStyleLeave(this,m_children,DocStyleChange::Strike,tagName);
break;
case HTML_DEL:
- handleStyleLeave(this,m_children,DocStyleChange::Del,"del");
+ handleStyleLeave(this,m_children,DocStyleChange::Del,tagName);
break;
case HTML_UNDERLINE:
- handleStyleLeave(this,m_children,DocStyleChange::Underline,"u");
+ handleStyleLeave(this,m_children,DocStyleChange::Underline,tagName);
break;
case HTML_INS:
- handleStyleLeave(this,m_children,DocStyleChange::Ins,"ins");
+ handleStyleLeave(this,m_children,DocStyleChange::Ins,tagName);
break;
case HTML_CODE:
- handleStyleLeave(this,m_children,DocStyleChange::Code,"code");
+ handleStyleLeave(this,m_children,DocStyleChange::Code,tagName);
break;
case HTML_EMPHASIS:
- handleStyleLeave(this,m_children,DocStyleChange::Italic,"em");
+ handleStyleLeave(this,m_children,DocStyleChange::Italic,tagName);
break;
case HTML_DIV:
- handleStyleLeave(this,m_children,DocStyleChange::Div,"div");
+ handleStyleLeave(this,m_children,DocStyleChange::Div,tagName);
break;
case HTML_SPAN:
- handleStyleLeave(this,m_children,DocStyleChange::Span,"span");
+ handleStyleLeave(this,m_children,DocStyleChange::Span,tagName);
break;
case HTML_SUB:
- handleStyleLeave(this,m_children,DocStyleChange::Subscript,"sub");
+ handleStyleLeave(this,m_children,DocStyleChange::Subscript,tagName);
break;
case HTML_SUP:
- handleStyleLeave(this,m_children,DocStyleChange::Superscript,"sup");
+ handleStyleLeave(this,m_children,DocStyleChange::Superscript,tagName);
break;
case HTML_CENTER:
- handleStyleLeave(this,m_children,DocStyleChange::Center,"center");
+ handleStyleLeave(this,m_children,DocStyleChange::Center,tagName);
break;
case HTML_SMALL:
- handleStyleLeave(this,m_children,DocStyleChange::Small,"small");
+ handleStyleLeave(this,m_children,DocStyleChange::Small,tagName);
break;
case HTML_PRE:
- handleStyleLeave(this,m_children,DocStyleChange::Preformatted,"pre");
+ handleStyleLeave(this,m_children,DocStyleChange::Preformatted,tagName);
setInsidePreformatted(FALSE);
doctokenizerYYsetInsidePre(FALSE);
break;
@@ -6466,7 +6472,7 @@ int DocPara::handleHtmlEndTag(const QCString &tagName)
retval = RetVal_CloseXml;
break;
case XML_C:
- handleStyleLeave(this,m_children,DocStyleChange::Code,"c");
+ handleStyleLeave(this,m_children,DocStyleChange::Code,tagName);
break;
case XML_ITEM:
case XML_LISTHEADER:
diff --git a/src/docparser.h b/src/docparser.h
index 02fe135..d252182 100644
--- a/src/docparser.h
+++ b/src/docparser.h
@@ -388,10 +388,10 @@ class DocStyleChange : public DocNode
Ins = (1<<13)
};
- DocStyleChange(DocNode *parent,uint position,Style s,bool enable,
+ DocStyleChange(DocNode *parent,uint position,Style s,QCString tagName,bool enable,
const HtmlAttribList *attribs=0) :
m_position(position), m_style(s), m_enable(enable)
- { m_parent = parent; if (attribs) m_attribs=*attribs; }
+ { m_parent = parent; if (attribs) m_attribs=*attribs; m_tagName = tagName.lower();}
Kind kind() const { return Kind_StyleChange; }
Style style() const { return m_style; }
const char *styleString() const;
@@ -399,12 +399,14 @@ class DocStyleChange : public DocNode
uint position() const { return m_position; }
void accept(DocVisitor *v) { v->visit(this); }
const HtmlAttribList &attribs() const { return m_attribs; }
+ QCString tagName() const { return m_tagName; }
private:
uint m_position;
Style m_style;
bool m_enable;
HtmlAttribList m_attribs;
+ QCString m_tagName;
};
/** Node representing a special symbol */