docbookvisitor.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  *
4  *
5  *
6  * Copyright (C) 1997-2015 by Dimitri van Heesch.
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation under the terms of the GNU General Public License is hereby
10  * granted. No representations are made about the suitability of this software
11  * for any purpose. It is provided "as is" without express or implied warranty.
12  * See the GNU General Public License for more details.
13  *
14  * Documents produced by Doxygen are derivative works derived from the
15  * input used in their production; they are not affected by this license.
16  *
17  */
18 
19 #include <qfileinfo.h>
20 
21 #include "docbookvisitor.h"
22 #include "docparser.h"
23 #include "language.h"
24 #include "doxygen.h"
25 #include "outputgen.h"
26 #include "docbookgen.h"
27 #include "dot.h"
28 #include "message.h"
29 #include "util.h"
30 #include "parserintf.h"
31 #include "filename.h"
32 #include "config.h"
33 #include "filedef.h"
34 #include "msc.h"
35 #include "dia.h"
36 #include "htmlentity.h"
37 #include "plantuml.h"
38 
39 static void visitPreStart(FTextStream &t, const bool hasCaption, QCString name, QCString width, QCString height)
40 {
41  QCString tmpStr;
42  t << " <figure>" << endl;
43  t << " <title></title>" << endl;
44  t << " <mediaobject>" << endl;
45  t << " <imageobject>" << endl;
46  t << " <imagedata";
47  if (!width.isEmpty())
48  {
49  t << " width=\"" << convertToXML(width) << "\"";
50  }
51  else
52  {
53  t << " width=\"50%\"";
54  }
55  if (!height.isEmpty())
56  {
57  t << " depth=\"" << convertToXML(tmpStr) << "\"";
58  }
59  t << " align=\"center\" valign=\"middle\" scalefit=\"1\" fileref=\"" << name << "\">";
60  t << "</imagedata>" << endl;
61  t << " </imageobject>" << endl;
62  if (hasCaption)
63  {
64  t << " <caption>" << endl;
65  }
66 }
67 
68 static void visitPostEnd(FTextStream &t, const bool hasCaption)
69 {
70  t << endl;
71  if (hasCaption)
72  {
73  t << " </caption>" << endl;
74  }
75  t << " </mediaobject>" << endl;
76  t << " </figure>" << endl;
77 }
78 
80 {
81  QListIterator<DocNode> cli(children);
82  DocNode *n;
83  for (cli.toFirst();(n=cli.current());++cli) n->accept(parent);
84 }
85 
87  : DocVisitor(DocVisitor_Docbook), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE)
88 {
89 }
90 
91 //--------------------------------------
92 // visitor functions for leaf nodes
93 //--------------------------------------
94 
96 {
97  if (m_hide) return;
98  filter(w->word());
99 }
100 
102 {
103  if (m_hide) return;
104  startLink(w->file(),w->anchor());
105  filter(w->word());
106  endLink();
107 }
108 
110 {
111  if (m_hide) return;
112  if (m_insidePre)
113  {
114  m_t << w->chars();
115  }
116  else
117  {
118  m_t << " ";
119  }
120 }
121 
123 {
124  if (m_hide) return;
125  const char *res = HtmlEntityMapper::instance()->docbook(s->symbol());
126  if (res)
127  {
128  m_t << res;
129  }
130  else
131  {
132  err("DocBook: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
133  }
134 }
135 
137 {
138  if (m_hide) return;
139  m_t << "<link xlink:href=\"";
140  if (u->isEmail()) m_t << "mailto:";
141  filter(u->url());
142  m_t << "\">";
143  filter(u->url());
144  m_t << "</link>";
145 }
146 
148 {
149  if (m_hide) return;
150  m_t << endl << "<literallayout>\n</literallayout>" << endl;
151 }
152 
154 {
155  if (m_hide) return;
156  m_t << "<informaltable frame='bottom'><tgroup cols='1'><colspec align='center'/><tbody><row><entry align='center'>\n";
157  m_t << "</entry></row></tbody></tgroup></informaltable>\n";
158 }
159 
161 {
162  if (m_hide) return;
163  switch (s->style())
164  {
166  if (s->enable()) m_t << "<emphasis role=\"bold\">"; else m_t << "</emphasis>";
167  break;
169  if (s->enable()) m_t << "<emphasis>"; else m_t << "</emphasis>";
170  break;
172  if (s->enable()) m_t << "<computeroutput>"; else m_t << "</computeroutput>";
173  break;
175  if (s->enable()) m_t << "<subscript>"; else m_t << "</subscript>";
176  break;
178  if (s->enable()) m_t << "<superscript>"; else m_t << "</superscript>";
179  break;
181  if (s->enable()) m_t << "<informaltable frame='none'><tgroup cols='1'><colspec align='center'/><tbody><row><entry align='center'>";
182  else m_t << "</entry></row></tbody></tgroup></informaltable>";
183  break;
185  if (s->enable())
186  {
187  m_t << "<literallayout>";
189  }
190  else
191  {
192  m_t << "</literallayout>";
194  }
195  break;
196  /* There is no equivalent Docbook tag for rendering Small text */
197  case DocStyleChange::Small: /* XSLT Stylesheets can be used */ break;
198  /* HTML only */
199  case DocStyleChange::Div: /* HTML only */ break;
200  case DocStyleChange::Span: /* HTML only */ break;
201  }
202 }
203 
205 {
206  if (m_hide) return;
208  switch(s->type())
209  {
210  case DocVerbatim::Code: // fall though
211  m_t << "<literallayout><computeroutput>";
213  ->parseCode(m_ci,s->context(),s->text(),langExt,
214  s->isExample(),s->exampleFile());
215  m_t << "</computeroutput></literallayout>";
216  break;
218  m_t << "<literallayout>";
219  filter(s->text());
220  m_t << "</literallayout>";
221  break;
222  case DocVerbatim::HtmlOnly:
223  break;
224  case DocVerbatim::RtfOnly:
225  break;
226  case DocVerbatim::ManOnly:
227  break;
229  break;
230  case DocVerbatim::XmlOnly:
231  break;
233  break;
234  m_t << s->text();
235  break;
236  case DocVerbatim::Dot:
237  {
238  static int dotindex = 1;
239  QCString baseName(4096);
240  QCString name;
241  QCString stext = s->text();
242  m_t << "<para>" << endl;
243  name.sprintf("%s%d", "dot_inline_dotgraph_", dotindex);
244  baseName.sprintf("%s%d",
245  (Config_getString("DOCBOOK_OUTPUT")+"/inline_dotgraph_").data(),
246  dotindex++
247  );
248  QFile file(baseName+".dot");
249  if (!file.open(IO_WriteOnly))
250  {
251  err("Could not open file %s.msc for writing\n",baseName.data());
252  }
253  file.writeBlock( stext, stext.length() );
254  file.close();
255  writeDotFile(baseName, s);
256  m_t << "</para>" << endl;
257  }
258  break;
259  case DocVerbatim::Msc:
260  {
261  static int mscindex = 1;
262  QCString baseName(4096);
263  QCString name;
264  QCString stext = s->text();
265  m_t << "<para>" << endl;
266  name.sprintf("%s%d", "msc_inline_mscgraph_", mscindex);
267  baseName.sprintf("%s%d",
268  (Config_getString("DOCBOOK_OUTPUT")+"/inline_mscgraph_").data(),
269  mscindex++
270  );
271  QFile file(baseName+".msc");
272  if (!file.open(IO_WriteOnly))
273  {
274  err("Could not open file %s.msc for writing\n",baseName.data());
275  }
276  QCString text = "msc {";
277  text+=stext;
278  text+="}";
279  file.writeBlock( text, text.length() );
280  file.close();
281  writeMscFile(baseName,s);
282  m_t << "</para>" << endl;
283  }
284  break;
286  {
287  static QCString docbookOutput = Config_getString("DOCBOOK_OUTPUT");
288  QCString baseName = writePlantUMLSource(docbookOutput,s->exampleFile(),s->text());
289  QCString shortName = baseName;
290  int i;
291  if ((i=shortName.findRev('/'))!=-1)
292  {
293  shortName=shortName.right(shortName.length()-i-1);
294  }
295  m_t << "<para>" << endl;
296  writePlantUMLFile(baseName,s);
297  m_t << "</para>" << endl;
298  }
299  break;
300  }
301 }
302 
304 {
305  if (m_hide) return;
306  m_t << "<anchor id=\"" << anc->file() << "_1" << anc->anchor() << "\"/>";
307 }
308 
310 {
311  if (m_hide) return;
312  SrcLangExt langExt = getLanguageFromFileName(inc->extension());
313  switch(inc->type())
314  {
316  {
317  m_t << "<literallayout><computeroutput>";
318  QFileInfo cfi( inc->file() );
319  FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
321  ->parseCode(m_ci,inc->context(),
322  inc->text(),
323  langExt,
324  inc->isExample(),
325  inc->exampleFile(), &fd);
326  m_t << "</computeroutput></literallayout>";
327  }
328  break;
329  case DocInclude::Include:
330  m_t << "<literallayout><computeroutput>";
332  ->parseCode(m_ci,inc->context(),
333  inc->text(),
334  langExt,
335  inc->isExample(),
336  inc->exampleFile());
337  m_t << "</computeroutput></literallayout>";
338  break;
340  break;
342  break;
344  break;
346  m_t << "<verbatim>";
347  filter(inc->text());
348  m_t << "</verbatim>";
349  break;
350  case DocInclude::Snippet:
351  m_t << "<literallayout><computeroutput>";
353  ->parseCode(m_ci,
354  inc->context(),
355  extractBlock(inc->text(),inc->blockId()),
356  langExt,
357  inc->isExample(),
358  inc->exampleFile()
359  );
360  m_t << "</computeroutput></literallayout>";
361  break;
362  }
363 }
364 
366 {
367  if (op->isFirst())
368  {
369  if (!m_hide)
370  {
371  m_t << "<programlisting>";
372  }
373  pushEnabled();
374  m_hide = TRUE;
375  }
377  if (op->type()!=DocIncOperator::Skip)
378  {
379  popEnabled();
380  if (!m_hide)
381  {
383  ->parseCode(m_ci,op->context(),
384  op->text(),langExt,op->isExample(),
385  op->exampleFile());
386  }
387  pushEnabled();
388  m_hide=TRUE;
389  }
390  if (op->isLast())
391  {
392  popEnabled();
393  if (!m_hide) m_t << "</programlisting>";
394  }
395  else
396  {
397  if (!m_hide) m_t << endl;
398  }
399 }
400 
402 {
403  if (m_hide) return;
404  m_t << "<equation><title>" << f->name() << "</title>";
405  filter(f->text());
406  m_t << "</equation>";
407 }
408 
410 {
411  if (m_hide) return;
412  m_t << "<indexentry><primaryie>" << endl;
413  filter(ie->entry());
414  m_t << "</primaryie><secondaryie></secondaryie></indexentry>" << endl;
415 }
416 
418 {
419  m_t << "<simplesect/>";
420 }
421 
423 {
424  if (m_hide) return;
425  if (!cite->file().isEmpty()) startLink(cite->file(),cite->anchor());
426  filter(cite->text());
427  if (!cite->file().isEmpty()) endLink();
428 }
429 
430 //--------------------------------------
431 // visitor functions for compound nodes
432 //--------------------------------------
433 
435 {
436  if (m_hide) return;
437  if (l->isEnumList())
438  {
439  m_t << "<orderedlist>\n";
440  }
441  else
442  {
443  m_t << "<itemizedlist>\n";
444  }
445 }
446 
448 {
449  if (m_hide) return;
450  if (l->isEnumList())
451  {
452  m_t << "</orderedlist>\n";
453  }
454  else
455  {
456  m_t << "</itemizedlist>\n";
457  }
458 }
459 
461 {
462  if (m_hide) return;
463  m_t << "<listitem>";
464 }
465 
467 {
468  if (m_hide) return;
469  m_t << "</listitem>";
470 }
471 
473 {
474  if (m_hide) return;
475  m_t << endl;
476  m_t << "<para>";
477 }
478 
480 {
481  if (m_hide) return;
482  m_t << "</para>";
483  m_t << endl;
484 }
485 
487 {
488  //m_t << "<hr><h4><font color=\"red\">New parser:</font></h4>\n";
489 }
490 
492 {
493  //m_t << "<hr><h4><font color=\"red\">Old parser:</font></h4>\n";
494 }
495 
497 {
498  if (m_hide) return;
499  switch(s->type())
500  {
501  case DocSimpleSect::See:
502  if (m_insidePre)
503  {
504  m_t << "<formalpara><title>" << theTranslator->trSeeAlso() << ": </title>" << endl;
505  }
506  else
507  {
508  m_t << "<formalpara><title>" << convertToXML(theTranslator->trSeeAlso()) << ": </title>" << endl;
509  }
510  break;
512  if (m_insidePre)
513  {
514  m_t << "<formalpara><title>" << theTranslator->trReturns()<< ": </title>" << endl;
515  }
516  else
517  {
518  m_t << "<formalpara><title>" << convertToXML(theTranslator->trReturns()) << ": </title>" << endl;
519  }
520  break;
522  if (m_insidePre)
523  {
524  m_t << "<formalpara><title>" << theTranslator->trAuthor(TRUE, TRUE) << ": </title>" << endl;
525  }
526  else
527  {
528  m_t << "<formalpara><title>" << convertToXML(theTranslator->trAuthor(TRUE, TRUE)) << ": </title>" << endl;
529  }
530  break;
532  if (m_insidePre)
533  {
534  m_t << "<formalpara><title>" << theTranslator->trAuthor(TRUE, FALSE) << ": </title>" << endl;
535  }
536  else
537  {
538  m_t << "<formalpara><title>" << convertToXML(theTranslator->trAuthor(TRUE, FALSE)) << ": </title>" << endl;
539  }
540  break;
542  if (m_insidePre)
543  {
544  m_t << "<formalpara><title>" << theTranslator->trVersion() << ": </title>" << endl;
545  }
546  else
547  {
548  m_t << "<formalpara><title>" << convertToXML(theTranslator->trVersion()) << ": </title>" << endl;
549  }
550  break;
552  if (m_insidePre)
553  {
554  m_t << "<formalpara><title>" << theTranslator->trSince() << ": </title>" << endl;
555  }
556  else
557  {
558  m_t << "<formalpara><title>" << convertToXML(theTranslator->trSince()) << ": </title>" << endl;
559  }
560  break;
561  case DocSimpleSect::Date:
562  if (m_insidePre)
563  {
564  m_t << "<formalpara><title>" << theTranslator->trDate() << ": </title>" << endl;
565  }
566  else
567  {
568  m_t << "<formalpara><title>" << convertToXML(theTranslator->trDate()) << ": </title>" << endl;
569  }
570  break;
571  case DocSimpleSect::Note:
572  if (m_insidePre)
573  {
574  m_t << "<formalpara><title>" << theTranslator->trNote() << ": </title>" << endl;
575  }
576  else
577  {
578  m_t << "<formalpara><title>" << convertToXML(theTranslator->trNote()) << ": </title>" << endl;
579  }
580  break;
582  if (m_insidePre)
583  {
584  m_t << "<formalpara><title>" << theTranslator->trWarning() << ": </title>" << endl;
585  }
586  else
587  {
588  m_t << "<formalpara><title>" << convertToXML(theTranslator->trWarning()) << ": </title>" << endl;
589  }
590  break;
591  case DocSimpleSect::Pre:
592  if (m_insidePre)
593  {
594  m_t << "<formalpara><title>" << theTranslator->trPrecondition() << ": </title>" << endl;
595  }
596  else
597  {
598  m_t << "<formalpara><title>" << convertToXML(theTranslator->trPrecondition()) << ": </title>" << endl;
599  }
600  break;
601  case DocSimpleSect::Post:
602  if (m_insidePre)
603  {
604  m_t << "<formalpara><title>" << theTranslator->trPostcondition() << ": </title>" << endl;
605  }
606  else
607  {
608  m_t << "<formalpara><title>" << convertToXML(theTranslator->trPostcondition()) << ": </title>" << endl;
609  }
610  break;
612  if (m_insidePre)
613  {
614  m_t << "<formalpara><title>" << theTranslator->trCopyright() << ": </title>" << endl;
615  }
616  else
617  {
618  m_t << "<formalpara><title>" << convertToXML(theTranslator->trCopyright()) << ": </title>" << endl;
619  }
620  break;
622  if (m_insidePre)
623  {
624  m_t << "<formalpara><title>" << theTranslator->trInvariant() << ": </title>" << endl;
625  }
626  else
627  {
628  m_t << "<formalpara><title>" << convertToXML(theTranslator->trInvariant()) << ": </title>" << endl;
629  }
630  break;
632  if (m_insidePre)
633  {
634  m_t << "<formalpara><title>" << theTranslator->trRemarks() << ": </title>" << endl;
635  }
636  else
637  {
638  m_t << "<formalpara><title>" << convertToXML(theTranslator->trRemarks()) << ": </title>" << endl;
639  }
640  break;
642  if (m_insidePre)
643  {
644  m_t << "<formalpara><title>" << theTranslator->trAttention() << ": </title>" << endl;
645  }
646  else
647  {
648  m_t << "<formalpara><title>" << convertToXML(theTranslator->trAttention()) << ": </title>" << endl;
649  }
650  break;
651  case DocSimpleSect::User:
652  m_t << "<formalpara><title></title>" << endl;
653  break;
654  case DocSimpleSect::Rcs:
655  m_t << "<formalpara><title></title>" << endl;
656  break;
657  case DocSimpleSect::Unknown: m_t << "<formalpara><title></title>" << endl; break;
658  }
659 }
660 
662 {
663  if (m_hide) return;
664  m_t << "</formalpara>" << endl;
665 }
666 
668 {
669  if (m_hide) return;
670  m_t << "<title>";
671 }
672 
674 {
675  if (m_hide) return;
676  m_t << "</title>";
677 }
678 
680 {
681  if (m_hide) return;
682  m_t << "<itemizedlist>\n";
683 }
684 
686 {
687  if (m_hide) return;
688  m_t << "</itemizedlist>\n";
689 }
690 
692 {
693  if (m_hide) return;
694  m_t << "<listitem>";
695 }
696 
698 {
699  if (m_hide) return;
700  m_t << "</listitem>\n";
701 }
702 
704 {
705  if (m_hide) return;
706  m_t << "<section xml:id=\"" << s->file();
707  if (!s->anchor().isEmpty()) m_t << "_1" << s->anchor();
708  m_t << "\">" << endl;
709  m_t << "<title>";
710  filter(s->title());
711  m_t << "</title>" << endl;
712 }
713 
715 {
716  m_t << "</section>\n";
717 }
718 
720 {
721  if (m_hide) return;
722  if (s->type()==DocHtmlList::Ordered)
723  m_t << "<orderedlist>\n";
724  else
725  m_t << "<itemizedlist>\n";
726 }
727 
729 {
730  if (m_hide) return;
731  if (s->type()==DocHtmlList::Ordered)
732  m_t << "</orderedlist>\n";
733  else
734  m_t << "</itemizedlist>\n";
735 }
736 
738 {
739  if (m_hide) return;
740  m_t << "<listitem>\n";
741 }
742 
744 {
745  if (m_hide) return;
746  m_t << "</listitem>\n";
747 }
748 
750 {
751  if (m_hide) return;
752  m_t << "<variablelist>\n";
753 }
754 
756 {
757  if (m_hide) return;
758  m_t << "</variablelist>\n";
759 }
760 
762 {
763  if (m_hide) return;
764  m_t << "<varlistentry><term>";
765 }
766 
768 {
769  if (m_hide) return;
770  m_t << "</term>\n";
771 }
772 
774 {
775  if (m_hide) return;
776  m_t << "<listitem>";
777 }
778 
780 {
781  if (m_hide) return;
782  m_t << "</listitem></varlistentry>\n";
783 }
784 
786 {
787  if (m_hide) return;
788  m_t << "<table frame=\"all\">" << endl;
789  m_t << " <title></title>" << endl;
790  m_t << " <tgroup cols=\"" << t->numColumns() << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl;
791  m_t << " <tbody>" << endl;
792 }
793 
795 {
796  if (m_hide) return;
797  m_t << " </tbody>" << endl;
798  m_t << " </tgroup>" << endl;
799  m_t << "</table>" << endl;
800 }
801 
803 {
804  if (m_hide) return;
805  m_t << "<row>\n";
806 }
807 
809 {
810  if (m_hide) return;
811  m_t << "</row>\n";
812 }
813 
815 {
816  if (m_hide) return;
817  m_t << "<entry>";
818 }
819 
821 {
822  if (m_hide) return;
823  m_t << "</entry>";
824 }
825 
827 {
828  if (m_hide) return;
829  m_t << "<caption>";
830 }
831 
833 {
834  if (m_hide) return;
835  m_t << "</caption>\n";
836 }
837 
839 {
840  if (m_hide) return;
841  // TODO: to be implemented
842 }
843 
845 {
846  if (m_hide) return;
847  // TODO: to be implemented
848 }
849 
851 {
852  if (m_hide) return;
853  m_t << "<link xlink:href=\"" << href->url() << "\">";
854 }
855 
857 {
858  if (m_hide) return;
859  m_t << "</link>";
860 }
861 
863 {
864  if (m_hide) return;
865  m_t << "<formalpara><title>";
866 }
867 
869 {
870  if (m_hide) return;
871  m_t << "</title></formalpara>\n";
872 }
873 
875 {
876  if (img->type()==DocImage::DocBook)
877  {
878  if (m_hide) return;
879  m_t << endl;
880  QCString baseName=img->name();
881  int i;
882  if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
883  {
884  baseName=baseName.right(baseName.length()-i-1);
885  }
886  visitPreStart(m_t, img -> hasCaption(), baseName, img -> width(), img -> height());
887  }
888  else
889  {
890  pushEnabled();
891  m_hide=TRUE;
892  }
893 }
894 
896 {
897  if (img->type()==DocImage::DocBook)
898  {
899  if (m_hide) return;
900  visitPostEnd(m_t, img -> hasCaption());
901  // copy the image to the output dir
902  QCString baseName=img->name();
903  int i;
904  if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
905  {
906  baseName=baseName.right(baseName.length()-i-1);
907  }
908  QCString m_file;
909  bool ambig;
910  FileDef *fd=findFileDef(Doxygen::imageNameDict, baseName, ambig);
911  if (fd)
912  {
913  m_file=fd->absFilePath();
914  }
915  QFile inImage(m_file);
916  QFile outImage(Config_getString("DOCBOOK_OUTPUT")+"/"+baseName.data());
917  if (inImage.open(IO_ReadOnly))
918  {
919  if (outImage.open(IO_WriteOnly))
920  {
921  char *buffer = new char[inImage.size()];
922  inImage.readBlock(buffer,inImage.size());
923  outImage.writeBlock(buffer,inImage.size());
924  outImage.flush();
925  delete[] buffer;
926  }
927  }
928  }
929  else
930  {
931  popEnabled();
932  }
933 }
934 
936 {
937  if (m_hide) return;
938  startDotFile(df->file(),df->width(),df->height(),df->hasCaption());
939 }
940 
942 {
943  if (m_hide) return;
944  endDotFile(df->hasCaption());
945 }
946 
948 {
949  if (m_hide) return;
950  startMscFile(df->file(),df->width(),df->height(),df->hasCaption());
951 }
952 
954 {
955  if (m_hide) return;
956  endMscFile(df->hasCaption());
957 }
959 {
960  if (m_hide) return;
961  startDiaFile(df->file(),df->width(),df->height(),df->hasCaption());
962 }
963 
965 {
966  if (m_hide) return;
967  endDiaFile(df->hasCaption());
968 }
969 
971 {
972  if (m_hide) return;
973  startLink(lnk->file(),lnk->anchor());
974 }
975 
977 {
978  if (m_hide) return;
979  endLink();
980 }
981 
983 {
984  if (m_hide) return;
985  if (!ref->file().isEmpty()) startLink(ref->file(),ref->anchor());
986  if (!ref->hasLinkText()) filter(ref->targetTitle());
987 }
988 
990 {
991  if (m_hide) return;
992  if (!ref->file().isEmpty()) endLink();
993 }
994 
996 {
997  if (m_hide) return;
998  m_t << "<tocitem id=\"" << ref->file() << "_1" << ref->anchor() << "\">";
999 }
1000 
1002 {
1003  if (m_hide) return;
1004  m_t << "</tocitem>" << endl;
1005 }
1006 
1008 {
1009  if (m_hide) return;
1010  m_t << "<toclist>" << endl;
1011 }
1012 
1014 {
1015  if (m_hide) return;
1016  m_t << "</toclist>" << endl;
1017 }
1018 
1020 {
1021  if (m_hide) return;
1022  m_t << endl;
1023  m_t << " <formalpara>" << endl;
1024  m_t << " <title/>" << endl;
1025  m_t << " <table frame=\"all\">" << endl;
1026  m_t << " <title>";
1027  switch(s->type())
1028  {
1033  default:
1034  ASSERT(0);
1035  }
1036  m_t << " </title>" << endl;
1037  m_t << " <tgroup cols=\"2\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl;
1038  m_t << " <colspec colwidth=\"1*\"/>" << endl;
1039  m_t << " <colspec colwidth=\"4*\"/>" << endl;
1040  m_t << " <tbody>" << endl;
1041 }
1042 
1044 {
1045  if (m_hide) return;
1046  m_t << " </tbody>" << endl;
1047  m_t << " </tgroup>" << endl;
1048  m_t << " </table>" << endl;
1049  m_t << " </formalpara>" << endl;
1050  m_t << " ";
1051 }
1052 
1054 {
1055  if (m_hide) return;
1057  DocNode *param;
1058  m_t << " <row>" << endl;
1059  if (!li.toFirst())
1060  {
1061  m_t << " <entry></entry>" << endl;
1062  }
1063  else
1064  {
1065  m_t << " <entry>";
1066  int cnt = 0;
1067  for (li.toFirst();(param=li.current());++li)
1068  {
1069  if (cnt)
1070  {
1071  m_t << ", ";
1072  }
1073  if (param->kind()==DocNode::Kind_Word)
1074  {
1075  visit((DocWord*)param);
1076  }
1077  else if (param->kind()==DocNode::Kind_LinkedWord)
1078  {
1079  visit((DocLinkedWord*)param);
1080  }
1081  cnt++;
1082  }
1083  m_t << "</entry>" << endl;
1084  }
1085  m_t << " <entry>";
1086 }
1087 
1089 {
1090  if (m_hide) return;
1091  m_t << "</entry>" << endl;
1092  m_t << " </row>" << endl;
1093 }
1094 
1096 {
1097  if (m_hide) return;
1098  if (x->title().isEmpty()) return;
1099  m_t << "<para><link linkend=\"";
1100  m_t << x->file() << "_1" << x->anchor();
1101  m_t << "\">";
1102  filter(x->title());
1103  m_t << "</link>";
1104  m_t << " ";
1105 }
1106 
1108 {
1109  if (m_hide) return;
1110  if (x->title().isEmpty()) return;
1111  m_t << "</para>";
1112 }
1113 
1115 {
1116  if (m_hide) return;
1117  startLink(ref->file(),ref->anchor());
1118 }
1119 
1121 {
1122  if (m_hide) return;
1123  endLink();
1124  m_t << " ";
1125 }
1126 
1128 {
1129  if (m_hide) return;
1130  // TODO: to be implemented
1131 }
1132 
1133 
1135 {
1136  if (m_hide) return;
1137  // TODO: to be implemented
1138 }
1139 
1140 
1142 {
1143  // TODO: to be implemented
1144 }
1145 
1146 
1148 {
1149  // TODO: to be implemented
1150 }
1151 
1152 
1154 {
1155  if (m_hide) return;
1156  m_t << "<blockquote>";
1157 }
1158 
1160 {
1161  if (m_hide) return;
1162  m_t << "</blockquote>";
1163 }
1164 
1166 {
1167  // TODO: to be implemented
1168 }
1169 
1170 
1172 {
1173  // TODO: to be implemented
1174 }
1175 
1177 {
1178 }
1179 
1181 {
1182 }
1183 
1184 
1186 {
1187  m_t << convertToXML(str);
1188 }
1189 
1191 {
1192  m_t << "<link linkend=\"" << file;
1193  if (!anchor.isEmpty()) m_t << "_1" << anchor;
1194  m_t << "\">";
1195 }
1196 
1198 {
1199  m_t << "</link>";
1200 }
1201 
1203 {
1204  m_enabled.push(new bool(m_hide));
1205 }
1206 
1208 {
1209  bool *v=m_enabled.pop();
1210  ASSERT(v!=0);
1211  m_hide = *v;
1212  delete v;
1213 }
1214 
1216 {
1217  QCString shortName = baseName;
1218  int i;
1219  if ((i=shortName.findRev('/'))!=-1)
1220  {
1221  shortName=shortName.right(shortName.length()-i-1);
1222  }
1223  QCString outDir = Config_getString("DOCBOOK_OUTPUT");
1224  writeMscGraphFromFile(baseName+".msc",outDir,shortName,MSC_BITMAP);
1225  visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height());
1226  visitCaption(this, s->children());
1227  visitPostEnd(m_t, s->hasCaption());
1228 }
1229 
1231 {
1232  QCString shortName = baseName;
1233  int i;
1234  if ((i=shortName.findRev('/'))!=-1)
1235  {
1236  shortName=shortName.right(shortName.length()-i-1);
1237  }
1238  QCString outDir = Config_getString("DOCBOOK_OUTPUT");
1239  generatePlantUMLOutput(baseName,outDir,PUML_BITMAP);
1240  visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height());
1241  visitCaption(this, s->children());
1242  visitPostEnd(m_t, s->hasCaption());
1243 }
1244 
1246  const QCString &width,
1247  const QCString &height,
1248  bool hasCaption
1249  )
1250 {
1252  int i;
1253  if ((i=baseName.findRev('/'))!=-1)
1254  {
1255  baseName=baseName.right(baseName.length()-i-1);
1256  }
1257  if ((i=baseName.find('.'))!=-1)
1258  {
1259  baseName=baseName.left(i);
1260  }
1261  baseName.prepend("msc_");
1262  QCString outDir = Config_getString("DOCBOOK_OUTPUT");
1263  writeMscGraphFromFile(fileName,outDir,baseName,MSC_BITMAP);
1264  m_t << "<para>" << endl;
1265  visitPreStart(m_t, hasCaption, baseName + ".png", width, height);
1266 }
1267 
1268 void DocbookDocVisitor::endMscFile(bool hasCaption)
1269 {
1270  if (m_hide) return;
1271  visitPostEnd(m_t, hasCaption);
1272  m_t << "</para>" << endl;
1273 }
1274 
1276 {
1277  QCString shortName = baseName;
1278  int i;
1279  if ((i=shortName.findRev('/'))!=-1)
1280  {
1281  shortName=shortName.right(shortName.length()-i-1);
1282  }
1283  QCString outDir = Config_getString("DOCBOOK_OUTPUT");
1284  writeDiaGraphFromFile(baseName+".dia",outDir,shortName,DIA_BITMAP);
1285  visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height());
1286  visitCaption(this, s->children());
1287  visitPostEnd(m_t, s->hasCaption());
1288 }
1289 
1291  const QCString &width,
1292  const QCString &height,
1293  bool hasCaption
1294  )
1295 {
1297  int i;
1298  if ((i=baseName.findRev('/'))!=-1)
1299  {
1300  baseName=baseName.right(baseName.length()-i-1);
1301  }
1302  if ((i=baseName.find('.'))!=-1)
1303  {
1304  baseName=baseName.left(i);
1305  }
1306  baseName.prepend("dia_");
1307  QCString outDir = Config_getString("DOCBOOK_OUTPUT");
1308  writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP);
1309  m_t << "<para>" << endl;
1310  visitPreStart(m_t, hasCaption, baseName + ".png", width, height);
1311 }
1312 
1313 void DocbookDocVisitor::endDiaFile(bool hasCaption)
1314 {
1315  if (m_hide) return;
1316  visitPostEnd(m_t, hasCaption);
1317  m_t << "</para>" << endl;
1318 }
1319 
1321 {
1322  QCString shortName = baseName;
1323  int i;
1324  if ((i=shortName.findRev('/'))!=-1)
1325  {
1326  shortName=shortName.right(shortName.length()-i-1);
1327  }
1328  QCString outDir = Config_getString("DOCBOOK_OUTPUT");
1329  writeDotGraphFromFile(baseName+".dot",outDir,shortName,GOF_BITMAP);
1330  visitPreStart(m_t, s->hasCaption(), baseName + ".dot", s->width(),s->height());
1331  visitCaption(this, s->children());
1332  visitPostEnd(m_t, s->hasCaption());
1333 }
1334 
1336  const QCString &width,
1337  const QCString &height,
1338  bool hasCaption
1339  )
1340 {
1342  int i;
1343  if ((i=baseName.findRev('/'))!=-1)
1344  {
1345  baseName=baseName.right(baseName.length()-i-1);
1346  }
1347  if ((i=baseName.find('.'))!=-1)
1348  {
1349  baseName=baseName.left(i);
1350  }
1351  baseName.prepend("dot_");
1352  QCString outDir = Config_getString("DOCBOOK_OUTPUT");
1353  QCString imgExt = getDotImageExtension();
1354  writeDotGraphFromFile(fileName,outDir,baseName,GOF_BITMAP);
1355  m_t << "<para>" << endl;
1356  visitPreStart(m_t, hasCaption, baseName + "." + imgExt, width, height);
1357 }
1358 
1359 void DocbookDocVisitor::endDotFile(bool hasCaption)
1360 {
1361  if (m_hide) return;
1362  m_t << endl;
1363  visitPostEnd(m_t, hasCaption);
1364  m_t << "</para>" << endl;
1365 }
1366 
static QCString name
Definition: declinfo.cpp:673
QCString convertToXML(const char *s)
Definition: util.cpp:5717
QCString exampleFile() const
Definition: docparser.h:454
QCString file() const
Definition: docparser.h:946
Type type() const
Definition: docparser.h:532
Type type() const
Definition: docparser.h:1034
virtual QCString trPrecondition()=0
virtual QCString trSince()=0
ParserInterface * getParser(const char *extension)
Definition: parserintf.h:191
QCString name() const
Definition: docparser.h:695
QCString file() const
Definition: docparser.h:723
static void visitPostEnd(FTextStream &t, const bool hasCaption)
QCString anchor() const
Definition: docparser.h:830
QCString anchor() const
Definition: docparser.h:277
void writeMscGraphFromFile(const char *inFile, const char *outDir, const char *outFile, MscOutputFormat format)
Definition: msc.cpp:92
QCString url() const
Definition: docparser.h:239
QCString text() const
Definition: docparser.h:296
void endDiaFile(bool hasCaption)
virtual QCString trAttention()=0
bool isFirst() const
Definition: docparser.h:537
void visit(DocWord *)
void startLink(const QCString &file, const QCString &anchor)
bool isEmpty() const
Definition: qcstring.h:189
QCString file() const
Definition: docparser.h:747
void startDiaFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption)
QCString file() const
Definition: docparser.h:966
static TemplateVariant parseCode(MemberDef *md, const QCString &scopeName, const QCString &relPath, const QCString &code, int startLine=-1, int endLine=-1, bool showLineNumbers=FALSE)
Definition: context.cpp:1266
uint length() const
Definition: qcstring.h:195
bool isEmail() const
Definition: docparser.h:242
QCString anchor() const
Definition: docparser.h:944
#define IO_WriteOnly
Definition: qiodevice.h:62
bool hasCaption() const
Definition: docparser.h:773
virtual QCString trInvariant()=0
QCString blockId() const
Definition: docparser.h:505
virtual QCString trPostcondition()=0
QCString text() const
Definition: docparser.h:503
QCString file() const
Definition: docparser.h:278
Type type() const
Definition: docparser.h:1101
const bool FALSE
Definition: qglobal.h:370
DocbookDocVisitor(FTextStream &t, CodeOutputInterface &ci)
virtual QCString trWarning()=0
QCString writePlantUMLSource(const QCString &outDir, const QCString &fileName, const QCString &content)
Definition: plantuml.cpp:25
int readBlock(char *data, uint len)
Definition: qfile_unix.cpp:473
void writeMscFile(const QCString &fileName, DocVerbatim *s)
QCString left(uint len) const
Definition: qcstring.cpp:213
virtual QCString trCopyright()=0
void writeDotFile(const QCString &fileName, DocVerbatim *s)
static HtmlEntityMapper * instance()
Definition: htmlentity.cpp:341
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
QCString file() const
Definition: docparser.h:827
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:41
Type type() const
Definition: docparser.h:502
QCString anchor() const
Definition: docparser.h:859
SrcLangExt
Definition: types.h:41
static QStrList * l
Definition: config.cpp:1044
static void visitCaption(DocbookDocVisitor *parent, QList< DocNode > children)
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:95
QCString anchor() const
Definition: docparser.h:967
QCString width() const
Definition: docparser.h:459
virtual QCString trReturns()=0
virtual QCString trDate()=0
void startDotFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption)
virtual QCString trNote()=0
void push(const type *d)
Definition: qstack.h:58
QCString exampleFile() const
Definition: docparser.h:542
QCString extractBlock(const QCString text, const QCString marker)
Definition: util.cpp:7998
#define IO_ReadOnly
Definition: qiodevice.h:61
const char * docbook(DocSymbol::SymType symb) const
Access routine to the docbook code of the HTML entity.
Definition: htmlentity.cpp:415
Abstract visitor that participates in the visitor pattern.
Definition: docvisitor.h:90
bool isExample() const
Definition: docparser.h:453
virtual QCString trExceptions()=0
QCString height() const
Definition: docparser.h:460
void filter(const char *str)
static ParserManager * parserManager
Definition: doxygen.h:141
QCString targetTitle() const
Definition: docparser.h:831
def cli(ctx)
Definition: main.py:7
QCString height() const
Definition: docparser.h:775
int writeBlock(const char *data, uint len)
Definition: qfile_unix.cpp:537
QCString file() const
Definition: docparser.h:292
QCString file() const
Definition: docparser.h:771
QCString file() const
Definition: docparser.h:857
virtual QCString trParameters()=0
QCString text() const
Definition: docparser.h:450
fileName
Definition: dumpTree.py:9
QStack< bool > m_enabled
QCString text() const
Definition: docparser.h:563
QCString width() const
Definition: docparser.h:726
void endDotFile(bool hasCaption)
QCString anchor() const
Definition: docparser.h:670
QCString word() const
Definition: docparser.h:199
bool hasCaption() const
Definition: docparser.h:749
CodeOutputInterface & m_ci
QCString right(uint len) const
Definition: qcstring.cpp:231
std::void_t< T > n
virtual QCString trAuthor(bool first_capital, bool singular)=0
bool open(int)
Definition: qfile_unix.cpp:134
bool isExample() const
Definition: docparser.h:541
QCString context() const
Definition: docparser.h:535
QCString height() const
Definition: docparser.h:751
FileDef * findFileDef(const FileNameDict *fnDict, const char *n, bool &ambig)
Definition: util.cpp:4963
virtual QCString trReturnValues()=0
FTextStream & m_t
QCString & prepend(const char *s)
Definition: qcstring.cpp:387
const QList< DocNode > & children() const
Definition: docparser.h:461
void writeDotGraphFromFile(const char *inFile, const char *outDir, const char *outFile, GraphOutputFormat format)
Definition: dot.cpp:4203
QCString text() const
Definition: docparser.h:533
A bunch of utility functions.
bool isLast() const
Definition: docparser.h:538
const char * data() const
Definition: qcstring.h:207
Definition: msc.h:24
#define Config_getString(val)
Definition: config.cpp:660
type * current() const
Definition: qlist.h:146
QCString url() const
Definition: docparser.h:876
QCString width() const
Definition: docparser.h:750
virtual QCString trVersion()=0
Type type() const
Definition: docparser.h:1057
Style style() const
Definition: docparser.h:329
QCString getDotImageExtension(void)
Definition: util.cpp:8562
void generatePlantUMLOutput(const char *baseName, const char *outDir, PlantUMLOutputFormat format)
Definition: plantuml.cpp:54
Concrete visitor implementation for Docbook output.
void err(const char *fmt,...)
Definition: message.cpp:226
QCString entry() const
Definition: docparser.h:586
bool isExample() const
Definition: docparser.h:506
type * pop()
Definition: qstack.h:59
static FileNameDict * imageNameDict
Definition: doxygen.h:110
QCString word() const
Definition: docparser.h:215
QCString absFilePath() const
Definition: filedef.h:96
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
QCString & sprintf(const char *format,...)
Definition: qcstring.cpp:27
QCString title() const
Definition: docparser.h:943
QCString file() const
Definition: docparser.h:495
const QList< DocNode > & parameters()
Definition: docparser.h:1169
void writeDiaGraphFromFile(const char *inFile, const char *outDir, const char *outFile, DiaOutputFormat format)
Definition: dia.cpp:28
static void visitPreStart(FTextStream &t, const bool hasCaption, QCString name, QCString width, QCString height)
QCString context() const
Definition: docparser.h:451
SrcLangExt getLanguageFromFileName(const QCString fileName)
Definition: util.cpp:7061
QCString height() const
Definition: docparser.h:727
bool isEnumList() const
Definition: docparser.h:621
void writePlantUMLFile(const QCString &fileName, DocVerbatim *s)
SymType symbol() const
Definition: docparser.h:418
void visitPost(DocAutoList *)
QCString file() const
Definition: docparser.h:669
virtual QCString trTemplateParameters()=0
bool hasLinkText() const
Definition: docparser.h:832
void endMscFile(bool hasCaption)
void startMscFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption)
Translator * theTranslator
Definition: language.cpp:157
QCString exampleFile() const
Definition: docparser.h:507
QCString context() const
Definition: docparser.h:504
QCString anchor() const
Definition: docparser.h:295
list x
Definition: train.py:276
virtual QCString trRemarks()=0
QCString file() const
Definition: docparser.h:217
void visitPre(DocAutoList *)
bool enable() const
Definition: docparser.h:331
bool hasCaption() const
Definition: docparser.h:458
QCString chars() const
Definition: docparser.h:434
virtual QCString trSeeAlso()=0
QCString width() const
Definition: docparser.h:774
QCString title() const
Definition: docparser.h:671
static QCString baseName
Definition: scanner.cpp:10890
QCString extension() const
Definition: docparser.h:496
void writeDiaFile(const QCString &fileName, DocVerbatim *s)
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:51
bool hasCaption() const
Definition: docparser.h:725
Type type() const
Definition: docparser.h:449
const int DocVisitor_Docbook
Definition: docvisitor.h:30
Definition: dot.h:42
void close()
Definition: qfile_unix.cpp:614
Definition: dia.h:24
Type type() const
Definition: docparser.h:694
QCString anchor() const
Definition: docparser.h:220
virtual void parseCode(CodeOutputInterface &codeOutIntf, const char *scopeName, const QCString &input, SrcLangExt lang, bool isExampleBlock, const char *exampleName=0, FileDef *fileDef=0, int startLine=-1, int endLine=-1, bool inlineFragment=FALSE, MemberDef *memberDef=0, bool showLineNumbers=TRUE, Definition *searchCtx=0, bool collectXRefs=TRUE)=0
virtual void accept(DocVisitor *v)=0
static QCString * s
Definition: config.cpp:1042
def parent(G, child, parent_type)
Definition: graph.py:67
const bool TRUE
Definition: qglobal.h:371
static QCString str
uint size() const
Definition: qfile_unix.cpp:398
QTextStream & endl(QTextStream &s)
uint numColumns() const
Definition: docparser.h:1357
#define ASSERT(x)
Definition: qglobal.h:590
QCString name() const
Definition: docparser.h:562
type * toFirst()
Definition: qlist.h:135