summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/commands.doc19
-rw-r--r--src/cmdmapper.cpp1
-rw-r--r--src/cmdmapper.h3
-rw-r--r--src/code.l9
-rw-r--r--src/docbookvisitor.cpp22
-rw-r--r--src/docparser.cpp6
-rw-r--r--src/docparser.h3
-rw-r--r--src/fortrancode.l11
-rw-r--r--src/htmldocvisitor.cpp25
-rw-r--r--src/latexdocvisitor.cpp22
-rw-r--r--src/mandocvisitor.cpp27
-rw-r--r--src/perlmodgen.cpp1
-rw-r--r--src/printdocvisitor.h1
-rw-r--r--src/pycode.l17
-rw-r--r--src/rtfdocvisitor.cpp24
-rw-r--r--src/vhdlcode.l16
-rw-r--r--src/xmlcode.l19
-rw-r--r--src/xmldocvisitor.cpp22
-rw-r--r--testing/014/indexpage.xml6
19 files changed, 211 insertions, 43 deletions
diff --git a/doc/commands.doc b/doc/commands.doc
index d9d38e8..6cb7a4d 100644
--- a/doc/commands.doc
+++ b/doc/commands.doc
@@ -179,6 +179,7 @@ documentation:
\refitem cmdskipline \\skipline
\refitem cmdsnippet \\snippet
\refitem cmdsnippetdoc \\snippetdoc
+\refitem cmdsnippetlineno \\snippetlineno
\refitem cmdstartuml \\startuml
\refitem cmdstruct \\struct
\refitem cmdsubpage \\subpage
@@ -2183,7 +2184,7 @@ Commands for displaying examples
This command works the same way as \ref cmdinclude "\\include", but will add line
numbers to the included file.
- \sa section \ref cmdinclude "\\include".
+ \sa sections \ref cmdinclude "\\include" and \ref cmdsnippetlineno "\\snippetlineno".
<hr>
\section cmdincludedoc \\includedoc <file-name>
@@ -2303,7 +2304,16 @@ Commands for displaying examples
see section \ref cmddontinclude "\\dontinclude" for an alternative way
to include fragments of a source file that does not require markers.
- \sa section \ref cmdsnippetdoc "\\snippetdoc".
+ \sa section \ref cmdsnippetdoc "\\snippetdoc" and \ref cmdsnippetlineno "\\snippetlineno".
+<hr>
+\section cmdsnippetlineno \\snippetlineno <file-name> ( block_id )
+
+ \addindex \\snippetlineno
+ This command works the same way as \ref cmdsnippet "\\snippet", but will add line
+ numbers to the included snippet.
+
+ \sa sections \ref cmdsnippet "\\snippet" and \ref cmdincludelineno "\\includelineno".
+
<hr>
\section cmdsnippetdoc \\snippetdoc <file-name> ( block_id )
@@ -3212,9 +3222,8 @@ class Receiver
\c \\verbatim command or the parser will get confused!
\sa sections \ref cmdcode "\\code",
- \ref cmdendverbatim "\\endverbatim",
- \ref cmdverbinclude "\\verbinclude", and
- \ref cmdverbincludedooc "\\verbincludedooc".
+ \ref cmdendverbatim "\\endverbatim" and
+ \ref cmdverbinclude "\\verbinclude".
<hr>
\section cmdxmlonly \\xmlonly
diff --git a/src/cmdmapper.cpp b/src/cmdmapper.cpp
index 5ed25cc..2c8effc 100644
--- a/src/cmdmapper.cpp
+++ b/src/cmdmapper.cpp
@@ -89,6 +89,7 @@ CommandMap cmdMap[] =
{ "section", CMD_SECTION },
{ "snippet", CMD_SNIPPET },
{ "snippetdoc", CMD_SNIPPETDOC },
+ { "snippetlineno", CMD_SNIPWITHLINES },
{ "subpage", CMD_SUBPAGE },
{ "subsection", CMD_SUBSECTION },
{ "subsubsection", CMD_SUBSUBSECTION },
diff --git a/src/cmdmapper.h b/src/cmdmapper.h
index 8800c38..8cb529d 100644
--- a/src/cmdmapper.h
+++ b/src/cmdmapper.h
@@ -135,7 +135,8 @@ enum CommandType
CMD_PLUS = 105,
CMD_MINUS = 106,
CMD_INCLUDEDOC = 107,
- CMD_SNIPPETDOC = 108
+ CMD_SNIPPETDOC = 108,
+ CMD_SNIPWITHLINES= 109
};
enum HtmlTagType
diff --git a/src/code.l b/src/code.l
index 60d4b03..c2eaeed 100644
--- a/src/code.l
+++ b/src/code.l
@@ -3659,16 +3659,17 @@ void parseCCode(CodeOutputInterface &od,const char *className,const QCString &s,
g_searchCtx = searchCtx;
g_collectXRefs = collectXRefs;
g_inFunctionTryBlock = FALSE;
- if (endLine!=-1)
- g_inputLines = endLine+1;
- else
- g_inputLines = countLines();
if (startLine!=-1)
g_yyLineNr = startLine;
else
g_yyLineNr = 1;
+ if (endLine!=-1)
+ g_inputLines = endLine+1;
+ else
+ g_inputLines = g_yyLineNr + countLines() - 1;
+
g_curlyCount = 0;
g_bodyCurlyCount = 0;
g_bracketCount = 0;
diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp
index 535d294..ab10da0 100644
--- a/src/docbookvisitor.cpp
+++ b/src/docbookvisitor.cpp
@@ -359,6 +359,28 @@ void DocbookDocVisitor::visit(DocInclude *inc)
);
m_t << "</computeroutput></literallayout>";
break;
+ case DocInclude::SnipWithLines:
+ {
+ QFileInfo cfi( inc->file() );
+ FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
+ m_t << "<literallayout><computeroutput>";
+ Doxygen::parserManager->getParser(inc->extension())
+ ->parseCode(m_ci,
+ inc->context(),
+ extractBlock(inc->text(),inc->blockId()),
+ langExt,
+ inc->isExample(),
+ inc->exampleFile(),
+ &fd,
+ lineBlock(inc->text(),inc->blockId()),
+ -1, // endLine
+ FALSE, // inlineFragment
+ 0, // memberDef
+ TRUE // show line number
+ );
+ m_t << "</computeroutput></literallayout>";
+ }
+ break;
case DocInclude::SnippetDoc:
case DocInclude::IncludeDoc:
err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
diff --git a/src/docparser.cpp b/src/docparser.cpp
index cdf549a..2602f78 100644
--- a/src/docparser.cpp
+++ b/src/docparser.cpp
@@ -1931,6 +1931,7 @@ void DocInclude::parse()
readTextFileByName(m_file,m_text);
break;
case Snippet:
+ case SnipWithLines:
readTextFileByName(m_file,m_text);
// check here for the existence of the blockId inside the file, so we
// only generate the warning once.
@@ -5174,7 +5175,7 @@ void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t)
}
QCString fileName = g_token->name;
QCString blockId;
- if (t==DocInclude::Snippet || t==DocInclude::SnippetDoc)
+ if (t==DocInclude::Snippet || t==DocInclude::SnipWithLines || t==DocInclude::SnippetDoc)
{
if (fileName == "this") fileName=g_fileName;
doctokenizerYYsetStateSnippet();
@@ -5701,6 +5702,9 @@ int DocPara::handleCommand(const QCString &cmdName)
case CMD_SNIPPET:
handleInclude(cmdName,DocInclude::Snippet);
break;
+ case CMD_SNIPWITHLINES:
+ handleInclude(cmdName,DocInclude::SnipWithLines);
+ break;
case CMD_INCLUDEDOC:
handleInclude(cmdName,DocInclude::IncludeDoc);
break;
diff --git a/src/docparser.h b/src/docparser.h
index 1fe5e95..f5167dc 100644
--- a/src/docparser.h
+++ b/src/docparser.h
@@ -483,7 +483,8 @@ class DocVerbatim : public DocNode
class DocInclude : public DocNode
{
public:
- enum Type { Include, DontInclude, VerbInclude, HtmlInclude, LatexInclude, IncWithLines, Snippet , IncludeDoc, SnippetDoc};
+ enum Type { Include, DontInclude, VerbInclude, HtmlInclude, LatexInclude,
+ IncWithLines, Snippet , IncludeDoc, SnippetDoc, SnipWithLines};
DocInclude(DocNode *parent,const QCString &file,
const QCString context, Type t,
bool isExample,const QCString exampleFile,
diff --git a/src/fortrancode.l b/src/fortrancode.l
index a2a5d1a..6abb676 100644
--- a/src/fortrancode.l
+++ b/src/fortrancode.l
@@ -1263,16 +1263,17 @@ void parseFortranCode(CodeOutputInterface &od,const char *className,const QCStri
g_needsTermination = FALSE;
g_searchCtx = searchCtx;
g_collectXRefs = collectXRefs;
- if (endLine!=-1)
- g_inputLines = endLine+1;
- else
- g_inputLines = countLines();
-
if (startLine!=-1)
g_yyLineNr = startLine;
else
g_yyLineNr = 1;
+ if (endLine!=-1)
+ g_inputLines = endLine+1;
+ else
+ g_inputLines = g_yyLineNr + countLines() - 1;
+
+
g_exampleBlock = exBlock;
g_exampleName = exName;
g_sourceFileDef = fd;
diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp
index 1b1bc98..a42a8ec 100644
--- a/src/htmldocvisitor.cpp
+++ b/src/htmldocvisitor.cpp
@@ -578,6 +578,31 @@ void HtmlDocVisitor::visit(DocInclude *inc)
-1, // endLine
TRUE, // inlineFragment
0, // memberDef
+ FALSE, // show line number
+ m_ctx // search context
+ );
+ m_t << PREFRAG_END;
+ forceStartParagraph(inc);
+ }
+ break;
+ case DocInclude::SnipWithLines:
+ {
+ forceEndParagraph(inc);
+ m_t << PREFRAG_START;
+ QFileInfo cfi( inc->file() );
+ FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
+ Doxygen::parserManager->getParser(inc->extension())
+ ->parseCode(m_ci,
+ inc->context(),
+ extractBlock(inc->text(),inc->blockId()),
+ langExt,
+ inc->isExample(),
+ inc->exampleFile(),
+ &fd,
+ lineBlock(inc->text(),inc->blockId()),
+ -1, // endLine
+ FALSE, // inlineFragment
+ 0, // memberDef
TRUE, // show line number
m_ctx // search context
);
diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp
index 13491e9..467800c 100644
--- a/src/latexdocvisitor.cpp
+++ b/src/latexdocvisitor.cpp
@@ -483,6 +483,28 @@ void LatexDocVisitor::visit(DocInclude *inc)
m_t << "\\end{DoxyCodeInclude}" << endl;
}
break;
+ case DocInclude::SnipWithLines:
+ {
+ QFileInfo cfi( inc->file() );
+ FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
+ m_t << "\n\\begin{DoxyCodeInclude}\n";
+ Doxygen::parserManager->getParser(inc->extension())
+ ->parseCode(m_ci,
+ inc->context(),
+ extractBlock(inc->text(),inc->blockId()),
+ langExt,
+ inc->isExample(),
+ inc->exampleFile(),
+ &fd,
+ lineBlock(inc->text(),inc->blockId()),
+ -1, // endLine
+ FALSE, // inlineFragment
+ 0, // memberDef
+ TRUE // show line number
+ );
+ m_t << "\\end{DoxyCodeInclude}" << endl;
+ }
+ break;
case DocInclude::SnippetDoc:
case DocInclude::IncludeDoc:
err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
diff --git a/src/mandocvisitor.cpp b/src/mandocvisitor.cpp
index 771cd80..2233cc6 100644
--- a/src/mandocvisitor.cpp
+++ b/src/mandocvisitor.cpp
@@ -306,6 +306,33 @@ void ManDocVisitor::visit(DocInclude *inc)
m_t << ".PP" << endl;
m_firstCol=TRUE;
break;
+ case DocInclude::SnipWithLines:
+ {
+ if (!m_firstCol) m_t << endl;
+ m_t << ".PP" << endl;
+ m_t << ".nf" << endl;
+ QFileInfo cfi( inc->file() );
+ FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
+ Doxygen::parserManager->getParser(inc->extension())
+ ->parseCode(m_ci,
+ inc->context(),
+ extractBlock(inc->text(),inc->blockId()),
+ langExt,
+ inc->isExample(),
+ inc->exampleFile(),
+ &fd,
+ lineBlock(inc->text(),inc->blockId()),
+ -1, // endLine
+ FALSE, // inlineFragment
+ 0, // memberDef
+ TRUE // show line number
+ );
+ if (!m_firstCol) m_t << endl;
+ m_t << ".fi" << endl;
+ m_t << ".PP" << endl;
+ m_firstCol=TRUE;
+ }
+ break;
case DocInclude::SnippetDoc:
case DocInclude::IncludeDoc:
err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp
index 0cd9911..ef5cbc2 100644
--- a/src/perlmodgen.cpp
+++ b/src/perlmodgen.cpp
@@ -716,6 +716,7 @@ void PerlModDocVisitor::visit(DocInclude *inc)
case DocInclude::LatexInclude: type = "latexonly"; break;
case DocInclude::VerbInclude: type = "preformatted"; break;
case DocInclude::Snippet: return;
+ case DocInclude::SnipWithLines: return;
case DocInclude::SnippetDoc:
case DocInclude::IncludeDoc:
err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
diff --git a/src/printdocvisitor.h b/src/printdocvisitor.h
index 499fac2..d1dbb74 100644
--- a/src/printdocvisitor.h
+++ b/src/printdocvisitor.h
@@ -171,6 +171,7 @@ class PrintDocVisitor : public DocVisitor
case DocInclude::LatexInclude: printf("latexinclude"); break;
case DocInclude::VerbInclude: printf("verbinclude"); break;
case DocInclude::Snippet: printf("snippet"); break;
+ case DocInclude::SnipWithLines: printf("snipwithlines"); break;
case DocInclude::SnippetDoc:
case DocInclude::IncludeDoc:
err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
diff --git a/src/pycode.l b/src/pycode.l
index 3935107..a31a0ed 100644
--- a/src/pycode.l
+++ b/src/pycode.l
@@ -1534,8 +1534,8 @@ static void adjustScopesAndSuites(unsigned indentLength)
void parsePythonCode(CodeOutputInterface &od,const char * /*className*/,
const QCString &s,bool exBlock, const char *exName,
- FileDef *fd,int startLine,int endLine,bool /*inlineFragment*/,
- MemberDef *,bool,Definition *searchCtx,bool collectXRefs)
+ FileDef *fd,int startLine,int endLine,bool inlineFragment,
+ MemberDef *,bool,Definition *searchCtx,bool collectXRefs)
{
//printf("***parseCode()\n");
@@ -1551,22 +1551,22 @@ void parsePythonCode(CodeOutputInterface &od,const char * /*className*/,
g_needsTermination = FALSE;
g_searchCtx=searchCtx;
g_collectXRefs=collectXRefs;
- if (endLine!=-1)
- g_inputLines = endLine+1;
- else
- g_inputLines = countLines();
-
if (startLine!=-1)
g_yyLineNr = startLine;
else
g_yyLineNr = 1;
+ if (endLine!=-1)
+ g_inputLines = endLine+1;
+ else
+ g_inputLines = g_yyLineNr + countLines() - 1;
+
g_exampleBlock = exBlock;
g_exampleName = exName;
g_sourceFileDef = fd;
bool cleanupSourceDef = FALSE;
- if (fd==0)
+ if (exBlock && fd==0)
{
// create a dummy filedef for the example
g_sourceFileDef = new FileDef("",(exName?exName:"generated"));
@@ -1577,6 +1577,7 @@ void parsePythonCode(CodeOutputInterface &od,const char * /*className*/,
setCurrentDoc("l00001");
}
+ g_includeCodeFragment = inlineFragment;
// Starts line 1 on the output
startCodeLine();
diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp
index 76da457..c85b638 100644
--- a/src/rtfdocvisitor.cpp
+++ b/src/rtfdocvisitor.cpp
@@ -444,6 +444,30 @@ void RTFDocVisitor::visit(DocInclude *inc)
);
m_t << "}";
break;
+ case DocInclude::SnipWithLines:
+ {
+ QFileInfo cfi( inc->file() );
+ FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
+ m_t << "{" << endl;
+ if (!m_lastIsPara) m_t << "\\par" << endl;
+ m_t << rtf_Style_Reset << getStyle("CodeExample");
+ Doxygen::parserManager->getParser(inc->extension())
+ ->parseCode(m_ci,
+ inc->context(),
+ extractBlock(inc->text(),inc->blockId()),
+ langExt,
+ inc->isExample(),
+ inc->exampleFile(),
+ &fd,
+ lineBlock(inc->text(),inc->blockId()),
+ -1, // endLine
+ FALSE, // inlineFragment
+ 0, // memberDef
+ TRUE // show line number
+ );
+ m_t << "}";
+ }
+ break;
case DocInclude::SnippetDoc:
case DocInclude::IncludeDoc:
err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
diff --git a/src/vhdlcode.l b/src/vhdlcode.l
index 6d2ebcb..ebebc10 100644
--- a/src/vhdlcode.l
+++ b/src/vhdlcode.l
@@ -85,6 +85,7 @@ static int g_yyLineNr; //!< current line number
static bool g_needsTermination;
static Definition *g_searchCtx;
+static bool g_exampleBlock;
static QCString g_exampleName;
static QCString g_exampleFile;
@@ -1504,7 +1505,7 @@ void resetVhdlCodeParserState()
}
void parseVhdlCode(CodeOutputInterface &od,const char *className,const QCString &s,
- bool /*exBlock*/, const char *exName,FileDef *fd,
+ bool exBlock, const char *exName,FileDef *fd,
int startLine,int endLine,bool inlineFragment,
MemberDef *memberDef,bool,Definition *searchCtx,
bool /* collectXRefs */)
@@ -1527,23 +1528,24 @@ void parseVhdlCode(CodeOutputInterface &od,const char *className,const QCString
g_needsTermination = FALSE;
g_searchCtx = searchCtx;
- if (endLine!=-1)
- g_inputLines = endLine+1;
- else
- g_inputLines = countLines();
-
if (startLine!=-1)
g_yyLineNr = startLine;
else
g_yyLineNr = 1;
+ if (endLine!=-1)
+ g_inputLines = endLine+1;
+ else
+ g_inputLines = g_yyLineNr + countLines() - 1;
+
// g_theCallContext.clear();
g_classScope = className;
+ g_exampleBlock = exBlock;
g_exampleName = exName;
g_sourceFileDef = fd;
bool cleanupSourceDef = FALSE;
- if (fd==0)
+ if (exBlock && fd==0)
{
// create a dummy filedef for the example
g_sourceFileDef = new FileDef("",exName);
diff --git a/src/xmlcode.l b/src/xmlcode.l
index fd36ebb..efcac0e 100644
--- a/src/xmlcode.l
+++ b/src/xmlcode.l
@@ -49,6 +49,7 @@ static int g_yyLineNr; //!< current line number
static bool g_needsTermination;
static Definition *g_searchCtx;
+static bool g_exampleBlock;
static QCString g_exampleName;
static QCString g_exampleFile;
@@ -323,12 +324,12 @@ void parseXmlCode(
CodeOutputInterface &od,
const char * /*className*/,
const QCString &s,
- bool /*exBlock*/,
+ bool exBlock,
const char *exName,
FileDef *fd,
int startLine,
int endLine,
- bool /*inlineFragment*/,
+ bool inlineFragment,
MemberDef *,
bool,Definition *searchCtx,
bool /*collectXRefs*/
@@ -345,22 +346,23 @@ void parseXmlCode(
g_needsTermination = FALSE;
g_searchCtx=searchCtx;
- if (endLine!=-1)
- g_inputLines = endLine+1;
- else
- g_inputLines = countLines();
-
if (startLine!=-1)
g_yyLineNr = startLine;
else
g_yyLineNr = 1;
+ if (endLine!=-1)
+ g_inputLines = endLine+1;
+ else
+ g_inputLines = g_yyLineNr + countLines() - 1;
+
+ g_exampleBlock = exBlock;
g_exampleName = exName;
g_sourceFileDef = fd;
bool cleanupSourceDef = FALSE;
- if (fd==0)
+ if (exBlock && fd==0)
{
// create a dummy filedef for the example
g_sourceFileDef = new FileDef("",(exName?exName:"generated"));
@@ -372,6 +374,7 @@ void parseXmlCode(
setCurrentDoc("l00001");
}
+ g_includeCodeFragment = inlineFragment;
// Starts line 1 on the output
startCodeLine();
diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp
index b0d6551..815759e 100644
--- a/src/xmldocvisitor.cpp
+++ b/src/xmldocvisitor.cpp
@@ -329,6 +329,28 @@ void XmlDocVisitor::visit(DocInclude *inc)
);
m_t << "</programlisting>";
break;
+ case DocInclude::SnipWithLines:
+ {
+ m_t << "<programlisting>";
+ QFileInfo cfi( inc->file() );
+ FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
+ Doxygen::parserManager->getParser(inc->extension())
+ ->parseCode(m_ci,
+ inc->context(),
+ extractBlock(inc->text(),inc->blockId()),
+ langExt,
+ inc->isExample(),
+ inc->exampleFile(),
+ &fd,
+ lineBlock(inc->text(),inc->blockId()),
+ -1, // endLine
+ FALSE, // inlineFragment
+ 0, // memberDef
+ TRUE // show line number
+ );
+ m_t << "</programlisting>";
+ }
+ break;
case DocInclude::SnippetDoc:
case DocInclude::IncludeDoc:
err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
diff --git a/testing/014/indexpage.xml b/testing/014/indexpage.xml
index c2fe57a..6f62ef2 100644
--- a/testing/014/indexpage.xml
+++ b/testing/014/indexpage.xml
@@ -6,16 +6,16 @@
<detaileddescription>
<para>
<programlisting>
- <codeline lineno="1">
+ <codeline>
<highlight class="comment">#<sp/>comment<sp/>in<sp/>Python</highlight>
<highlight class="normal"/>
</codeline>
- <codeline lineno="2">
+ <codeline>
<highlight class="normal"/>
<highlight class="keyword">class<sp/></highlight>
<highlight class="normal">Python:</highlight>
</codeline>
- <codeline lineno="3">
+ <codeline>
<highlight class="normal">
<sp/>
<sp/>