Skip to content

Commit 46942e9

Browse files
author
Dimitri van Heesch
committed
Merge branch 'master' of github.com:doxygen/doxygen
2 parents 5b2e30a + 725c7e3 commit 46942e9

15 files changed

+225
-31
lines changed

doc/commands.doc

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ documentation:
115115
\refitem cmdimage \\image
116116
\refitem cmdimplements \\implements
117117
\refitem cmdinclude \\include
118+
\refitem cmdincludedoc \\includedoc
118119
\refitem cmdincludelineno \\includelineno
119120
\refitem cmdingroup \\ingroup
120121
\refitem cmdinternal \\internal
@@ -177,6 +178,7 @@ documentation:
177178
\refitem cmdskip \\skip
178179
\refitem cmdskipline \\skipline
179180
\refitem cmdsnippet \\snippet
181+
\refitem cmdsnippetdoc \\snippetdoc
180182
\refitem cmdstartuml \\startuml
181183
\refitem cmdstruct \\struct
182184
\refitem cmdsubpage \\subpage
@@ -2171,8 +2173,8 @@ Commands for displaying examples
21712173
\note Doxygen's special commands do not work inside blocks of code.
21722174
It is allowed to nest C-style comments inside a code block though.
21732175

2174-
\sa sections \ref cmdexample "\\example", \ref cmddontinclude "\\dontinclude", and
2175-
\ref cmdverbatim "\\verbatim".
2176+
\sa sections \ref cmdexample "\\example", \ref cmddontinclude "\\dontinclude",
2177+
\ref cmdverbatim "\\verbatim" and \ref cmdincludedoc "\\includedoc".
21762178

21772179
<hr>
21782180
\section cmdincludelineno \\includelineno <file-name>
@@ -2183,6 +2185,22 @@ Commands for displaying examples
21832185

21842186
\sa section \ref cmdinclude "\\include".
21852187

2188+
<hr>
2189+
\section cmdincludedoc \\includedoc <file-name>
2190+
2191+
\addindex \\includedoc
2192+
This command works the same way as \ref cmdinclude "\\include", but it will include
2193+
the content of the file as if it were at the place where this command is called.
2194+
The result is that the content is parsed by doxygen and placed in the documentation.
2195+
2196+
\note Some commands like \ref cmdcond "\\cond" and \ref cmdif "\\if" don't work with
2197+
this command due to the moment of parsing.
2198+
2199+
\note The included documentation should not have comment signs in it as the will appear
2200+
in the documentation as well.
2201+
2202+
\sa section \ref cmdinclude "\\include".
2203+
21862204
<hr>
21872205
\section cmdline \\line ( pattern )
21882206

@@ -2285,6 +2303,23 @@ Commands for displaying examples
22852303
see section \ref cmddontinclude "\\dontinclude" for an alternative way
22862304
to include fragments of a source file that does not require markers.
22872305

2306+
\sa section \ref cmdsnippetdoc "\\snippetdoc".
2307+
<hr>
2308+
\section cmdsnippetdoc \\snippetdoc <file-name> ( block_id )
2309+
2310+
\addindex \\snippetdoc
2311+
This command works the same way as \ref cmdsnippet "\\snippet", but it will include
2312+
the content of the file between the `block-id`s as if it were at the place where this command is called.
2313+
The result is that the content is parsed by doxygen and placed in the documentation.
2314+
2315+
\note Some commands like \ref cmdcond "\\cond" and \ref cmdif "\\if" don't work with
2316+
this command due to the moment of parsing.
2317+
2318+
\note The included documentation should not have comment signs in it as the will appear
2319+
in the documentation as well.
2320+
2321+
\sa section \ref cmdsnippet "\\snippet" and \ref cmdincludedoc "\\includedoc".
2322+
22882323
<hr>
22892324
\section cmduntil \\until ( pattern )
22902325

@@ -3177,8 +3212,9 @@ class Receiver
31773212
\c \\verbatim command or the parser will get confused!
31783213

31793214
\sa sections \ref cmdcode "\\code",
3180-
\ref cmdendverbatim "\\endverbatim", and
3181-
\ref cmdverbinclude "\\verbinclude".
3215+
\ref cmdendverbatim "\\endverbatim",
3216+
\ref cmdverbinclude "\\verbinclude", and
3217+
\ref cmdverbincludedooc "\\verbincludedooc".
31823218

31833219
<hr>
31843220
\section cmdxmlonly \\xmlonly

src/cmdmapper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ CommandMap cmdMap[] =
8888
{ "secreflist", CMD_SECREFLIST },
8989
{ "section", CMD_SECTION },
9090
{ "snippet", CMD_SNIPPET },
91+
{ "snippetdoc", CMD_SNIPPETDOC },
9192
{ "subpage", CMD_SUBPAGE },
9293
{ "subsection", CMD_SUBSECTION },
9394
{ "subsubsection", CMD_SUBSUBSECTION },
@@ -130,6 +131,7 @@ CommandMap cmdMap[] =
130131
{ "manonly", CMD_MANONLY },
131132
{ "endmanonly", CMD_ENDMANONLY },
132133
{ "includelineno", CMD_INCWITHLINES },
134+
{ "includedoc", CMD_INCLUDEDOC },
133135
{ "inheritdoc", CMD_INHERITDOC },
134136
{ "mscfile", CMD_MSCFILE },
135137
{ "rtfonly", CMD_RTFONLY },

src/cmdmapper.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ enum CommandType
133133
CMD_SETSCOPE = 103,
134134
CMD_PUNT = 104,
135135
CMD_PLUS = 105,
136-
CMD_MINUS = 106
136+
CMD_MINUS = 106,
137+
CMD_INCLUDEDOC = 107,
138+
CMD_SNIPPETDOC = 108
137139
};
138140

139141
enum HtmlTagType

src/docparser.cpp

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ struct DocParserContext
123123
QStack<DocStyleChange> initialStyleStack;
124124
QList<Definition> copyStack;
125125
QCString fileName;
126+
int lineNo;
126127
QCString relPath;
127128

128129
bool hasParamCommand;
@@ -144,7 +145,6 @@ struct DocParserContext
144145
static QStack<DocParserContext> g_parserStack;
145146

146147
//---------------------------------------------------------------------------
147-
148148
static void docParserPushContext(bool saveParamInfo=TRUE)
149149
{
150150
//QCString indent;
@@ -163,6 +163,7 @@ static void docParserPushContext(bool saveParamInfo=TRUE)
163163
ctx->initialStyleStack = g_initialStyleStack;
164164
ctx->copyStack = g_copyStack;
165165
ctx->fileName = g_fileName;
166+
ctx->lineNo = doctokenizerYYlineno;
166167
ctx->relPath = g_relPath;
167168

168169
if (saveParamInfo)
@@ -201,6 +202,7 @@ static void docParserPopContext(bool keepParamInfo=FALSE)
201202
g_initialStyleStack = ctx->initialStyleStack;
202203
g_copyStack = ctx->copyStack;
203204
g_fileName = ctx->fileName;
205+
doctokenizerYYlineno = ctx->lineNo;
204206
g_relPath = ctx->relPath;
205207

206208
if (!keepParamInfo)
@@ -5140,7 +5142,6 @@ void DocPara::handleRef(const QCString &cmdName)
51405142
doctokenizerYYsetStatePara();
51415143
}
51425144

5143-
51445145
void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t)
51455146
{
51465147
DBG(("handleInclude(%s)\n",qPrint(cmdName)));
@@ -5168,7 +5169,7 @@ void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t)
51685169
}
51695170
QCString fileName = g_token->name;
51705171
QCString blockId;
5171-
if (t==DocInclude::Snippet)
5172+
if (t==DocInclude::Snippet || t==DocInclude::SnippetDoc)
51725173
{
51735174
if (fileName == "this") fileName=g_fileName;
51745175
doctokenizerYYsetStateSnippet();
@@ -5182,9 +5183,31 @@ void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t)
51825183
}
51835184
blockId = "["+g_token->name+"]";
51845185
}
5185-
DocInclude *inc = new DocInclude(this,fileName,g_context,t,g_isExample,g_exampleName,blockId);
5186-
m_children.append(inc);
5187-
inc->parse();
5186+
5187+
// This is the only place to handle the \includedoc and \snippetdoc commands,
5188+
// as the content is included here as if it is really here.
5189+
if (t==DocInclude::IncludeDoc || t==DocInclude::SnippetDoc)
5190+
{
5191+
QCString inc_text;
5192+
int inc_line = 1;
5193+
readTextFileByName(fileName,inc_text);
5194+
if (t==DocInclude::SnippetDoc)
5195+
{
5196+
inc_line = lineBlock(inc_text, blockId);
5197+
inc_text = extractBlock(inc_text, blockId);
5198+
}
5199+
docParserPushContext();
5200+
g_fileName = fileName;
5201+
doctokenizerYYlineno=inc_line;
5202+
internalValidatingParseDoc(this,m_children,inc_text);
5203+
docParserPopContext();
5204+
}
5205+
else
5206+
{
5207+
DocInclude *inc = new DocInclude(this,fileName,g_context,t,g_isExample,g_exampleName,blockId);
5208+
m_children.append(inc);
5209+
inc->parse();
5210+
}
51885211
}
51895212

