Commit a07d3d48 authored by Dimitri van Heesch's avatar Dimitri van Heesch

Improved handling of \internal and \endinternal

parent 84f83537
...@@ -131,6 +131,7 @@ CommandMap cmdMap[] = ...@@ -131,6 +131,7 @@ CommandMap cmdMap[] =
{ "vhdlflow", CMD_VHDLFLOW }, { "vhdlflow", CMD_VHDLFLOW },
{ "docbookonly", CMD_DBONLY }, { "docbookonly", CMD_DBONLY },
{ "enddocbookonly",CMD_ENDDBONLY }, { "enddocbookonly",CMD_ENDDBONLY },
{ "endinternal", CMD_ENDINTERNAL },
{ 0, 0 }, { 0, 0 },
}; };
......
...@@ -120,7 +120,8 @@ enum CommandType ...@@ -120,7 +120,8 @@ enum CommandType
CMD_PIPE = 90, CMD_PIPE = 90,
CMD_VHDLFLOW = 91, CMD_VHDLFLOW = 91,
CMD_DBONLY = 92, CMD_DBONLY = 92,
CMD_ENDDBONLY = 93 CMD_ENDDBONLY = 93,
CMD_ENDINTERNAL = 94
}; };
enum HtmlTagType enum HtmlTagType
......
...@@ -1023,6 +1023,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" ...@@ -1023,6 +1023,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
BEGIN(HtmlComment); BEGIN(HtmlComment);
} }
<Comment>{B}*{CMD}"endinternal"{B}* { <Comment>{B}*{CMD}"endinternal"{B}* {
addOutput("\\endinternal ");
if (!inInternalDocs) if (!inInternalDocs)
warn(yyFileName,yyLineNr, warn(yyFileName,yyLineNr,
"found \\endinternal without matching \\internal" "found \\endinternal without matching \\internal"
...@@ -1925,6 +1926,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" ...@@ -1925,6 +1926,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
} }
} }
<SkipInternal>[@\\]"endinternal"[ \t]* { <SkipInternal>[@\\]"endinternal"[ \t]* {
addOutput("\\endinternal ");
BEGIN(Comment); BEGIN(Comment);
} }
<SkipInternal>[^ \\@\n]+ { // skip non-special characters <SkipInternal>[^ \\@\n]+ { // skip non-special characters
......
...@@ -3207,7 +3207,8 @@ int DocInternal::parse(int level) ...@@ -3207,7 +3207,8 @@ int DocInternal::parse(int level)
retval!=RetVal_Section && retval!=RetVal_Section &&
retval!=RetVal_Subsection && retval!=RetVal_Subsection &&
retval!=RetVal_Subsubsection && retval!=RetVal_Subsubsection &&
retval!=RetVal_Paragraph retval!=RetVal_Paragraph &&
retval!=RetVal_EndInternal
); );
if (lastPar) lastPar->markLast(); if (lastPar) lastPar->markLast();
...@@ -3229,7 +3230,7 @@ int DocInternal::parse(int level) ...@@ -3229,7 +3230,7 @@ int DocInternal::parse(int level)
warn_doc_error(g_fileName,doctokenizerYYlineno,"\\internal command found inside internal section"); warn_doc_error(g_fileName,doctokenizerYYlineno,"\\internal command found inside internal section");
} }
DBG(("DocInternal::parse() end\n")); DBG(("DocInternal::parse() end: retval=%x\n",retval));
DocNode *n=g_nodeStack.pop(); DocNode *n=g_nodeStack.pop();
ASSERT(n==this); ASSERT(n==this);
return retval; return retval;
...@@ -5563,6 +5564,9 @@ int DocPara::handleCommand(const QCString &cmdName) ...@@ -5563,6 +5564,9 @@ int DocPara::handleCommand(const QCString &cmdName)
case CMD_INTERNAL: case CMD_INTERNAL:
retval = RetVal_Internal; retval = RetVal_Internal;
break; break;
case CMD_ENDINTERNAL:
retval = RetVal_EndInternal;
break;
case CMD_COPYDOC: // fall through case CMD_COPYDOC: // fall through
case CMD_COPYBRIEF: // fall through case CMD_COPYBRIEF: // fall through
case CMD_COPYDETAILS: case CMD_COPYDETAILS:
...@@ -5669,7 +5673,8 @@ int DocPara::handleCommand(const QCString &cmdName) ...@@ -5669,7 +5673,8 @@ int DocPara::handleCommand(const QCString &cmdName)
INTERNAL_ASSERT(retval==0 || retval==RetVal_OK || retval==RetVal_SimpleSec || INTERNAL_ASSERT(retval==0 || retval==RetVal_OK || retval==RetVal_SimpleSec ||
retval==TK_LISTITEM || retval==TK_ENDLIST || retval==TK_NEWPARA || retval==TK_LISTITEM || retval==TK_ENDLIST || retval==TK_NEWPARA ||
retval==RetVal_Section || retval==RetVal_EndList || retval==RetVal_Section || retval==RetVal_EndList ||
retval==RetVal_Internal || retval==RetVal_SwitchLang retval==RetVal_Internal || retval==RetVal_SwitchLang ||
retval==RetVal_EndInternal
); );
DBG(("handleCommand(%s) end retval=%x\n",qPrint(cmdName),retval)); DBG(("handleCommand(%s) end retval=%x\n",qPrint(cmdName),retval));
return retval; return retval;
...@@ -6618,12 +6623,22 @@ int DocSection::parse() ...@@ -6618,12 +6623,22 @@ int DocSection::parse()
{ {
warn_doc_error(g_fileName,doctokenizerYYlineno,"Invalid list item found"); warn_doc_error(g_fileName,doctokenizerYYlineno,"Invalid list item found");
} }
if (retval==RetVal_Internal)
{
DocInternal *in = new DocInternal(this);
m_children.append(in);
retval = in->parse(m_level+1);
if (retval==RetVal_EndInternal)
{
retval=RetVal_OK;
}
}
} while (retval!=0 && } while (retval!=0 &&
retval!=RetVal_Internal &&
retval!=RetVal_Section && retval!=RetVal_Section &&
retval!=RetVal_Subsection && retval!=RetVal_Subsection &&
retval!=RetVal_Subsubsection && retval!=RetVal_Subsubsection &&
retval!=RetVal_Paragraph retval!=RetVal_Paragraph &&
retval!=RetVal_EndInternal
); );
if (lastPar) lastPar->markLast(); if (lastPar) lastPar->markLast();
...@@ -6680,12 +6695,6 @@ int DocSection::parse() ...@@ -6680,12 +6695,6 @@ int DocSection::parse()
retval=0; // stop parsing retval=0; // stop parsing
} }
else if (retval==RetVal_Internal)
{
DocInternal *in = new DocInternal(this);
m_children.append(in);
retval = in->parse(m_level+1);
}
else else
{ {
} }
...@@ -6695,10 +6704,11 @@ int DocSection::parse() ...@@ -6695,10 +6704,11 @@ int DocSection::parse()
retval==RetVal_Subsection || retval==RetVal_Subsection ||
retval==RetVal_Subsubsection || retval==RetVal_Subsubsection ||
retval==RetVal_Paragraph || retval==RetVal_Paragraph ||
retval==RetVal_Internal retval==RetVal_Internal ||
retval==RetVal_EndInternal
); );
DBG(("DocSection::parse() end\n")); DBG(("DocSection::parse() end: retval=%x\n",retval));
DocNode *n = g_nodeStack.pop(); DocNode *n = g_nodeStack.pop();
ASSERT(n==this); ASSERT(n==this);
return retval; return retval;
...@@ -6834,7 +6844,13 @@ void DocRoot::parse() ...@@ -6834,7 +6844,13 @@ void DocRoot::parse()
{ {
warn_doc_error(g_fileName,doctokenizerYYlineno,"found paragraph command outside of subsubsection context!"); warn_doc_error(g_fileName,doctokenizerYYlineno,"found paragraph command outside of subsubsection context!");
} }
} while (retval!=0 && retval!=RetVal_Section && retval!=RetVal_Internal); if (retval==RetVal_Internal)
{
DocInternal *in = new DocInternal(this);
m_children.append(in);
retval = in->parse(1);
}
} while (retval!=0 && retval!=RetVal_Section);
if (lastPar) lastPar->markLast(); if (lastPar) lastPar->markLast();
//printf("DocRoot::parse() retval=%d %d\n",retval,RetVal_Section); //printf("DocRoot::parse() retval=%d %d\n",retval,RetVal_Section);
...@@ -6856,14 +6872,6 @@ void DocRoot::parse() ...@@ -6856,14 +6872,6 @@ void DocRoot::parse()
} }
} }
if (retval==RetVal_Internal)
{
DocInternal *in = new DocInternal(this);
m_children.append(in);
retval = in->parse(1);
}
handleUnclosedStyleCommands(); handleUnclosedStyleCommands();
DocNode *n = g_nodeStack.pop(); DocNode *n = g_nodeStack.pop();
......
...@@ -62,7 +62,8 @@ enum Tokens ...@@ -62,7 +62,8 @@ enum Tokens
RetVal_SwitchLang = 0x10012, RetVal_SwitchLang = 0x10012,
RetVal_CloseXml = 0x10013, RetVal_CloseXml = 0x10013,
RetVal_EndBlockQuote = 0x10014, RetVal_EndBlockQuote = 0x10014,
RetVal_CopyDoc = 0x10015 RetVal_CopyDoc = 0x10015,
RetVal_EndInternal = 0x10016
}; };
/** @brief Data associated with a token used by the comment block parser. */ /** @brief Data associated with a token used by the comment block parser. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment