1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
|
/******************************************************************************
*
*
*
* Copyright (C) 1997-2002 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation under the terms of the GNU General Public License is hereby
* granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
* Documents produced by Doxygen are derivative works derived from the
* input used in their production; they are not affected by this license.
*
*/
#include "qtbc.h"
#include "memberlist.h"
#include "classlist.h"
#include "filedef.h"
#include "doxygen.h"
#include "memberdef.h"
#include "classdef.h"
#include "namespacedef.h"
#include "util.h"
#include "language.h"
#include "outputlist.h"
#include "dot.h"
#include "message.h"
#include "code.h"
#include "docparser.h"
//#include "xml.h"
/*! create a new file definition, where \a p is the file path,
\a the file name, and \a ref is an HTML anchor name if the
file was read from a tag file or 0 otherwise
*/
FileDef::FileDef(const char *p,const char *nm,const char *lref)
: Definition((QCString)p+nm,1,nm)
{
path=p;
filepath=path+nm;
filename=nm;
diskname=nm;
setReference(lref);
classSDict = new ClassSDict(17);
includeList = new QList<IncludeInfo>;
includeList->setAutoDelete(TRUE);
includeDict = new QDict<IncludeInfo>(61);
includedByList = new QList<IncludeInfo>;
includedByList->setAutoDelete(TRUE);
includedByDict = new QDict<IncludeInfo>(61);
namespaceSDict = new NamespaceSDict;
srcDefDict = 0;
srcMemberDict = 0;
usingDirList = 0;
usingDeclList = 0;
package = 0;
isSource = FALSE;
docname = nm;
if (Config_getBool("FULL_PATH_NAMES"))
{
docname.prepend(stripFromPath(path.copy()));
}
memberGroupSDict = new MemberGroupSDict;
memberGroupSDict->setAutoDelete(TRUE);
}
/*! destroy the file definition */
FileDef::~FileDef()
{
delete classSDict;
delete includeDict;
delete includeList;
delete namespaceSDict;
delete srcDefDict;
delete srcMemberDict;
delete usingDirList;
delete usingDeclList;
delete memberGroupSDict;
}
/*! Compute the HTML anchor names for all members in the class */
void FileDef::computeAnchors()
{
setAnchors(0,'a',&allMemberList);
}
void FileDef::distributeMemberGroupDocumentation()
{
//printf("FileDef::distributeMemberGroupDocumentation()\n");
MemberGroupSDict::Iterator mgli(*memberGroupSDict);
MemberGroup *mg;
for (;(mg=mgli.current());++mgli)
{
mg->distributeMemberGroupDocumentation();
}
}
void FileDef::findSectionsInDocumentation()
{
docFindSections(documentation(),0,this,0,docFile());
MemberGroupSDict::Iterator mgli(*memberGroupSDict);
MemberGroup *mg;
for (;(mg=mgli.current());++mgli)
{
mg->findSectionsInDocumentation();
}
decDefineMembers.findSectionsInDocumentation();
decProtoMembers.findSectionsInDocumentation();
decTypedefMembers.findSectionsInDocumentation();
decEnumMembers.findSectionsInDocumentation();
decFuncMembers.findSectionsInDocumentation();
decVarMembers.findSectionsInDocumentation();
}
void FileDef::writeDetailedDocumentation(OutputList &ol)
{
if ((!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF")) ||
!documentation().isEmpty()
)
{
ol.writeRuler();
ol.pushGeneratorState();
//bool latexOn = ol.isEnabled(OutputGenerator::Latex);
//if (latexOn) ol.disable(OutputGenerator::Latex);
ol.disable(OutputGenerator::Latex);
ol.disable(OutputGenerator::RTF);
ol.writeAnchor(0,"_details");
//if (latexOn) ol.enable(OutputGenerator::Latex);
ol.popGeneratorState();
ol.startGroupHeader();
ol.parseText(theTranslator->trDetailedDescription());
ol.endGroupHeader();
if (!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF"))
{
ol.parseDoc(briefFile(),briefLine(),0,0,briefDescription(),FALSE);
}
if (!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF") &&
!documentation().isEmpty())
{
ol.pushGeneratorState();
ol.disable(OutputGenerator::Man);
ol.newParagraph();
ol.enableAll();
ol.disableAllBut(OutputGenerator::Man);
ol.writeString("\n\n");
ol.popGeneratorState();
}
if (!documentation().isEmpty())
{
//if (doc.at(dl-1)!='.' && doc.at(dl-1)!='!' && doc.at(dl-1)!='?')
// doc+='.';
ol.parseDoc(docFile(),docLine(),0,0,documentation()+"\n",FALSE);
}
//printf("Writing source ref for file %s\n",name().data());
if (Config_getBool("SOURCE_BROWSER"))
{
ol.newParagraph();
QCString refText = theTranslator->trDefinedInSourceFile();
int fileMarkerPos = refText.find("@0");
if (fileMarkerPos!=-1) // should always pass this.
{
ol.parseText(refText.left(fileMarkerPos)); //text left from marker 1
ol.writeObjectLink(0,getSourceFileBase(),
0,name());
ol.parseText(refText.right(
refText.length()-fileMarkerPos-2)); // text right from marker 2
}
}
}
}
/*! Write the documentation page for this file to the file of output
generators \a ol.
*/
void FileDef::writeDocumentation(OutputList &ol)
{
//funcList->countDecMembers();
//QCString fn = name();
//if (Config_getBool("FULL_PATH_NAMES"))
//{
// fn.prepend(stripFromPath(getPath().copy()));
//}
//printf("WriteDocumentation diskname=%s\n",diskname.data());
QCString pageTitle=name()+" File Reference";
startFile(ol,getOutputFileBase(),name(),pageTitle);
startTitle(ol,getOutputFileBase());
ol.parseText(theTranslator->trFileReference(docname));
addGroupListToTitle(ol,this);
endTitle(ol,getOutputFileBase(),docName());
//ol.newParagraph();
if (!Config_getString("GENERATE_TAGFILE").isEmpty())
{
Doxygen::tagFile << " <compound kind=\"file\">" << endl;
Doxygen::tagFile << " <name>" << convertToXML(name()) << "</name>" << endl;
Doxygen::tagFile << " <path>" << convertToXML(getPath()) << "</path>" << endl;
Doxygen::tagFile << " <filename>"
<< convertToXML(getOutputFileBase())
<< "</filename>" << endl;
}
ol.startTextBlock();
if (Config_getBool("DETAILS_AT_TOP"))
{
writeDetailedDocumentation(ol);
ol.newParagraph();
}
else if (briefDescription())
{
ol.parseDoc(briefFile(),briefLine(),0,0,briefDescription(),FALSE);
ol.writeString(" \n");
ol.disableAllBut(OutputGenerator::Html);
ol.startTextLink(0,"_details");
ol.parseText(theTranslator->trMore());
ol.endTextLink();
ol.enableAll();
ol.disable(OutputGenerator::Man);
ol.newParagraph();
ol.enable(OutputGenerator::Man);
}
ol.writeSynopsis();
if (Config_getBool("SHOW_INCLUDE_FILES"))
{
ol.startTextBlock(TRUE);
QListIterator<IncludeInfo> ili(*includeList);
IncludeInfo *ii;
for (;(ii=ili.current());++ili)
{
FileDef *fd=ii->fileDef;
bool isIDLorJava = FALSE;
if (fd)
{
isIDLorJava = fd->name().right(4)==".idl" ||
fd->name().right(5)==".java";
}
ol.startTypewriter();
if (isIDLorJava)
{
ol.docify("import ");
}
else
{
ol.docify("#include ");
}
if (ii->local || isIDLorJava)
ol.docify("\"");
else
ol.docify("<");
ol.disable(OutputGenerator::Html);
ol.docify(ii->includeName);
ol.enableAll();
ol.disableAllBut(OutputGenerator::Html);
// Here we use the include file name as it appears in the file.
// we could also we the name as it is used within doxygen,
// then we should have used fd->docName() instead of ii->includeName
if (fd && fd->isLinkable())
{
ol.writeObjectLink(fd->getReference(),
fd->generateSourceFile() ? fd->includeName() : fd->getOutputFileBase(),
0,ii->includeName);
if (!Config_getString("GENERATE_TAGFILE").isEmpty() && !fd->isReference())
{
const char *locStr = (ii->local || isIDLorJava) ? "yes" : "no";
Doxygen::tagFile << " <includes id=\""
<< convertToXML(fd->getOutputFileBase())
<< "\" name=\""
<< convertToXML(fd->name())
<< "\" local=\"" << locStr << "\">"
<< convertToXML(ii->includeName)
<< "</includes>"
<< endl;
}
}
else
{
ol.docify(ii->includeName);
}
ol.enableAll();
if (ii->local || isIDLorJava)
ol.docify("\"");
else
ol.docify(">");
if (isIDLorJava)
ol.docify(";");
ol.endTypewriter();
ol.disable(OutputGenerator::RTF);
ol.lineBreak();
ol.enableAll();
ol.disableAllBut(OutputGenerator::RTF);
ol.newParagraph();
ol.enableAll();
}
ol.endTextBlock();
}
if (Config_getBool("HAVE_DOT") && Config_getBool("INCLUDE_GRAPH"))
{
//printf("Graph for file %s\n",name().data());
DotInclDepGraph incDepGraph(this,FALSE);
if (!incDepGraph.isTrivial())
{
ol.disable(OutputGenerator::Man);
ol.newParagraph();
ol.startInclDepGraph();
ol.parseText(theTranslator->trInclDepGraph(name()));
ol.endInclDepGraph(incDepGraph);
ol.enableAll();
}
//incDepGraph.writeGraph(Config_getString("HTML_OUTPUT"),fd->getOutputFileBase());
}
if (Config_getBool("HAVE_DOT") && Config_getBool("INCLUDED_BY_GRAPH"))
{
//printf("Graph for file %s\n",name().data());
DotInclDepGraph incDepGraph(this,TRUE);
if (!incDepGraph.isTrivial())
{
ol.disable(OutputGenerator::Man);
ol.newParagraph();
ol.startInclDepGraph();
ol.parseText(theTranslator->trInclByDepGraph());
ol.endInclDepGraph(incDepGraph);
ol.enableAll();
}
//incDepGraph.writeGraph(Config_getString("HTML_OUTPUT"),fd->getOutputFileBase());
}
//printf("%s: generateSourceFile()=%d\n",name().data(),generateSourceFile());
if (generateSourceFile())
{
ol.disableAllBut(OutputGenerator::Html);
ol.newParagraph();
ol.startTextLink(includeName(),0);
ol.parseText(theTranslator->trGotoSourceCode());
ol.endTextLink();
ol.enableAll();
}
ol.endTextBlock();
ol.startMemberSections();
if (namespaceSDict->count()>0)
{
NamespaceSDict::Iterator ndi(*namespaceSDict);
NamespaceDef *nd;
bool found=FALSE;
for (ndi.toFirst();(nd=ndi.current());++ndi)
{
if (nd->name().find('@')==-1)
{
if (!found)
{
ol.startMemberHeader();
ol.parseText(theTranslator->trNamespaces());
ol.endMemberHeader();
ol.startMemberList();
found=TRUE;
}
ol.startMemberItem(0);
ol.writeString("namespace ");
ol.insertMemberAlign();
if (nd->isLinkable())
{
ol.writeObjectLink(nd->getReference(),
nd->getOutputFileBase(),
0,
nd->displayName()
);
if (!Config_getString("GENERATE_TAGFILE").isEmpty())
{
Doxygen::tagFile << " <namespace>" << convertToXML(nd->name()) << "</namespace>" << endl;
}
}
else
{
ol.startBold();
ol.docify(nd->displayName());
ol.endBold();
}
ol.endMemberItem();
}
}
if (found) ol.endMemberList();
}
classSDict->writeDeclaration(ol);
/* write user defined member groups */
MemberGroupSDict::Iterator mgli(*memberGroupSDict);
MemberGroup *mg;
for (;(mg=mgli.current());++mgli)
{
if (mg->header()!="[NOHEADER]")
{
mg->writeDeclarations(ol,0,0,this,0);
}
}
//allMemberList.writeDeclarations(ol,0,0,this,0,0,0);
decDefineMembers.writeDeclarations(ol,0,0,this,0,theTranslator->trDefines(),0);
decProtoMembers.writeDeclarations(ol,0,0,this,0,theTranslator->trFuncProtos(),0);
decTypedefMembers.writeDeclarations(ol,0,0,this,0,theTranslator->trTypedefs(),0);
decEnumMembers.writeDeclarations(ol,0,0,this,0,theTranslator->trEnumerations(),0);
decFuncMembers.writeDeclarations(ol,0,0,this,0,theTranslator->trFunctions(),0);
decVarMembers.writeDeclarations(ol,0,0,this,0,theTranslator->trVariables(),0);
ol.endMemberSections();
if (!Config_getBool("DETAILS_AT_TOP"))
{
writeDetailedDocumentation(ol);
}
docDefineMembers.writeDocumentation(ol,name(),this,
theTranslator->trDefineDocumentation());
docProtoMembers.writeDocumentation(ol,name(),this,
theTranslator->trFunctionPrototypeDocumentation());
docTypedefMembers.writeDocumentation(ol,name(),this,
theTranslator->trTypedefDocumentation());
docEnumMembers.writeDocumentation(ol,name(),this,
theTranslator->trEnumerationTypeDocumentation());
docFuncMembers.writeDocumentation(ol,name(),this,
theTranslator->trFunctionDocumentation());
docVarMembers.writeDocumentation(ol,name(),this,
theTranslator->trVariableDocumentation());
// write Author section (Man only)
ol.disableAllBut(OutputGenerator::Man);
ol.startGroupHeader();
ol.parseText(theTranslator->trAuthor(TRUE,TRUE));
ol.endGroupHeader();
ol.parseText(theTranslator->trGeneratedAutomatically(Config_getString("PROJECT_NAME")));
ol.enableAll();
if (!Config_getString("GENERATE_TAGFILE").isEmpty())
{
writeDocAnchorsToTagFile();
Doxygen::tagFile << " </compound>" << endl;
}
endFile(ol);
}
/*! Write a source listing of this file to the output */
void FileDef::writeSource(OutputList &ol)
{
ol.disableAllBut(OutputGenerator::Html);
startFile(ol,getSourceFileBase(),0,docname+" Source File");
startTitle(ol,0);
ol.parseText(docname);
endTitle(ol,0,0);
if (isLinkable())
{
ol.startTextLink(getOutputFileBase(),0);
ol.parseText(theTranslator->trGotoDocumentation());
ol.endTextLink();
}
initParseCodeContext();
ol.startCodeFragment();
parseCode(ol,0,
fileToString(absFilePath(),Config_getBool("FILTER_SOURCE_FILES")),
FALSE,0,this
);
ol.endCodeFragment();
endFile(ol);
ol.enableAll();
}
void FileDef::addMembersToMemberGroup()
{
::addMembersToMemberGroup(&decDefineMembers,memberGroupSDict);
::addMembersToMemberGroup(&decProtoMembers,memberGroupSDict);
::addMembersToMemberGroup(&decTypedefMembers,memberGroupSDict);
::addMembersToMemberGroup(&decEnumMembers,memberGroupSDict);
::addMembersToMemberGroup(&decFuncMembers,memberGroupSDict);
::addMembersToMemberGroup(&decVarMembers,memberGroupSDict);
}
/*! Adds member definition \a md to the list of all members of this file */
void FileDef::insertMember(MemberDef *md)
{
//printf("%s:FileDef::insertMember(%s)\n",name().data(),md->name().data());
allMemberList.append(md);
bool sortMemberDocs = Config_getBool("SORT_MEMBER_DOCS");
switch(md->memberType())
{
case MemberDef::Variable:
case MemberDef::Property:
decVarMembers.append(md);
if (sortMemberDocs)
docVarMembers.inSort(md);
else
docVarMembers.append(md);
break;
case MemberDef::Function:
decFuncMembers.append(md);
if (sortMemberDocs)
docFuncMembers.inSort(md);
else
docFuncMembers.append(md);
break;
case MemberDef::Typedef:
decTypedefMembers.append(md);
if (sortMemberDocs)
docTypedefMembers.inSort(md);
else
docTypedefMembers.append(md);
break;
case MemberDef::Enumeration:
decEnumMembers.append(md);
if (sortMemberDocs)
docEnumMembers.inSort(md);
else
docEnumMembers.append(md);
break;
case MemberDef::EnumValue: // enum values are shown inside their enums
break;
case MemberDef::Prototype:
decProtoMembers.append(md);
if (sortMemberDocs)
docProtoMembers.inSort(md);
else
docProtoMembers.append(md);
break;
case MemberDef::Define:
decDefineMembers.append(md);
if (sortMemberDocs)
docDefineMembers.inSort(md);
else
docDefineMembers.append(md);
break;
default:
err("FileDef::insertMembers(): "
"member `%s' with class scope `%s' inserted in file scope `%s'!\n",
md->name().data(),
md->getClassDef() ? md->getClassDef()->name().data() : "",
name().data());
}
//addMemberToGroup(md,groupId);
}
/*! Adds compound definition \a cd to the list of all compounds of this file */
void FileDef::insertClass(ClassDef *cd)
{
if (Config_getBool("SORT_MEMBER_DOCS"))
classSDict->inSort(cd->name(),cd);
else
classSDict->append(cd->name(),cd);
}
/*! Adds namespace definition \a nd to the list of all compounds of this file */
void FileDef::insertNamespace(NamespaceDef *nd)
{
if (!nd->name().isEmpty() && namespaceSDict->find(nd->name())==0)
{
if (Config_getBool("SORT_MEMBER_DOCS"))
namespaceSDict->inSort(nd->name(),nd);
else
namespaceSDict->append(nd->name(),nd);
}
}
void FileDef::addSourceRef(int line,Definition *d,MemberDef *md)
{
if (d)
{
if (srcDefDict==0) srcDefDict = new QIntDict<Definition>(257);
if (srcMemberDict==0) srcMemberDict = new QIntDict<MemberDef>(257);
srcDefDict->insert(line,d);
if (md) srcMemberDict->insert(line,md);
//printf("Adding member %s with anchor %s at line %d to file %s\n",
// d->name().data(),anchor,line,name().data());
}
}
Definition *FileDef::getSourceDefinition(int lineNr)
{
Definition *result=0;
if (srcDefDict)
{
result = srcDefDict->find(lineNr);
}
return result;
}
MemberDef *FileDef::getSourceMember(int lineNr)
{
MemberDef *result=0;
if (srcMemberDict)
{
result = srcMemberDict->find(lineNr);
}
return result;
}
void FileDef::addUsingDirective(NamespaceDef *nd)
{
if (usingDirList==0)
{
usingDirList = new NamespaceList;
}
usingDirList->append(nd);
}
void FileDef::addUsingDeclaration(ClassDef *cd)
{
if (usingDeclList==0)
{
usingDeclList = new ClassList;
}
usingDeclList->append(cd);
}
void FileDef::addIncludeDependency(FileDef *fd,const char *incName,bool local)
{
//printf("FileDef::addIncludeDependency(%p,%s,%d)\n",fd,incName,local);
QCString iName = fd ? fd->absFilePath().data() : incName;
if (!iName.isEmpty() && includeDict->find(iName)==0)
{
IncludeInfo *ii = new IncludeInfo;
ii->fileDef = fd;
ii->includeName = incName;
ii->local = local;
includeList->append(ii);
includeDict->insert(iName,ii);
}
}
void FileDef::addIncludedByDependency(FileDef *fd,const char *incName,bool local)
{
//printf("FileDef::addIncludedByDependency(%p,%s,%d)\n",fd,incName,local);
QCString iName = fd ? fd->absFilePath().data() : incName;
if (!iName.isEmpty() && includedByDict->find(iName)==0)
{
IncludeInfo *ii = new IncludeInfo;
ii->fileDef = fd;
ii->includeName = incName;
ii->local = local;
includedByList->append(ii);
includedByDict->insert(iName,ii);
}
}
bool FileDef::isIncluded(const QCString &name) const
{
if (name.isEmpty()) return FALSE;
return includeDict->find(name)!=0;
}
bool FileDef::generateSourceFile() const
{
QCString extension = name().right(4);
return !isReference() &&
(Config_getBool("SOURCE_BROWSER") ||
(Config_getBool("VERBATIM_HEADERS") && guessSection(name())==Entry::HEADER_SEC)
) &&
extension!=".doc" && extension!=".txt" && extension!=".dox";
}
void FileDef::addListReferences()
{
addRefItem(specialListItems(),
theTranslator->trFile(TRUE,TRUE),
getOutputFileBase(),name()
);
MemberGroupSDict::Iterator mgli(*memberGroupSDict);
MemberGroup *mg;
for (;(mg=mgli.current());++mgli)
{
mg->addListReferences(this);
}
docDefineMembers.addListReferences(this);
docProtoMembers.addListReferences(this);
docTypedefMembers.addListReferences(this);
docEnumMembers.addListReferences(this);
docFuncMembers.addListReferences(this);
docVarMembers.addListReferences(this);
}
|