51905213
void DocPara::handleSection(const QCString &cmdName)
@@ -5419,15 +5442,15 @@ int DocPara::handleCommand(const QCString &cmdName)
54195442
break;
54205443
case CMD_LI:
54215444
{
5422-
DocSimpleList *sl=new DocSimpleList(this);
5423-
m_children.append(sl);
5445+
DocSimpleList *sl=new DocSimpleList(this);
5446+
m_children.append(sl);
54245447
retval = sl->parse();
54255448
}
54265449
break;
54275450
case CMD_SECTION:
54285451
{
54295452
handleSection(cmdName);
5430-
retval = RetVal_Section;
5453+
retval = RetVal_Section;
54315454
}
54325455
break;
54335456
case CMD_SUBSECTION:
@@ -5673,6 +5696,12 @@ int DocPara::handleCommand(const QCString &cmdName)
56735696
case CMD_SNIPPET:
56745697
handleInclude(cmdName,DocInclude::Snippet);
56755698
break;
5699+
case CMD_INCLUDEDOC:
5700+
handleInclude(cmdName,DocInclude::IncludeDoc);
5701+
break;
5702+
case CMD_SNIPPETDOC:
5703+
handleInclude(cmdName,DocInclude::SnippetDoc);
5704+
break;
56765705
case CMD_SKIP:
56775706
handleIncludeOperator(cmdName,DocIncOperator::Skip);
56785707
break;
@@ -6160,8 +6189,7 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta
61606189
case XML_INHERITDOC:
61616190
handleInheritDoc();
61626191
break;
6163-
6164-
default:
6192+
default:
61656193
// we should not get here!
61666194
ASSERT(0);
61676195
break;

