summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2016-08-28 10:04:52 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2016-08-28 10:04:52 (GMT)
commit46942e9333b77703b67f95d457972730a82163ef (patch)
treecbaa36c138525eef06fb79a05c6adb45a1d2effa /src
parent5b2e30aa0847f622e053b6ac6aa9c727f7ea42b3 (diff)
parent725c7e35be17898c7cc7bfc51b8e2dfbca82bbb5 (diff)
downloadDoxygen-46942e9333b77703b67f95d457972730a82163ef.zip
Doxygen-46942e9333b77703b67f95d457972730a82163ef.tar.gz
Doxygen-46942e9333b77703b67f95d457972730a82163ef.tar.bz2
Merge branch 'master' of github.com:doxygen/doxygen
Diffstat (limited to 'src')
-rw-r--r--src/cmdmapper.cpp2
-rw-r--r--src/cmdmapper.h4
-rw-r--r--src/docparser.cpp50
-rw-r--r--src/docparser.h2
-rw-r--r--src/fortranscanner.l31
-rw-r--r--src/latexdocvisitor.cpp18
-rw-r--r--src/latexgen.cpp6
-rw-r--r--src/mandocvisitor.cpp18
-rw-r--r--src/pre.l16
-rw-r--r--src/pycode.l4
-rw-r--r--src/rtfdocvisitor.cpp18
-rwxr-xr-xsrc/util.cpp24
-rwxr-xr-xsrc/util.h1
-rw-r--r--src/xmldocvisitor.cpp18
14 files changed, 185 insertions, 27 deletions
diff --git a/src/cmdmapper.cpp b/src/cmdmapper.cpp
index 6784b3e..5ed25cc 100644
--- a/src/cmdmapper.cpp
+++ b/src/cmdmapper.cpp
@@ -88,6 +88,7 @@ CommandMap cmdMap[] =
{ "secreflist", CMD_SECREFLIST },
{ "section", CMD_SECTION },
{ "snippet", CMD_SNIPPET },
+ { "snippetdoc", CMD_SNIPPETDOC },
{ "subpage", CMD_SUBPAGE },
{ "subsection", CMD_SUBSECTION },
{ "subsubsection", CMD_SUBSUBSECTION },
@@ -130,6 +131,7 @@ CommandMap cmdMap[] =
{ "manonly", CMD_MANONLY },
{ "endmanonly", CMD_ENDMANONLY },
{ "includelineno", CMD_INCWITHLINES },
+ { "includedoc", CMD_INCLUDEDOC },
{ "inheritdoc", CMD_INHERITDOC },
{ "mscfile", CMD_MSCFILE },
{ "rtfonly", CMD_RTFONLY },
diff --git a/src/cmdmapper.h b/src/cmdmapper.h
index 92c906a..8800c38 100644
--- a/src/cmdmapper.h
+++ b/src/cmdmapper.h
@@ -133,7 +133,9 @@ enum CommandType
CMD_SETSCOPE = 103,
CMD_PUNT = 104,
CMD_PLUS = 105,
- CMD_MINUS = 106
+ CMD_MINUS = 106,
+ CMD_INCLUDEDOC = 107,
+ CMD_SNIPPETDOC = 108
};
enum HtmlTagType
diff --git a/src/docparser.cpp b/src/docparser.cpp
index f06f6cd..afeb35f 100644
--- a/src/docparser.cpp
+++ b/src/docparser.cpp
@@ -123,6 +123,7 @@ struct DocParserContext
QStack<DocStyleChange> initialStyleStack;
QList<Definition> copyStack;
QCString fileName;
+ int lineNo;
QCString relPath;
bool hasParamCommand;
@@ -144,7 +145,6 @@ struct DocParserContext
static QStack<DocParserContext> g_parserStack;
//---------------------------------------------------------------------------
-
static void docParserPushContext(bool saveParamInfo=TRUE)
{
//QCString indent;
@@ -163,6 +163,7 @@ static void docParserPushContext(bool saveParamInfo=TRUE)
ctx->initialStyleStack = g_initialStyleStack;
ctx->copyStack = g_copyStack;
ctx->fileName = g_fileName;
+ ctx->lineNo = doctokenizerYYlineno;
ctx->relPath = g_relPath;
if (saveParamInfo)
@@ -201,6 +202,7 @@ static void docParserPopContext(bool keepParamInfo=FALSE)
g_initialStyleStack = ctx->initialStyleStack;
g_copyStack = ctx->copyStack;
g_fileName = ctx->fileName;
+ doctokenizerYYlineno = ctx->lineNo;
g_relPath = ctx->relPath;
if (!keepParamInfo)
@@ -5140,7 +5142,6 @@ endref:
doctokenizerYYsetStatePara();
}
-
void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t)
{
DBG(("handleInclude(%s)\n",qPrint(cmdName)));
@@ -5168,7 +5169,7 @@ void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t)
}
QCString fileName = g_token->name;
QCString blockId;
- if (t==DocInclude::Snippet)
+ if (t==DocInclude::Snippet || t==DocInclude::SnippetDoc)
{
if (fileName == "this") fileName=g_fileName;
doctokenizerYYsetStateSnippet();
@@ -5182,9 +5183,31 @@ void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t)
}
blockId = "["+g_token->name+"]";
}
- DocInclude *inc = new DocInclude(this,fileName,g_context,t,g_isExample,g_exampleName,blockId);
- m_children.append(inc);
- inc->parse();
+
+ // This is the only place to handle the \includedoc and \snippetdoc commands,
+ // as the content is included here as if it is really here.
+ if (t==DocInclude::IncludeDoc || t==DocInclude::SnippetDoc)
+ {
+ QCString inc_text;
+ int inc_line = 1;
+ readTextFileByName(fileName,inc_text);
+ if (t==DocInclude::SnippetDoc)
+ {
+ inc_line = lineBlock(inc_text, blockId);
+ inc_text = extractBlock(inc_text, blockId);
+ }
+ docParserPushContext();
+ g_fileName = fileName;
+ doctokenizerYYlineno=inc_line;
+ internalValidatingParseDoc(this,m_children,inc_text);
+ docParserPopContext();
+ }
+ else
+ {
+ DocInclude *inc = new DocInclude(this,fileName,g_context,t,g_isExample,g_exampleName,blockId);
+ m_children.append(inc);
+ inc->parse();
+ }
}
void DocPara::handleSection(const QCString &cmdName)
@@ -5419,15 +5442,15 @@ int DocPara::handleCommand(const QCString &cmdName)
break;
case CMD_LI:
{
- DocSimpleList *sl=new DocSimpleList(this);
- m_children.append(sl);
+ DocSimpleList *sl=new DocSimpleList(this);
+ m_children.append(sl);
retval = sl->parse();
}
break;
case CMD_SECTION:
{
handleSection(cmdName);
- retval = RetVal_Section;
+ retval = RetVal_Section;
}
break;
case CMD_SUBSECTION:
@@ -5673,6 +5696,12 @@ int DocPara::handleCommand(const QCString &cmdName)
case CMD_SNIPPET:
handleInclude(cmdName,DocInclude::Snippet);
break;
+ case CMD_INCLUDEDOC:
+ handleInclude(cmdName,DocInclude::IncludeDoc);
+ break;
+ case CMD_SNIPPETDOC:
+ handleInclude(cmdName,DocInclude::SnippetDoc);
+ break;
case CMD_SKIP:
handleIncludeOperator(cmdName,DocIncOperator::Skip);
break;
@@ -6160,8 +6189,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
case XML_INHERITDOC:
handleInheritDoc();
break;
-
- default:
+ default:
// we should not get here!
ASSERT(0);
break;
diff --git a/src/docparser.h b/src/docparser.h
index e2751d8..1fe5e95 100644
--- a/src/docparser.h
+++ b/src/docparser.h
@@ -483,7 +483,7 @@ class DocVerbatim : public DocNode
class DocInclude : public DocNode
{
public:
- enum Type { Include, DontInclude, VerbInclude, HtmlInclude, LatexInclude, IncWithLines, Snippet };
+ enum Type { Include, DontInclude, VerbInclude, HtmlInclude, LatexInclude, IncWithLines, Snippet , IncludeDoc, SnippetDoc};
DocInclude(DocNode *parent,const QCString &file,
const QCString context, Type t,
bool isExample,const QCString exampleFile,
diff --git a/src/fortranscanner.l b/src/fortranscanner.l
index ad4a63f..0b59eb7 100644
--- a/src/fortranscanner.l
+++ b/src/fortranscanner.l
@@ -322,6 +322,12 @@ SCOPENAME ({ID}{BS}"::"{BS})*
/*-----------------------------------------------------------------------------------*/
+<Prepass>^{BS}[&]*{BS}!.*\n { /* skip lines with just comment. Note code was in free format or has been converted to it */
+ lineCountPrepass ++;
+ }
+<Prepass>^{BS}\n { /* skip empty lines */
+ lineCountPrepass ++;
+ }
<*>^.*\n { // prepass: look for line continuations
functionLine = FALSE;
@@ -1422,6 +1428,7 @@ static const char* prepassFixedForm(const char* contents)
bool inSingle=FALSE;
bool inDouble=FALSE;
bool inBackslash=FALSE;
+ bool fullCommentLine=TRUE;
int newContentsSize = strlen(contents)+3; // \000, \n (when necessary) and one spare character (to avoid reallocation)
char* newContents = (char*)malloc(newContentsSize);
@@ -1435,8 +1442,17 @@ static const char* prepassFixedForm(const char* contents)
char c = contents[i];
switch(c) {
case '\n':
- prevLineLength=column;
- prevLineAmpOrExclIndex=getAmpOrExclAtTheEnd(&contents[i-prevLineLength+1], prevLineLength,prevQuote);
+ if (!fullCommentLine)
+ {
+ prevLineLength=column;
+ prevLineAmpOrExclIndex=getAmpOrExclAtTheEnd(&contents[i-prevLineLength+1], prevLineLength,prevQuote);
+ if (prevLineAmpOrExclIndex == -1) prevLineAmpOrExclIndex = column - 1;
+ }
+ else
+ {
+ prevLineLength+=column;
+ }
+ fullCommentLine=TRUE;
column=0;
emptyLabel=TRUE;
commented=FALSE;
@@ -1463,7 +1479,8 @@ static const char* prepassFixedForm(const char* contents)
case '\\':
if ((column <= fixedCommentAfter) && (column!=6) && !commented)
{
- // we have some special cases in respect to strings and exscaped string characters
+ // we have some special cases in respect to strings and escaped string characters
+ fullCommentLine=FALSE;
newContents[j]=c;
if (c == '\\')
{
@@ -1512,6 +1529,7 @@ static const char* prepassFixedForm(const char* contents)
}
else
{
+ if (!commented) fullCommentLine=FALSE;
newContents[j]=c;
}
break;
@@ -1519,6 +1537,7 @@ static const char* prepassFixedForm(const char* contents)
// fallthrough
default:
if(column==6 && emptyLabel) { // continuation
+ if (!commented) fullCommentLine=FALSE;
if (c != '0') { // 0 not allowed as continuation character, see f95 standard paragraph 3.3.2.3
newContents[j]=' ';
@@ -1532,6 +1551,7 @@ static const char* prepassFixedForm(const char* contents)
} else {
newContents[j]=c; // , just handle like space
}
+ prevLineLength=0;
} else if ((column > fixedCommentAfter) && !commented) {
// first non commented non blank character after position fixedCommentAfter
if (c != '!') {
@@ -1542,6 +1562,7 @@ static const char* prepassFixedForm(const char* contents)
newContents[j]=c;
commented = TRUE;
} else {
+ if (!commented) fullCommentLine=FALSE;
newContents[j]=c;
emptyLabel=FALSE;
}
@@ -2491,7 +2512,11 @@ static void parseMain(const char *fileName,const char *fileBuf,Entry *rt, Fortra
//printf("---strlen=%d\n", strlen(fileBuf));
//clock_t start=clock();
+ //printf("Input fixed form string:\n%s\n", fileBuf);
+ //printf("===========================\n");
inputString = prepassFixedForm(fileBuf);
+ //printf("Resulting free form string:\n%s\n", inputString);
+ //printf("===========================\n");
//clock_t end=clock();
//printf("CPU time used=%f\n", ((double) (end-start))/CLOCKS_PER_SEC);
diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp
index 4a98c77..2c1bc37 100644
--- a/src/latexdocvisitor.cpp
+++ b/src/latexdocvisitor.cpp
@@ -431,7 +431,14 @@ void LatexDocVisitor::visit(DocInclude *inc)
inc->text(),
langExt,
inc->isExample(),
- inc->exampleFile(), &fd);
+ inc->exampleFile(),
+ &fd, // fileDef,
+ -1, // start line
+ -1, // end line
+ FALSE, // inline fragment
+ 0, // memberDef
+ TRUE // show line numbers
+ );
m_t << "\\end{DoxyCodeInclude}" << endl;
}
break;
@@ -440,7 +447,14 @@ void LatexDocVisitor::visit(DocInclude *inc)
Doxygen::parserManager->getParser(inc->extension())
->parseCode(m_ci,inc->context(),
inc->text(),langExt,inc->isExample(),
- inc->exampleFile());
+ inc->exampleFile(),
+ 0, // fileDef
+ -1, // startLine
+ -1, // endLine
+ TRUE, // inlineFragment
+ 0, // memberDef
+ FALSE
+ );
m_t << "\\end{DoxyCodeInclude}\n";
break;
case DocInclude::DontInclude:
diff --git a/src/latexgen.cpp b/src/latexgen.cpp
index 7b77e6e..e56f91d 100644
--- a/src/latexgen.cpp
+++ b/src/latexgen.cpp
@@ -1292,7 +1292,7 @@ void LatexGenerator::endIndexItem(const char *ref,const char *fn)
//{
// t << "\\item\\contentsline{section}{";
// docify(text);
-// t << "}{\\pageref{" << text << "}}" << endl;
+// t << "}{\\pageref{" << stripPath(text) << "}}" << endl;
//}
@@ -1336,7 +1336,7 @@ void LatexGenerator::writeStartAnnoItem(const char *,const char *,
void LatexGenerator::writeEndAnnoItem(const char *name)
{
- t << "}{\\pageref{" << name << "}}{}" << endl;
+ t << "}{\\pageref{" << stripPath(name) << "}}{}" << endl;
}
void LatexGenerator::startIndexKey()
@@ -1357,7 +1357,7 @@ void LatexGenerator::startIndexValue(bool hasBrief)
void LatexGenerator::endIndexValue(const char *name,bool /*hasBrief*/)
{
//if (hasBrief) t << ")";
- t << "}{\\pageref{" << name << "}}{}" << endl;
+ t << "}{\\pageref{" << stripPath(name) << "}}{}" << endl;
}
//void LatexGenerator::writeClassLink(const char *,const char *,
diff --git a/src/mandocvisitor.cpp b/src/mandocvisitor.cpp
index 8acffc7..6b06958 100644
--- a/src/mandocvisitor.cpp
+++ b/src/mandocvisitor.cpp
@@ -237,7 +237,14 @@ void ManDocVisitor::visit(DocInclude *inc)
inc->text(),
langExt,
inc->isExample(),
- inc->exampleFile(), &fd);
+ inc->exampleFile(),
+ &fd, // fileDef,
+ -1, // start line
+ -1, // end line
+ FALSE, // inline fragment
+ 0, // memberDef
+ TRUE
+ );
if (!m_firstCol) m_t << endl;
m_t << ".fi" << endl;
m_t << ".PP" << endl;
@@ -253,7 +260,14 @@ void ManDocVisitor::visit(DocInclude *inc)
inc->text(),
langExt,
inc->isExample(),
- inc->exampleFile());
+ inc->exampleFile(),
+ 0, // fileDef
+ -1, // startLine
+ -1, // endLine
+ TRUE, // inlineFragment
+ 0, // memberDef
+ FALSE
+ );
if (!m_firstCol) m_t << endl;
m_t << ".fi" << endl;
m_t << ".PP" << endl;
diff --git a/src/pre.l b/src/pre.l
index 13ca91f..e89a61c 100644
--- a/src/pre.l
+++ b/src/pre.l
@@ -1737,6 +1737,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
%x SkipString
%x CopyLine
%x CopyString
+%x CopyStringFtn
%x Include
%x IncludeID
%x EndImport
@@ -1850,6 +1851,11 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
outputChar(*yytext);
BEGIN( CopyString );
}
+<CopyLine>\' {
+ if (getLanguageFromFileName(g_yyFileName)!=SrcLangExt_Fortran) REJECT;
+ outputChar(*yytext);
+ BEGIN( CopyStringFtn );
+ }
<CopyString>[^\"\\\r\n]+ {
outputArray(yytext,(int)yyleng);
}
@@ -1860,6 +1866,16 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
outputChar(*yytext);
BEGIN( CopyLine );
}
+<CopyStringFtn>[^\'\\\r\n]+ {
+ outputArray(yytext,(int)yyleng);
+ }
+<CopyStringFtn>\\. {
+ outputArray(yytext,(int)yyleng);
+ }
+<CopyStringFtn>\' {
+ outputChar(*yytext);
+ BEGIN( CopyLine );
+ }
<CopyLine>{ID}/{BN}{0,80}"(" {
g_expectGuard = FALSE;
Define *def=0;
diff --git a/src/pycode.l b/src/pycode.l
index ef6c780..3935107 100644
--- a/src/pycode.l
+++ b/src/pycode.l
@@ -1142,6 +1142,10 @@ TARGET ({IDENTIFIER}|"("{TARGET_LIST}")"|"["{TARGET_LIST}"]"|{ATTRIBUT
codify(yytext);
}
+ "\n" {
+ codifyLines(yytext);
+ }
+
":" {
codify(yytext);
diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp
index 7386c6e..1e539ff 100644
--- a/src/rtfdocvisitor.cpp
+++ b/src/rtfdocvisitor.cpp
@@ -386,7 +386,14 @@ void RTFDocVisitor::visit(DocInclude *inc)
inc->text(),
langExt,
inc->isExample(),
- inc->exampleFile(), &fd);
+ inc->exampleFile(),
+ &fd, // fileDef,
+ -1, // start line
+ -1, // end line
+ FALSE, // inline fragment
+ 0, // memberDef
+ TRUE // show line numbers
+ );
m_t << "\\par";
m_t << "}" << endl;
}
@@ -398,7 +405,14 @@ void RTFDocVisitor::visit(DocInclude *inc)
Doxygen::parserManager->getParser(inc->extension())
->parseCode(m_ci,inc->context(),
inc->text(),langExt,inc->isExample(),
- inc->exampleFile());
+ inc->exampleFile(),
+ 0, // fileDef
+ -1, // startLine
+ -1, // endLine
+ TRUE, // inlineFragment
+ 0, // memberDef
+ FALSE // show line numbers
+ );
m_t << "\\par";
m_t << "}" << endl;
break;
diff --git a/src/util.cpp b/src/util.cpp
index 543291c..efd3d3c 100755
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -8085,6 +8085,7 @@ bool copyFile(const QCString &src,const QCString &dest)
/** Returns the section of text, in between a pair of markers.
* Full lines are returned, excluding the lines on which the markers appear.
+ * \sa routine lineBlock
*/
QCString extractBlock(const QCString text,const QCString marker)
{
@@ -8128,6 +8129,29 @@ QCString extractBlock(const QCString text,const QCString marker)
return l2>l1 ? text.mid(l1,l2-l1) : QCString();
}
+/** Returns the line number of the line following the line with the marker.
+ * \sa routine extractBlock
+ */
+int lineBlock(const QCString text,const QCString marker)
+{
+ int result = 1;
+ int p=0,i;
+ bool found=FALSE;
+
+ // find the character positions of the first marker
+ int m1 = text.find(marker);
+ if (m1==-1) return result;
+
+ // find start line positions for the markers
+ while (!found && (i=text.find('\n',p))!=-1)
+ {
+ found = (p<=m1 && m1<i); // found the line with the start marker
+ p=i+1;
+ result++;
+ }
+ return result;
+}
+
/** Returns a string representation of \a lang. */
QCString langToString(SrcLangExt lang)
{
diff --git a/src/util.h b/src/util.h
index 15f4c4f..af8a3b4 100755
--- a/src/util.h
+++ b/src/util.h
@@ -445,6 +445,7 @@ QCString replaceColorMarkers(const char *str);
bool copyFile(const QCString &src,const QCString &dest);
QCString extractBlock(const QCString text,const QCString marker);
+int lineBlock(const QCString text,const QCString marker);
QCString correctURL(const QCString &url,const QCString &relPath);
diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp
index 380a39b..1f5dea3 100644
--- a/src/xmldocvisitor.cpp
+++ b/src/xmldocvisitor.cpp
@@ -272,7 +272,14 @@ void XmlDocVisitor::visit(DocInclude *inc)
inc->text(),
langExt,
inc->isExample(),
- inc->exampleFile(), &fd);
+ inc->exampleFile(),
+ &fd, // fileDef,
+ -1, // start line
+ -1, // end line
+ FALSE, // inline fragment
+ 0, // memberDef
+ TRUE // show line numbers
+ );
m_t << "</programlisting>";
}
break;
@@ -283,7 +290,14 @@ void XmlDocVisitor::visit(DocInclude *inc)
inc->text(),
langExt,
inc->isExample(),
- inc->exampleFile());
+ inc->exampleFile(),
+ 0, // fileDef
+ -1, // startLine
+ -1, // endLine
+ TRUE, // inlineFragment
+ 0, // memberDef
+ FALSE // show line numbers
+ );
m_t << "</programlisting>";
break;
case DocInclude::DontInclude: