Imported Upstream version 1.8.15
[platform/upstream/doxygen.git] / src / docbookgen.cpp
1 /******************************************************************************
2 *
3 *
4 *
5 * Copyright (C) 1997-2015 by Dimitri van Heesch.
6 *
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation under the terms of the GNU General Public License is hereby
9 * granted. No representations are made about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
11 * See the GNU General Public License for more details.
12 *
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
15 *
16 */
17
18 #include <stdlib.h>
19
20 #include <qdir.h>
21 #include <qfile.h>
22 #include <qtextstream.h>
23 #include <qintdict.h>
24 #include <qregexp.h>
25 #include "docbookgen.h"
26 #include "doxygen.h"
27 #include "message.h"
28 #include "config.h"
29 #include "classlist.h"
30 #include "classdef.h"
31 #include "diagram.h"
32 #include "util.h"
33 #include "defargs.h"
34 #include "outputgen.h"
35 #include "dot.h"
36 #include "pagedef.h"
37 #include "filename.h"
38 #include "version.h"
39 #include "docbookvisitor.h"
40 #include "docparser.h"
41 #include "language.h"
42 #include "parserintf.h"
43 #include "arguments.h"
44 #include "memberlist.h"
45 #include "groupdef.h"
46 #include "memberdef.h"
47 #include "namespacedef.h"
48 #include "membername.h"
49 #include "membergroup.h"
50 #include "dirdef.h"
51 #include "section.h"
52
53 // no debug info
54 #define Docbook_DB(x) do {} while(0)
55 // debug to stdout
56 //#define Docbook_DB(x) printf x
57 // debug inside output
58 //#define Docbook_DB(x) QCString __t;__t.sprintf x;m_t << __t
59
60 #if 0
61 #define DB_GEN_C DB_GEN_C1(t)
62 #define DB_GEN_C1(x) x << "<!-- DB_GEN_C " << __LINE__ << " -->\n";
63 #define DB_GEN_C2(y) DB_GEN_C2a(t,y)
64 #define DB_GEN_C2a(x,y) x << "<!-- DB_GEN_C " << __LINE__ << " " << y << " -->\n";
65 #else
66 #define DB_GEN_C
67 #define DB_GEN_C1(x)
68 #define DB_GEN_C2(y)
69 #define DB_GEN_C2a(x,y)
70 #endif
71 //------------------
72
73 inline void writeDocbookString(FTextStream &t,const char *s)
74 {
75   t << convertToDocBook(s);
76 }
77
78 inline void writeDocbookCodeString(FTextStream &t,const char *s, int &col)
79 {
80   char c;
81   while ((c=*s++))
82   {
83     switch(c)
84     {
85       case '\t':
86         {
87           static int tabSize = Config_getInt(TAB_SIZE);
88           int spacesToNextTabStop = tabSize - (col%tabSize);
89           col+=spacesToNextTabStop;
90           while (spacesToNextTabStop--) t << "&#32;";
91           break;
92         }
93       case ' ':  t << "&#32;"; col++;  break;
94       case '<':  t << "&lt;"; col++;   break;
95       case '>':  t << "&gt;"; col++;   break;
96       case '&':  t << "&amp;"; col++;  break;
97       case '\'': t << "&apos;"; col++; break;
98       case '"':  t << "&quot;"; col++; break;
99       case '\007':  t << "^G"; col++; break; // bell
100       case '\014':  t << "^L"; col++; break; // form feed
101       default:   t << c; col++;        break;
102     }
103   }
104 }
105
106 static void addIndexTerm(FTextStream &t, QCString prim, QCString sec = "")
107 {
108   t << "<indexterm><primary>";
109   t << convertToDocBook(prim);
110   t << "</primary>";
111   if (!sec.isEmpty())
112   {
113     t << "<secondary>";
114     t << convertToDocBook(sec);
115     t << "</secondary>";
116   }
117   t << "</indexterm>" << endl;
118 }
119 void writeDocbookLink(FTextStream &t,const char * /*extRef*/,const char *compoundId,
120     const char *anchorId,const char * text,const char * /*tooltip*/)
121 {
122   t << "<link linkend=\"_" << stripPath(compoundId);
123   if (anchorId) t << "_1" << anchorId;
124   t << "\"";
125   t << ">";
126   writeDocbookString(t,text);
127   t << "</link>";
128 }
129
130 DocbookCodeGenerator::DocbookCodeGenerator(FTextStream &t) : m_lineNumber(-1), m_col(0),
131   m_insideCodeLine(FALSE), m_insideSpecialHL(FALSE)
132 {
133   m_prettyCode=Config_getBool(DOCBOOK_PROGRAMLISTING);
134   setTextStream(t);
135 }
136
137 DocbookCodeGenerator::DocbookCodeGenerator() : m_lineNumber(-1), m_col(0),
138   m_insideCodeLine(FALSE), m_insideSpecialHL(FALSE),  m_streamSet(FALSE)
139 {
140   m_prettyCode=Config_getBool(DOCBOOK_PROGRAMLISTING);
141 }
142
143 DocbookCodeGenerator::~DocbookCodeGenerator() {}
144
145 void DocbookCodeGenerator::codify(const char *text)
146 {
147   Docbook_DB(("(codify \"%s\")\n",text));
148   writeDocbookCodeString(m_t,text,m_col);
149 }
150 void DocbookCodeGenerator::writeCodeLink(const char *ref,const char *file,
151     const char *anchor,const char *name,
152     const char *tooltip)
153 {
154   Docbook_DB(("(writeCodeLink)\n"));
155   writeDocbookLink(m_t,ref,file,anchor,name,tooltip);
156   m_col+=strlen(name);
157 }
158 void DocbookCodeGenerator::writeCodeLinkLine(const char *ref,const char *file,
159     const char *anchor,const char *name,
160     const char *tooltip)
161 {
162   Docbook_DB(("(writeCodeLinkLine)\n"));
163   m_t << "<anchor xml:id=\"_" << stripExtensionGeneral(stripPath(file),".xml");
164   m_t << "_1l";
165   writeDocbookString(m_t,name);
166   m_t << "\"/>";
167   m_col+=strlen(name);
168 }
169 void DocbookCodeGenerator::writeTooltip(const char *, const DocLinkInfo &, const char *,
170                   const char *, const SourceLinkInfo &, const SourceLinkInfo &
171                  )
172 {
173   Docbook_DB(("(writeToolTip)\n"));
174 }
175 void DocbookCodeGenerator::startCodeLine(bool)
176 {
177   Docbook_DB(("(startCodeLine)\n"));
178   m_insideCodeLine=TRUE;
179   m_col=0;
180 }
181 void DocbookCodeGenerator::endCodeLine()
182 {
183   m_t << endl;
184   Docbook_DB(("(endCodeLine)\n"));
185   m_lineNumber = -1;
186   m_refId.resize(0);
187   m_external.resize(0);
188   m_insideCodeLine=FALSE;
189 }
190 void DocbookCodeGenerator::startFontClass(const char *colorClass)
191 {
192   Docbook_DB(("(startFontClass)\n"));
193   m_t << "<emphasis role=\"" << colorClass << "\">";
194   m_insideSpecialHL=TRUE;
195 }
196 void DocbookCodeGenerator::endFontClass()
197 {
198   Docbook_DB(("(endFontClass)\n"));
199   m_t << "</emphasis>"; // non DocBook
200   m_insideSpecialHL=FALSE;
201 }
202 void DocbookCodeGenerator::writeCodeAnchor(const char *)
203 {
204   Docbook_DB(("(writeCodeAnchor)\n"));
205 }
206 void DocbookCodeGenerator::writeLineNumber(const char *ref,const char *fileName,
207     const char *anchor,int l)
208 {
209   Docbook_DB(("(writeLineNumber)\n"));
210   m_insideCodeLine = TRUE;
211   if (m_prettyCode)
212   {
213     QCString lineNumber;
214     lineNumber.sprintf("%05d",l);
215
216     if (fileName && !m_sourceFileName.isEmpty())
217     {
218       writeCodeLinkLine(ref,m_sourceFileName,anchor,lineNumber,0);
219       writeCodeLink(ref,fileName,anchor,lineNumber,0);
220     }
221     else
222     {
223       codify(lineNumber);
224     }
225     m_t << " ";
226   }
227   else
228   {
229     m_t << l << " ";
230   }
231
232 }
233 void DocbookCodeGenerator::setCurrentDoc(Definition *,const char *,bool)
234 {
235 }
236 void DocbookCodeGenerator::addWord(const char *,bool)
237 {
238 }
239 void DocbookCodeGenerator::finish()
240 {
241   if (m_insideCodeLine) endCodeLine();
242 }
243 void DocbookCodeGenerator::startCodeFragment()
244 {
245   m_t << "<literallayout><computeroutput>" << endl;
246 }
247 void DocbookCodeGenerator::endCodeFragment()
248 {
249   m_t << "</computeroutput></literallayout>" << endl;
250 }
251
252 DocbookGenerator::DocbookGenerator() : OutputGenerator()
253 {
254 DB_GEN_C
255   dir=Config_getString(DOCBOOK_OUTPUT);
256   //insideTabbing=FALSE;
257   //firstDescItem=TRUE;
258   //disableLinks=FALSE;
259   //m_indent=0;
260   //templateMemberItem = FALSE;
261   m_prettyCode=Config_getBool(DOCBOOK_PROGRAMLISTING);
262   m_denseText = FALSE;
263   m_inGroup = FALSE;
264   m_inDetail = FALSE;
265   m_levelListItem = 0;
266   m_descTable = FALSE;
267   m_inLevel = -1;
268   m_firstMember = FALSE;
269   for (int i = 0 ; i < sizeof(m_inListItem) / sizeof(*m_inListItem) ; i++) m_inListItem[i] = FALSE;
270   for (int i = 0 ; i < sizeof(m_inSimpleSect) / sizeof(*m_inSimpleSect) ; i++) m_inSimpleSect[i] = FALSE;
271 }
272
273 DocbookGenerator::~DocbookGenerator()
274 {
275 DB_GEN_C
276 }
277
278 void DocbookGenerator::init()
279 {
280   QCString dir=Config_getString(DOCBOOK_OUTPUT);
281   QDir d(dir);
282   if (!d.exists() && !d.mkdir(dir))
283   {
284     err("Could not create output directory %s\n",dir.data());
285     exit(1);
286   }
287
288   createSubDirs(d);
289 }
290
291 void DocbookGenerator::startFile(const char *name,const char *,const char *)
292 {
293 DB_GEN_C
294   QCString fileName=name;
295   QCString pageName;
296   QCString fileType="section";
297   if (fileName == "refman")
298   {
299     fileName="index";
300     fileType="book";
301   }
302   else if (fileName == "index")
303   {
304     fileName="mainpage";
305     fileType="chapter";
306   }
307   pageName = fileName;
308   relPath = relativePathToRoot(fileName);
309   if (fileName.right(4)!=".xml") fileName+=".xml";
310   startPlainFile(fileName);
311   m_codeGen.setTextStream(t);
312   m_codeGen.setRelativePath(relPath);
313   m_codeGen.setSourceFileName(stripPath(fileName));
314
315   t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" << endl;;
316   t << "<" << fileType << " xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"";
317   if (!pageName.isEmpty()) t << " xml:id=\"_" <<  stripPath(pageName) << "\"";
318   t << ">" << endl;
319 }
320
321 void DocbookGenerator::endFile()
322 {
323 DB_GEN_C
324   if (m_inDetail) t << "</section>" << endl;
325   m_inDetail = FALSE;
326   while (m_inLevel != -1)
327   {
328     t << "</section>" << endl;
329     m_inLevel--;
330   }
331   if (m_inGroup) t << "</section>" << endl;
332   m_inGroup = FALSE;
333
334   QCString fileType="section";
335   QCString fileName= m_codeGen.sourceFileName();
336   if (fileName == "index.xml")
337   {
338     fileType="book";
339   }
340   else if (fileName == "mainpage.xml")
341   {
342     fileType="chapter";
343   }
344   t << "</" << fileType << ">" << endl;
345   endPlainFile();
346   m_codeGen.setSourceFileName("");
347 }
348
349 void DocbookGenerator::startIndexSection(IndexSections is)
350 {
351 DB_GEN_C2("IndexSections " << is)
352   switch (is)
353   {
354     case isTitlePageStart:
355       {
356         QCString dbk_projectName = Config_getString(PROJECT_NAME);
357         t << "    <info>" << endl;
358         t << "    <title>" << convertToDocBook(dbk_projectName) << "</title>" << endl;
359         t << "    </info>" << endl;
360       }
361       break;
362     case isTitlePageAuthor:
363       break;
364     case isMainPage:
365       t << "<chapter>" << endl;
366       t << "    <title>";
367       break;
368     case isModuleIndex:
369       //Module Index}\n"
370       break;
371     case isDirIndex:
372       //Directory Index}\n"
373       break;
374     case isNamespaceIndex:
375       //Namespace Index}\n"
376       break;
377     case isClassHierarchyIndex:
378       //Hierarchical Index}\n"
379       break;
380     case isCompoundIndex:
381       //t << "{"; //Class Index}\n"
382       break;
383     case isFileIndex:
384       //Annotated File Index}\n"
385       break;
386     case isPageIndex:
387       //Annotated Page Index}\n"
388       break;
389     case isModuleDocumentation:
390       t << "<chapter>\n";
391       t << "    <title>";
392       break;
393     case isDirDocumentation:
394       t << "<chapter>\n";
395       t << "    <title>";
396       break;
397     case isNamespaceDocumentation:
398       t << "<chapter>\n";
399       t << "    <title>";
400       break;
401     case isClassDocumentation:
402       t << "<chapter>\n";
403       t << "    <title>";
404       break;
405     case isFileDocumentation:
406       t << "<chapter>\n";
407       t << "    <title>";
408       break;
409     case isExampleDocumentation:
410       t << "<chapter>\n";
411       t << "    <title>";
412       break;
413     case isPageDocumentation:
414       break;
415     case isPageDocumentation2:
416       break;
417     case isEndIndex:
418       break;
419   }
420 }
421
422 void DocbookGenerator::endIndexSection(IndexSections is)
423 {
424 DB_GEN_C2("IndexSections " << is)
425   static bool sourceBrowser = Config_getBool(SOURCE_BROWSER);
426   switch (is)
427   {
428     case isTitlePageStart:
429       break;
430     case isTitlePageAuthor:
431       break;
432     case isMainPage:
433       t << "</title>" << endl;
434       t << "    <xi:include href=\"mainpage.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
435       t << "</chapter>" << endl;
436       break;
437     case isModuleIndex:
438       //t << "</chapter>" << endl;
439       break;
440     case isDirIndex:
441       //t << "<xi:include href=\"dirs.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
442       //t << "</chapter>" << endl;
443       break;
444     case isNamespaceIndex:
445       //t << "<xi:include href=\"namespaces.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
446       //t << "</chapter>" << endl;
447       break;
448     case isClassHierarchyIndex:
449       //t << "<xi:include href=\"hierarchy.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
450       //t << "</chapter>" << endl;
451       break;
452     case isCompoundIndex:
453       //t << "</chapter>" << endl;
454       break;
455     case isFileIndex:
456       //t << "<xi:include href=\"files.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
457       //t << "</chapter>" << endl;
458       break;
459     case isPageIndex:
460       //t << "<xi:include href=\"pages.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
461       //t << "</chapter>" << endl;
462       break;
463     case isModuleDocumentation:
464       {
465         t << "</title>" << endl;
466         GroupSDict::Iterator gli(*Doxygen::groupSDict);
467         GroupDef *gd;
468         bool found=FALSE;
469         for (gli.toFirst();(gd=gli.current()) && !found;++gli)
470         {
471           if (!gd->isReference())
472           {
473             t << "    <xi:include href=\"" << gd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
474             found=TRUE;
475           }
476         }
477         for (;(gd=gli.current());++gli)
478         {
479           if (!gd->isReference())
480           {
481             t << "    <xi:include href=\"" << gd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
482           }
483         }
484       }
485       t << "</chapter>\n";
486       break;
487     case isDirDocumentation:
488       {
489         t << "</title>" << endl;
490         SDict<DirDef>::Iterator dli(*Doxygen::directories);
491         DirDef *dd;
492         bool found=FALSE;
493         for (dli.toFirst();(dd=dli.current()) && !found;++dli)
494         {
495           if (dd->isLinkableInProject())
496           {
497             t << "<    xi:include href=\"" << dd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
498             found=TRUE;
499           }
500         }
501         for (;(dd=dli.current());++dli)
502         {
503           if (dd->isLinkableInProject())
504           {
505             t << "    <xi:include href=\"" << dd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
506           }
507         }
508       }
509       t << "</chapter>\n";
510       break;
511     case isNamespaceDocumentation:
512       {
513         t << "</title>" << endl;
514         NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict);
515         NamespaceDef *nd;
516         bool found=FALSE;
517         for (nli.toFirst();(nd=nli.current()) && !found;++nli)
518         {
519           if (nd->isLinkableInProject())
520           {
521             t << "<xi:include href=\"" << nd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
522             found=TRUE;
523           }
524         }
525         while ((nd=nli.current()))
526         {
527           if (nd->isLinkableInProject())
528           {
529             t << "<xi:include href=\"" << nd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
530           }
531           ++nli;
532         }
533       }
534       t << "</chapter>\n";
535       break;
536     case isClassDocumentation:
537       {
538         t << "</title>" << endl;
539         ClassSDict::Iterator cli(*Doxygen::classSDict);
540         ClassDef *cd=0;
541         bool found=FALSE;
542         for (cli.toFirst();(cd=cli.current()) && !found;++cli)
543         {
544           if (cd->isLinkableInProject() &&
545               cd->templateMaster()==0 &&
546              !cd->isEmbeddedInOuterScope()
547              )
548           {
549             t << "    <xi:include href=\"" << cd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
550             found=TRUE;
551           }
552         }
553         for (;(cd=cli.current());++cli)
554         {
555           if (cd->isLinkableInProject() &&
556               cd->templateMaster()==0 &&
557              !cd->isEmbeddedInOuterScope()
558              )
559           {
560             t << "    <xi:include href=\"" << cd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
561           }
562         }
563       }
564       t << "</chapter>\n";
565       break;
566     case isFileDocumentation:
567       {
568         t << "</title>" << endl;
569         bool isFirst=TRUE;
570         FileNameListIterator fnli(*Doxygen::inputNameList);
571         FileName *fn;
572         for (fnli.toFirst();(fn=fnli.current());++fnli)
573         {
574           FileNameIterator fni(*fn);
575           FileDef *fd;
576           for (;(fd=fni.current());++fni)
577           {
578             if (fd->isLinkableInProject())
579             {
580               if (isFirst)
581               {
582                 t << "    <xi:include href=\"" << fd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
583                 if (sourceBrowser && m_prettyCode && fd->generateSourceFile())
584                 {
585                   t << "    <xi:include href=\"" << fd->getSourceFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
586                 }
587                 isFirst=FALSE;
588               }
589               else
590               {
591                 t << "    <xi:include href=\"" << fd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
592                 if (sourceBrowser && m_prettyCode && fd->generateSourceFile())
593                 {
594                   t << "    <xi:include href=\"" << fd->getSourceFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
595                 }
596               }
597             }
598           }
599         }
600       }
601       t << "</chapter>\n";
602       break;
603     case isExampleDocumentation:
604       {
605         t << "</title>" << endl;
606         PageSDict::Iterator pdi(*Doxygen::exampleSDict);
607         PageDef *pd=pdi.toFirst();
608         if (pd)
609         {
610           t << "    <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
611         }
612         for (++pdi;(pd=pdi.current());++pdi)
613         {
614           t << "    <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
615         }
616       }
617       t << "</chapter>\n";
618       break;
619     case isPageDocumentation:
620       break;
621     case isPageDocumentation2:
622       break;
623     case isEndIndex:
624       t << "<index/>" << endl;
625       break;
626   }
627 }
628 void DocbookGenerator::writePageLink(const char *name, bool /*first*/)
629 {
630 DB_GEN_C
631   PageSDict::Iterator pdi(*Doxygen::pageSDict);
632   PageDef *pd = pdi.toFirst();
633   for (pd = pdi.toFirst();(pd=pdi.current());++pdi)
634   {
635     if (!pd->getGroupDef() && !pd->isReference() && pd->name() == stripPath(name))
636     {
637       t << "<chapter>\n";
638       if (!pd->title().isEmpty())
639       {
640         t << "    <title>" << convertToDocBook(pd->title()) << "</title>" << endl;
641       }
642       else
643       {
644         t << "    <title>" << convertToDocBook(pd->name()) << "</title>" << endl;
645       }
646       t << "    <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
647       t << "</chapter>\n";
648     }
649   }
650 }
651 void DocbookGenerator::writeDoc(DocNode *n,Definition *ctx,MemberDef *)
652 {
653 DB_GEN_C
654   DocbookDocVisitor *visitor =
655     new DocbookDocVisitor(t,*this);
656   n->accept(visitor);
657   delete visitor;
658 }
659
660 void DocbookGenerator::startParagraph(const char *)
661 {
662 DB_GEN_C
663   t << "<para>" << endl;
664 }
665
666 void DocbookGenerator::endParagraph()
667 {
668 DB_GEN_C
669   t << "</para>" << endl;
670 }
671 void DocbookGenerator::writeString(const char *text)
672 {
673 DB_GEN_C
674   t << text;
675 }
676 void DocbookGenerator::startMemberHeader(const char *name,int)
677 {
678 DB_GEN_C
679   t << "<simplesect>" << endl;
680   m_inSimpleSect[m_levelListItem] = TRUE;
681   t << "    <title>";
682 }
683
684 void DocbookGenerator::endMemberHeader()
685 {
686 DB_GEN_C
687   t << "    </title>" << endl;
688 }
689 void DocbookGenerator::docify(const char *str)
690 {
691 DB_GEN_C
692   t << convertToDocBook(str);
693 }
694 void DocbookGenerator::writeObjectLink(const char *ref, const char *f,
695                                      const char *anchor, const char *text)
696 {
697 DB_GEN_C
698   if (anchor)
699     if (f) t << "<link linkend=\"_" << stripPath(f) << "_1" << anchor << "\">";
700     else   t << "<link linkend=\"_" << anchor << "\">";
701   else
702     t << "<link linkend=\"_" << stripPath(f) << "\">";
703   docify(text);
704   t << "</link>";
705 }
706 void DocbookGenerator::startMemberList()
707 {
708 DB_GEN_C
709   t << "        <itemizedlist>" << endl;
710   m_levelListItem++;
711 }
712 void DocbookGenerator::endMemberList()
713 {
714 DB_GEN_C
715   if (m_inListItem[m_levelListItem]) t << "</listitem>" << endl;
716   m_inListItem[m_levelListItem] = FALSE;
717   t << "        </itemizedlist>" << endl;
718   m_levelListItem = (m_levelListItem> 0 ?  m_levelListItem - 1 : 0);
719   if (m_inSimpleSect[m_levelListItem]) t << "</simplesect>" << endl;
720   m_inSimpleSect[m_levelListItem] = FALSE;
721 }
722 void DocbookGenerator::startMemberItem(const char *,int,const char *)
723 {
724 DB_GEN_C
725   if (m_inListItem[m_levelListItem]) t << "</listitem>" << endl;
726   t << "            <listitem><para>";
727   m_inListItem[m_levelListItem] = TRUE;
728 }
729 void DocbookGenerator::endMemberItem()
730 {
731 DB_GEN_C
732   t << "</para>" << endl;
733 }
734 void DocbookGenerator::startBold(void)
735 {
736 DB_GEN_C
737   t << "<emphasis role=\"strong\">";
738 }
739 void DocbookGenerator::endBold(void)
740 {
741 DB_GEN_C
742   t << "</emphasis>";
743 }
744 void DocbookGenerator::startGroupHeader(int extraIndentLevel)
745 {
746 DB_GEN_C2("m_inLevel " << m_inLevel)
747 DB_GEN_C2("extraIndentLevel " << extraIndentLevel)
748   m_firstMember = TRUE;
749   if (m_inSimpleSect[m_levelListItem]) t << "</simplesect>" << endl;
750   m_inSimpleSect[m_levelListItem] = FALSE;
751   if (m_inLevel != -1) m_inGroup = TRUE;
752   if (m_inLevel == extraIndentLevel) t << "</section>" << endl;
753   m_inLevel = extraIndentLevel;
754   t << "<section>" << endl;
755   t << "<title>";
756 }
757 void DocbookGenerator::writeRuler(void)
758 {
759 DB_GEN_C2("m_inLevel " << m_inLevel)
760 DB_GEN_C2("m_inGroup " << m_inGroup)
761   if (m_inGroup) t << "</section>" << endl;
762   m_inGroup = FALSE;
763 }
764
765 void DocbookGenerator::endGroupHeader(int)
766 {
767 DB_GEN_C
768   t << "</title>" << endl;
769 }
770
771 void DocbookGenerator::startParameterList(bool openBracket)
772 {
773 DB_GEN_C
774   if (openBracket) t << "(";
775 }
776 void DocbookGenerator::endParameterList()
777 {
778 DB_GEN_C
779 }
780 void DocbookGenerator::writeNonBreakableSpace(int n)
781 {
782 DB_GEN_C
783   for (int i=0;i<n;i++) t << " ";
784 }
785 void DocbookGenerator::lineBreak(const char *)
786 {
787 DB_GEN_C
788   t << endl;
789 }
790 void DocbookGenerator::startTypewriter()
791 {
792 DB_GEN_C
793   if (!m_denseText) t << "<computeroutput>";
794 }
795 void DocbookGenerator::endTypewriter()
796 {
797 DB_GEN_C
798   if (!m_denseText) t << "</computeroutput>" << endl;
799 }
800 void DocbookGenerator::startTextBlock(bool dense)
801 {
802 DB_GEN_C
803   if (dense)
804   {
805     m_denseText = TRUE;
806     t << "<programlisting>";
807   }
808 }
809 void DocbookGenerator::endTextBlock(bool dense)
810 {
811 DB_GEN_C
812   if (m_denseText)
813   {
814     m_denseText = FALSE;
815     t << "</programlisting>";
816   }
817 }
818 void DocbookGenerator::startMemberDoc(const char *clname, const char *memname, const char *anchor, const char *title,
819                                       int memCount, int memTotal, bool showInline)
820 {
821 DB_GEN_C2("m_inLevel " << m_inLevel)
822   t << "    <section>" << endl;
823   t << "    <title>" << convertToDocBook(title);
824   if (memTotal>1)
825   {
826     t << "<computeroutput>[" << memCount << "/" << memTotal << "]</computeroutput>";
827   }
828   t << "</title>" << endl;
829   if (memname && memname[0]!='@')
830   {
831     addIndexTerm(t,memname,clname);
832     addIndexTerm(t,clname,memname);
833   }
834 }
835 void DocbookGenerator::endMemberDoc(bool)
836 {
837 DB_GEN_C
838   t << "</computeroutput></para>";
839 }
840 void DocbookGenerator::startTitleHead(const char *)
841 {
842 DB_GEN_C
843   t << "<title>";
844 }
845 void DocbookGenerator::endTitleHead(const char *fileName,const char *name)
846 {
847 DB_GEN_C
848   t << "</title>" << endl;
849   if (name) addIndexTerm(t, name);
850 }
851 void DocbookGenerator::startDoxyAnchor(const char *fName,const char *manName,
852                                  const char *anchor,const char *name,
853                                  const char *args)
854 {
855 DB_GEN_C
856   if (!m_inListItem[m_levelListItem] && !m_descTable)
857   {
858     if (!m_firstMember) t << "    </section>";
859     m_firstMember = FALSE;
860   }
861   if (anchor)
862   {
863     t << "<anchor xml:id=\"_" << stripPath(fName) << "_1" << anchor << "\"/>";
864   }
865 }
866 void DocbookGenerator::endDoxyAnchor(const char *fileName,const char *anchor)
867 {
868 DB_GEN_C
869 }
870 void DocbookGenerator::startMemberDocName(bool)
871 {
872 DB_GEN_C
873   t << "<para><computeroutput>";
874 }
875 void DocbookGenerator::endMemberDocName()
876 {
877 DB_GEN_C
878 }
879 void DocbookGenerator::startMemberGroupHeader(bool hasHeader)
880 {
881 DB_GEN_C
882   t << "<simplesect><title>";
883 }
884 void DocbookGenerator::endMemberGroupHeader()
885 {
886 DB_GEN_C
887   t << "</title>" << endl;
888 }
889 void DocbookGenerator::startMemberGroup()
890 {
891 DB_GEN_C
892 }
893 void DocbookGenerator::endMemberGroup(bool)
894 {
895 DB_GEN_C
896   t << "</simplesect>" << endl;
897 }
898 void DocbookGenerator::startClassDiagram()
899 {
900 DB_GEN_C
901   t << "<para>";
902 }
903
904 void DocbookGenerator::endClassDiagram(const ClassDiagram &d, const char *fileName,const char *)
905 {
906 DB_GEN_C
907   t << "    <informalfigure>" << endl;
908   t << "        <mediaobject>" << endl;
909   t << "            <imageobject>" << endl;
910   t << "                <imagedata width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" 
911                          << relPath << fileName << ".png\">" << "</imagedata>" << endl;
912   t << "            </imageobject>" << endl;
913   d.writeImage(t,dir,relPath,fileName,FALSE);
914   t << "        </mediaobject>" << endl;
915   t << "    </informalfigure>" << endl;
916   t << "</para>" << endl;
917 }
918 void  DocbookGenerator::startLabels()
919 {
920 DB_GEN_C
921 }
922
923 void  DocbookGenerator::writeLabel(const char *l,bool isLast)
924 {
925 DB_GEN_C
926   t << "<computeroutput>[" << l << "]</computeroutput>";
927   if (!isLast) t << ", ";
928 }
929
930 void  DocbookGenerator::endLabels()
931 {
932 DB_GEN_C
933 }
934 void DocbookGenerator::startExamples()
935 {
936 DB_GEN_C
937   t << "<simplesect><title>";
938   docify(theTranslator->trExamples());
939   t << "</title>";
940 }
941
942 void DocbookGenerator::endExamples()
943 {
944 DB_GEN_C
945   t << "</simplesect>" << endl;
946 }
947 void DocbookGenerator::startSubsubsection(void)
948 {
949 DB_GEN_C
950   t << "<simplesect><title>";
951 }
952 void DocbookGenerator::endSubsubsection(void)
953 {
954 DB_GEN_C
955   t << "</title></simplesect>" << endl;
956 }
957 void DocbookGenerator::writeChar(char c)
958 {
959 DB_GEN_C
960   char cs[2];
961   cs[0]=c;
962   cs[1]=0;
963   docify(cs);
964 }
965 void DocbookGenerator::startMemberDocPrefixItem()
966 {
967 DB_GEN_C
968   t << "<computeroutput>";
969 }
970 void DocbookGenerator::endMemberDocPrefixItem()
971 {
972 DB_GEN_C
973   t << "</computeroutput>";
974 }
975 void DocbookGenerator::exceptionEntry(const char* prefix,bool closeBracket)
976 {
977 DB_GEN_C
978   if (prefix)
979     t << " " << prefix << "(";
980   else if (closeBracket)
981     t << ")";
982   t << " ";
983 }
984 void DocbookGenerator::startParameterName(bool)
985 {
986 DB_GEN_C
987   t << " ";
988 }
989 void DocbookGenerator::endParameterName(bool last,bool /*emptyList*/,bool closeBracket)
990 {
991 DB_GEN_C
992   if (last)
993   {
994     if (closeBracket) t << ")";
995   }
996 }
997 void DocbookGenerator::startCodeFragment()
998 {
999 DB_GEN_C
1000     t << "<programlisting>";
1001 }
1002 void DocbookGenerator::endCodeFragment()
1003 {
1004 DB_GEN_C
1005     t << "</programlisting>";
1006 }
1007 void DocbookGenerator::startMemberTemplateParams()
1008 {
1009 DB_GEN_C
1010 }
1011
1012 void DocbookGenerator::endMemberTemplateParams(const char *,const char *)
1013 {
1014 DB_GEN_C
1015   t << "</para>";
1016   t << "<para>";
1017 }
1018 void DocbookGenerator::startSection(const char *lab,const char *,SectionInfo::SectionType type)
1019 {
1020 DB_GEN_C
1021   t << "    <section xml:id=\"_" << stripPath(lab) << "\">";
1022   t << "<title>";
1023 }
1024 void DocbookGenerator::endSection(const char *lab,SectionInfo::SectionType)
1025 {
1026 DB_GEN_C
1027   t << "</title>";
1028   t << "    </section>";
1029 }
1030 void DocbookGenerator::addIndexItem(const char *prim,const char *sec)
1031 {
1032 DB_GEN_C
1033   addIndexTerm(t, prim, sec);
1034 }
1035
1036 void DocbookGenerator::startDescTable(const char *title)
1037 {
1038 DB_GEN_C
1039   int ncols = 2;
1040   t << "<informaltable frame=\"all\">" << endl;
1041   if (title)t << "<title>" << convertToDocBook(title) << "</title>" << endl;
1042   t << "    <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl;
1043   for (int i = 0; i < ncols; i++)
1044   {
1045     t << "      <colspec colname='c" << i+1 << "'/>\n";
1046   }
1047   t << "<tbody>\n";
1048   m_descTable = TRUE;
1049 }
1050
1051 void DocbookGenerator::endDescTable()
1052 {
1053 DB_GEN_C
1054   t << "    </tbody>" << endl;
1055   t << "    </tgroup>" << endl;
1056   t << "</informaltable>" << endl;
1057   m_descTable = FALSE;
1058 }
1059
1060 void DocbookGenerator::startDescTableRow()
1061 {
1062 DB_GEN_C
1063   t << "<row>";
1064   t << "<entry>";
1065 }
1066
1067 void DocbookGenerator::endDescTableRow()
1068 {
1069 DB_GEN_C
1070   t << "</row>";
1071 }
1072
1073 void DocbookGenerator::startDescTableTitle()
1074 {
1075 DB_GEN_C
1076 }
1077
1078 void DocbookGenerator::endDescTableTitle()
1079 {
1080 DB_GEN_C
1081 }
1082
1083 void DocbookGenerator::startDescTableData()
1084 {
1085 DB_GEN_C
1086   t << "</entry><entry>";
1087 }
1088
1089 void DocbookGenerator::endDescTableData()
1090 {
1091 DB_GEN_C
1092   t << "</entry>";
1093 }
1094 void DocbookGenerator::startGroupCollaboration()
1095 {
1096 DB_GEN_C
1097 }
1098 void DocbookGenerator::endGroupCollaboration(const DotGroupCollaboration &g)
1099 {
1100 DB_GEN_C
1101   g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT),fileName,relPath,FALSE);
1102 }
1103 void DocbookGenerator::startDotGraph()
1104 {
1105 DB_GEN_C
1106 }
1107 void DocbookGenerator::endDotGraph(const DotClassGraph &g)
1108 {
1109 DB_GEN_C
1110   g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT),fileName,relPath,TRUE,FALSE);
1111 }
1112 void DocbookGenerator::startInclDepGraph()
1113 {
1114 DB_GEN_C
1115 }
1116 void DocbookGenerator::endInclDepGraph(const DotInclDepGraph &g)
1117 {
1118 DB_GEN_C
1119   QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT), fileName,relPath,FALSE);
1120 }
1121 void DocbookGenerator::startCallGraph()
1122 {
1123 DB_GEN_C
1124 }
1125 void DocbookGenerator::endCallGraph(const DotCallGraph &g)
1126 {
1127 DB_GEN_C
1128   QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT), fileName,relPath,FALSE);
1129 }
1130 void DocbookGenerator::startDirDepGraph()
1131 {
1132 DB_GEN_C
1133 }
1134 void DocbookGenerator::endDirDepGraph(const DotDirDeps &g)
1135 {
1136 DB_GEN_C
1137   QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString(DOCBOOK_OUTPUT), fileName,relPath,FALSE);
1138 }
1139 void DocbookGenerator::startMemberDocList()
1140 {
1141 DB_GEN_C
1142 }
1143 void DocbookGenerator::endMemberDocList()
1144 {
1145 DB_GEN_C
1146   m_inGroup = TRUE;
1147 }
1148 void DocbookGenerator::startConstraintList(const char *header)
1149 {
1150 DB_GEN_C
1151   t << "<simplesect><title>";
1152   docify(header);
1153   t << "</title>" << endl;
1154 }
1155 void DocbookGenerator::startConstraintParam()
1156 {
1157 DB_GEN_C
1158   t << "<para><emphasis role=\"strong\">";
1159 }
1160 void DocbookGenerator::endConstraintParam()
1161 {
1162 DB_GEN_C
1163 }
1164 void DocbookGenerator::startConstraintType()
1165 {
1166 DB_GEN_C
1167   t << ":";
1168 }
1169 void DocbookGenerator::endConstraintType()
1170 {
1171 DB_GEN_C
1172   t << "</emphasis></para>" << endl;
1173 }
1174 void DocbookGenerator::startConstraintDocs()
1175 {
1176 DB_GEN_C
1177 }
1178 void DocbookGenerator::endConstraintDocs()
1179 {
1180 DB_GEN_C
1181 }
1182 void DocbookGenerator::endConstraintList()
1183 {
1184 DB_GEN_C
1185   t << "</simplesect>" << endl;
1186 }