src/docparser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ class DocVerbatim : public DocNode
483483
class DocInclude : public DocNode
484484
{
485485
public:
486-
enum Type { Include, DontInclude, VerbInclude, HtmlInclude, LatexInclude, IncWithLines, Snippet };
486+
enum Type { Include, DontInclude, VerbInclude, HtmlInclude, LatexInclude, IncWithLines, Snippet , IncludeDoc, SnippetDoc};
487487
DocInclude(DocNode *parent,const QCString &file,
488488
const QCString context, Type t,
489489
bool isExample,const QCString exampleFile,

src/fortranscanner.l

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ SCOPENAME ({ID}{BS}"::"{BS})*
322322

323323
/*-----------------------------------------------------------------------------------*/
324324

325+
<Prepass>^{BS}[&]*{BS}!.*\n { /* skip lines with just comment. Note code was in free format or has been converted to it */
326+
lineCountPrepass ++;
327+
}
328+
<Prepass>^{BS}\n { /* skip empty lines */
329+
lineCountPrepass ++;
330+
}
325331
<*>^.*\n { // prepass: look for line continuations
326332
functionLine = FALSE;
327333

@@ -1422,6 +1428,7 @@ static const char* prepassFixedForm(const char* contents)
14221428
bool inSingle=FALSE;
14231429
bool inDouble=FALSE;
14241430
bool inBackslash=FALSE;
1431+
bool fullCommentLine=TRUE;
14251432
int newContentsSize = strlen(contents)+3; // \000, \n (when necessary) and one spare character (to avoid reallocation)
14261433
char* newContents = (char*)malloc(newContentsSize);
14271434

@@ -1435,8 +1442,17 @@ static const char* prepassFixedForm(const char* contents)
14351442
char c = contents[i];
14361443
switch(c) {
14371444
case '\n':
1438-
prevLineLength=column;
1439-
prevLineAmpOrExclIndex=getAmpOrExclAtTheEnd(&contents[i-prevLineLength+1], prevLineLength,prevQuote);
1445+
if (!fullCommentLine)
1446+
{
1447+
prevLineLength=column;
1448+
prevLineAmpOrExclIndex=getAmpOrExclAtTheEnd(&contents[i-prevLineLength+1], prevLineLength,prevQuote);
1449+
if (prevLineAmpOrExclIndex == -1) prevLineAmpOrExclIndex = column - 1;
1450+
}
1451+
else
1452+
{
1453+
prevLineLength+=column;
1454+
}
1455+
fullCommentLine=TRUE;
14401456
column=0;
14411457
emptyLabel=TRUE;
14421458
commented=FALSE;
@@ -1463,7 +1479,8 @@ static const char* prepassFixedForm(const char* contents)
14631479
case '\\':
14641480
if ((column <= fixedCommentAfter) && (column!=6) && !commented)
14651481
{
1466-
// we have some special cases in respect to strings and exscaped string characters
1482+
// we have some special cases in respect to strings and escaped string characters
1483+
fullCommentLine=FALSE;
14671484
newContents[j]=c;
14681485
if (c == '\\')
14691486
{
@@ -1512,13 +1529,15 @@ static const char* prepassFixedForm(const char* contents)
15121529
}
15131530
else
15141531
{
1532+
if (!commented) fullCommentLine=FALSE;
15151533
newContents[j]=c;
15161534
}
15171535
break;
15181536
}
15191537
// fallthrough
15201538
default:
15211539
if(column==6 && emptyLabel) { // continuation
1540+
if (!commented) fullCommentLine=FALSE;
15221541
if (c != '0') { // 0 not allowed as continuation character, see f95 standard paragraph 3.3.2.3
15231542
newContents[j]=' ';
15241543

@@ -1532,6 +1551,7 @@ static const char* prepassFixedForm(const char* contents)
15321551
} else {
15331552
newContents[j]=c; // , just handle like space
15341553
}
1554+
prevLineLength=0;
15351555
} else if ((column > fixedCommentAfter) && !commented) {
15361556
// first non commented non blank character after position fixedCommentAfter
15371557
if (c != '!') {
@@ -1542,6 +1562,7 @@ static const char* prepassFixedForm(const char* contents)
15421562
newContents[j]=c;
15431563
commented = TRUE;
15441564
} else {
1565+
if (!commented) fullCommentLine=FALSE;
15451566
newContents[j]=c;
15461567
emptyLabel=FALSE;
15471568
}
@@ -2491,7 +2512,11 @@ static void parseMain(const char *fileName,const char *fileBuf,Entry *rt, Fortra
24912512
//printf("---strlen=%d\n", strlen(fileBuf));
24922513
//clock_t start=clock();
24932514

2515+
//printf("Input fixed form string:\n%s\n", fileBuf);
2516+
//printf("===========================\n");
24942517
inputString = prepassFixedForm(fileBuf);
2518+
//printf("Resulting free form string:\n%s\n", inputString);
2519+
//printf("===========================\n");
24952520

24962521
//clock_t end=clock();
24972522
//printf("CPU time used=%f\n", ((double) (end-start))/CLOCKS_PER_SEC);

src/latexdocvisitor.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,14 @@ void LatexDocVisitor::visit(DocInclude *inc)
431431
inc->text(),
432432
langExt,
433433
inc->isExample(),
434-
inc->exampleFile(), &fd);
434+
inc->exampleFile(),
435+
&fd, // fileDef,
436+
-1, // start line
437+
-1, // end line
438+
FALSE, // inline fragment
439+
0, // memberDef
440+
TRUE // show line numbers
441+
);
435442
m_t << "\\end{DoxyCodeInclude}" << endl;
436443
}
437444
break;
@@ -440,7 +447,14 @@ void LatexDocVisitor::visit(DocInclude *inc)
440447
Doxygen::parserManager->getParser(inc->extension())
441448
->parseCode(m_ci,inc->context(),
442449
inc->text(),langExt,inc->isExample(),
443-
inc->exampleFile());
450+
inc->exampleFile(),
451+
0, // fileDef
452+
-1, // startLine
453+
-1, // endLine
454+
TRUE, // inlineFragment
455+
0, // memberDef
456+
FALSE
457+
);
444458
m_t << "\\end{DoxyCodeInclude}\n";
445459
break;
446460
case DocInclude::DontInclude:

0 commit comments

Comments
 (0)