diff options
-rw-r--r-- | doc/commands.doc | 4 | ||||
-rw-r--r-- | src/docbookvisitor.cpp | 20 | ||||
-rw-r--r-- | src/docparser.cpp | 28 | ||||
-rw-r--r-- | src/docparser.h | 7 | ||||
-rw-r--r-- | src/htmldocvisitor.cpp | 19 | ||||
-rw-r--r-- | src/latexdocvisitor.cpp | 23 | ||||
-rw-r--r-- | src/mandocvisitor.cpp | 24 | ||||
-rw-r--r-- | src/perlmodgen.cpp | 1 | ||||
-rw-r--r-- | src/rtfdocvisitor.cpp | 24 | ||||
-rw-r--r-- | src/xmldocvisitor.cpp | 18 |
10 files changed, 142 insertions, 26 deletions
diff --git a/doc/commands.doc b/doc/commands.doc index 0e66c1d..b6c8f6b 100644 --- a/doc/commands.doc +++ b/doc/commands.doc @@ -2186,7 +2186,7 @@ Commands for displaying examples \htmlonly</p></center><p>\endhtmlonly <hr> -\section cmddontinclude \\dontinclude <file-name> +\section cmddontinclude \\dontinclude[{lineno}] <file-name> \addindex \\dontinclude This command can be used to parse a source file without actually @@ -2197,6 +2197,8 @@ Commands for displaying examples \ref cfg_example_path "EXAMPLE_PATH" tag of doxygen's configuration file. + You can add option `{lineno}` to enable line numbers for the included code if desired. + The class and member declarations and definitions inside the code fragment are 'remembered' during the parsing of the comment block that contained the \c \\dontinclude command. diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index 3e4874d..28f6229 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -408,9 +408,8 @@ DB_VIS_C m_t << "</computeroutput></literallayout>"; break; case DocInclude::DontInclude: - break; + case DocInclude::DontIncWithLines: case DocInclude::HtmlInclude: - break; case DocInclude::LatexInclude: break; case DocInclude::VerbInclude: @@ -479,10 +478,25 @@ DB_VIS_C popEnabled(); if (!m_hide) { + FileDef *fd; + if (!op->includeFileName().isEmpty()) + { + QFileInfo cfi( op->includeFileName() ); + fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() ); + } + Doxygen::parserManager->getParser(m_langExt) ->parseCode(m_ci,op->context(), op->text(),langExt,op->isExample(), - op->exampleFile()); + op->exampleFile(), + fd, // fileDef + op->line(), // startLine + -1, // endLine + FALSE, // inline fragment + 0, // memberDef + op->showLineNo() // show line numbers + ); + if (fd) delete fd; } pushEnabled(); m_hide=TRUE; diff --git a/src/docparser.cpp b/src/docparser.cpp index 8aae275..1c8479b 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -112,6 +112,8 @@ static QCString g_includeFileName; static QCString g_includeFileText; static uint g_includeFileOffset; static uint g_includeFileLength; +static uint g_includeFileLine; +static bool g_includeFileShowLineNo; /** Parser's context to store all global variables. @@ -143,6 +145,8 @@ struct DocParserContext QCString includeFileText; uint includeFileOffset; uint includeFileLength; + uint includeFileLine; + bool includeFileLineNo; TokenInfo *token; }; @@ -190,6 +194,8 @@ static void docParserPushContext(bool saveParamInfo=TRUE) ctx->includeFileText = g_includeFileText; ctx->includeFileOffset = g_includeFileOffset; ctx->includeFileLength = g_includeFileLength; + ctx->includeFileLine = g_includeFileLine; + ctx->includeFileLineNo = g_includeFileShowLineNo; ctx->token = g_token; g_token = new TokenInfo; @@ -228,6 +234,8 @@ static void docParserPopContext(bool keepParamInfo=FALSE) g_includeFileText = ctx->includeFileText; g_includeFileOffset = ctx->includeFileOffset; g_includeFileLength = ctx->includeFileLength; + g_includeFileLine = ctx->includeFileLine; + g_includeFileShowLineNo = ctx->includeFileLineNo; delete g_token; g_token = ctx->token; @@ -2004,6 +2012,8 @@ void DocInclude::parse() DBG(("DocInclude::parse(file=%s,text=%s)\n",qPrint(m_file),qPrint(m_text))); switch(m_type) { + case DontIncWithLines: + // fall through case IncWithLines: // fall through case Include: @@ -2014,6 +2024,8 @@ void DocInclude::parse() g_includeFileText = m_text; g_includeFileOffset = 0; g_includeFileLength = m_text.length(); + g_includeFileLine = 0; + g_includeFileShowLineNo = (m_type == DontIncWithLines || m_type == IncWithLines); //printf("g_includeFile=<<%s>>\n",g_includeFileText.data()); break; case VerbInclude: @@ -2059,6 +2071,7 @@ void DocIncOperator::parse() const char *p = g_includeFileText; uint l = g_includeFileLength; uint o = g_includeFileOffset; + uint il = g_includeFileLine; DBG(("DocIncOperator::parse() text=%s off=%d len=%d\n",qPrint(p),o,l)); uint so = o,bo; bool nonEmpty = FALSE; @@ -2070,6 +2083,7 @@ void DocIncOperator::parse() char c = p[o]; if (c=='\n') { + g_includeFileLine++; if (nonEmpty) break; // we have a pattern to match so=o+1; // no pattern, skip empty line } @@ -2081,10 +2095,12 @@ void DocIncOperator::parse() } if (g_includeFileText.mid(so,o-so).find(m_pattern)!=-1) { + m_line = il; m_text = g_includeFileText.mid(so,o-so); DBG(("DocIncOperator::parse() Line: %s\n",qPrint(m_text))); } g_includeFileOffset = QMIN(l,o+1); // set pointer to start of new line + m_showLineNo = g_includeFileShowLineNo; break; case SkipLine: while (o<l) @@ -2095,6 +2111,7 @@ void DocIncOperator::parse() char c = p[o]; if (c=='\n') { + g_includeFileLine++; if (nonEmpty) break; // we have a pattern to match so=o+1; // no pattern, skip empty line } @@ -2106,6 +2123,7 @@ void DocIncOperator::parse() } if (g_includeFileText.mid(so,o-so).find(m_pattern)!=-1) { + m_line = il; m_text = g_includeFileText.mid(so,o-so); DBG(("DocIncOperator::parse() SkipLine: %s\n",qPrint(m_text))); break; @@ -2113,6 +2131,7 @@ void DocIncOperator::parse() o++; // skip new line } g_includeFileOffset = QMIN(l,o+1); // set pointer to start of new line + m_showLineNo = g_includeFileShowLineNo; break; case Skip: while (o<l) @@ -2123,6 +2142,7 @@ void DocIncOperator::parse() char c = p[o]; if (c=='\n') { + g_includeFileLine++; if (nonEmpty) break; // we have a pattern to match so=o+1; // no pattern, skip empty line } @@ -2139,6 +2159,7 @@ void DocIncOperator::parse() o++; // skip new line } g_includeFileOffset = so; // set pointer to start of new line + m_showLineNo = g_includeFileShowLineNo; break; case Until: bo=o; @@ -2150,6 +2171,7 @@ void DocIncOperator::parse() char c = p[o]; if (c=='\n') { + g_includeFileLine++; if (nonEmpty) break; // we have a pattern to match so=o+1; // no pattern, skip empty line } @@ -2161,6 +2183,7 @@ void DocIncOperator::parse() } if (g_includeFileText.mid(so,o-so).find(m_pattern)!=-1) { + m_line = il; m_text = g_includeFileText.mid(bo,o-bo); DBG(("DocIncOperator::parse() Until: %s\n",qPrint(m_text))); break; @@ -2168,6 +2191,7 @@ void DocIncOperator::parse() o++; // skip new line } g_includeFileOffset = QMIN(l,o+1); // set pointer to start of new line + m_showLineNo = g_includeFileShowLineNo; break; } } @@ -5276,6 +5300,10 @@ void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t) { t = DocInclude::SnipWithLines; } + else if (t==DocInclude::DontInclude && optList.contains("lineno")) + { + t = DocInclude::DontIncWithLines; + } else if (t==DocInclude::Include && optList.contains("doc")) { t = DocInclude::IncludeDoc; diff --git a/src/docparser.h b/src/docparser.h index 0b8073c..15180f9 100644 --- a/src/docparser.h +++ b/src/docparser.h @@ -563,7 +563,8 @@ class DocInclude : public DocNode { public: enum Type { Include, DontInclude, VerbInclude, HtmlInclude, LatexInclude, - IncWithLines, Snippet , IncludeDoc, SnippetDoc, SnipWithLines}; + IncWithLines, Snippet , IncludeDoc, SnippetDoc, SnipWithLines, + DontIncWithLines}; DocInclude(DocNode *parent,const QCString &file, const QCString context, Type t, bool isExample,const QCString exampleFile, @@ -623,6 +624,8 @@ class DocIncOperator : public DocNode } return ""; } + int line() const { return m_line; } + bool showLineNo() const { return m_showLineNo; } QCString text() const { return m_text; } QCString pattern() const { return m_pattern; } QCString context() const { return m_context; } @@ -638,6 +641,8 @@ class DocIncOperator : public DocNode private: Type m_type; + int m_line; + bool m_showLineNo; QCString m_text; QCString m_pattern; QCString m_context; diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index c0c22b8..f405591 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -670,7 +670,9 @@ void HtmlDocVisitor::visit(DocInclude *inc) forceStartParagraph(inc); } break; - case DocInclude::DontInclude: + case DocInclude::DontInclude: + case DocInclude::LatexInclude: + case DocInclude::DontIncWithLines: break; case DocInclude::HtmlInclude: { @@ -679,8 +681,6 @@ void HtmlDocVisitor::visit(DocInclude *inc) if (inc->isBlock()) forceStartParagraph(inc); } break; - case DocInclude::LatexInclude: - break; case DocInclude::VerbInclude: forceEndParagraph(inc); m_t << /*PREFRAG_START <<*/ "<pre class=\"fragment\">"; @@ -762,6 +762,12 @@ void HtmlDocVisitor::visit(DocIncOperator *op) popEnabled(); if (!m_hide) { + FileDef *fd; + if (!op->includeFileName().isEmpty()) + { + QFileInfo cfi( op->includeFileName() ); + fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() ); + } Doxygen::parserManager->getParser(m_langExt) ->parseCode( m_ci, @@ -770,14 +776,15 @@ void HtmlDocVisitor::visit(DocIncOperator *op) langExt, op->isExample(), op->exampleFile(), - 0, // fileDef - -1, // startLine + fd, // fileDef + op->line(), // startLine -1, // endLine FALSE, // inline fragment 0, // memberDef - TRUE, // show line numbers + op->showLineNo(), // show line numbers m_ctx // search context ); + if (fd) delete fd; } pushEnabled(); m_hide=TRUE; diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index 008d638..2e979bd 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -494,9 +494,9 @@ void LatexDocVisitor::visit(DocInclude *inc) LatexCodeGenerator::setDoxyCodeOpen(FALSE); m_t << "\\end{DoxyCodeInclude}\n"; break; - case DocInclude::DontInclude: - break; - case DocInclude::HtmlInclude: + case DocInclude::DontInclude: + case DocInclude::DontIncWithLines: + case DocInclude::HtmlInclude: break; case DocInclude::LatexInclude: m_t << inc->text(); @@ -572,9 +572,24 @@ void LatexDocVisitor::visit(DocIncOperator *op) popEnabled(); if (!m_hide) { + FileDef *fd; + if (!op->includeFileName().isEmpty()) + { + QFileInfo cfi( op->includeFileName() ); + fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() ); + } + Doxygen::parserManager->getParser(m_langExt) ->parseCode(m_ci,op->context(),op->text(),langExt, - op->isExample(),op->exampleFile()); + op->isExample(),op->exampleFile(), + fd, // fileDef + op->line(), // startLine + -1, // endLine + FALSE, // inline fragment + 0, // memberDef + op->showLineNo() // show line numbers + ); + if (fd) delete fd; } pushEnabled(); m_hide=TRUE; diff --git a/src/mandocvisitor.cpp b/src/mandocvisitor.cpp index df6af42..5c98c6f 100644 --- a/src/mandocvisitor.cpp +++ b/src/mandocvisitor.cpp @@ -297,10 +297,9 @@ void ManDocVisitor::visit(DocInclude *inc) m_t << ".PP" << endl; m_firstCol=TRUE; break; - case DocInclude::DontInclude: - break; - case DocInclude::HtmlInclude: - break; + case DocInclude::DontInclude: + case DocInclude::DontIncWithLines: + case DocInclude::HtmlInclude: case DocInclude::LatexInclude: break; case DocInclude::VerbInclude: @@ -387,9 +386,24 @@ void ManDocVisitor::visit(DocIncOperator *op) popEnabled(); if (!m_hide) { + FileDef *fd; + if (!op->includeFileName().isEmpty()) + { + QFileInfo cfi( op->includeFileName() ); + fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() ); + } + Doxygen::parserManager->getParser(m_langExt) ->parseCode(m_ci,op->context(),op->text(),langExt, - op->isExample(),op->exampleFile()); + op->isExample(),op->exampleFile(), + fd, // fileDef + op->line(), // startLine + -1, // endLine + FALSE, // inline fragment + 0, // memberDef + op->showLineNo() // show line numbers + ); + if (fd) delete fd; } pushEnabled(); m_hide=TRUE; diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp index fcc7ef5..1ec4bf3 100644 --- a/src/perlmodgen.cpp +++ b/src/perlmodgen.cpp @@ -729,6 +729,7 @@ void PerlModDocVisitor::visit(DocInclude *inc) #endif return; case DocInclude::DontInclude: return; + case DocInclude::DontIncWithLines: return; case DocInclude::HtmlInclude: type = "htmlonly"; break; case DocInclude::LatexInclude: type = "latexonly"; break; case DocInclude::VerbInclude: type = "preformatted"; break; diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp index afe6dee..55c03a5 100644 --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -466,10 +466,9 @@ void RTFDocVisitor::visit(DocInclude *inc) m_t << "\\par"; m_t << "}" << endl; break; - case DocInclude::DontInclude: - break; - case DocInclude::HtmlInclude: - break; + case DocInclude::DontInclude: + case DocInclude::DontIncWithLines: + case DocInclude::HtmlInclude: case DocInclude::LatexInclude: break; case DocInclude::VerbInclude: @@ -550,9 +549,24 @@ void RTFDocVisitor::visit(DocIncOperator *op) popEnabled(); if (!m_hide) { + FileDef *fd; + if (!op->includeFileName().isEmpty()) + { + QFileInfo cfi( op->includeFileName() ); + fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() ); + } + Doxygen::parserManager->getParser(m_langExt) ->parseCode(m_ci,op->context(),op->text(),langExt, - op->isExample(),op->exampleFile()); + op->isExample(),op->exampleFile(), + fd, // fileDef + op->line(), // startLine + -1, // endLine + FALSE, // inline fragment + 0, // memberDef + op->showLineNo() // show line numbers + ); + if (fd) delete fd; } pushEnabled(); m_hide=TRUE; diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp index f85a16e..1005719 100644 --- a/src/xmldocvisitor.cpp +++ b/src/xmldocvisitor.cpp @@ -335,6 +335,7 @@ void XmlDocVisitor::visit(DocInclude *inc) m_t << "</programlisting>"; break; case DocInclude::DontInclude: + case DocInclude::DontIncWithLines: break; case DocInclude::HtmlInclude: if (inc->isBlock()) @@ -420,10 +421,25 @@ void XmlDocVisitor::visit(DocIncOperator *op) popEnabled(); if (!m_hide) { + FileDef *fd; + if (!op->includeFileName().isEmpty()) + { + QFileInfo cfi( op->includeFileName() ); + fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() ); + } + Doxygen::parserManager->getParser(m_langExt) ->parseCode(m_ci,op->context(), op->text(),langExt,op->isExample(), - op->exampleFile()); + op->exampleFile(), + fd, // fileDef + op->line(), // startLine + -1, // endLine + FALSE, // inline fragment + 0, // memberDef + op->showLineNo() // show line numbers + ); + if (fd) delete fd; } pushEnabled(); m_hide=TRUE; |