Doxygen
Loading...
Searching...
No Matches
xmldocvisitor.cpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2020 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#include "xmldocvisitor.h"
17#include "docparser.h"
18#include "language.h"
19#include "doxygen.h"
20#include "outputgen.h"
21#include "xmlgen.h"
22#include "dot.h"
23#include "message.h"
24#include "util.h"
25#include "parserintf.h"
26#include "filename.h"
27#include "config.h"
28#include "htmlentity.h"
29#include "emoji.h"
30#include "filedef.h"
31#include "fileinfo.h"
32#include "codefragment.h"
33#include "cite.h"
34
36{
37 t << "<simplesect kind=\"";
38 switch(s.type())
39 {
41 t << "see"; break;
43 t << "return"; break;
45 t << "author"; break;
47 t << "authors"; break;
49 t << "version"; break;
51 t << "since"; break;
53 t << "date"; break;
55 t << "note"; break;
57 t << "warning"; break;
59 t << "pre"; break;
61 t << "post"; break;
63 t << "copyright"; break;
65 t << "invariant"; break;
67 t << "remark"; break;
69 t << "attention"; break;
71 t << "important"; break;
73 t << "par"; break;
75 t << "rcs"; break;
76 case DocSimpleSect::Unknown: break;
77 }
78 t << "\">";
79}
80
81static void endSimpleSect(TextStream &t,const DocSimpleSect &)
82{
83 t << "</simplesect>\n";
84}
85
86static void visitCaption(XmlDocVisitor &visitor, const DocNodeList &children)
87{
88 for (const auto &n : children)
89 {
90 std::visit(visitor,n);
91 }
92}
93
94static void visitPreStart(TextStream &t, const char *cmd, bool doCaption,
95 XmlDocVisitor &visitor, const DocNodeList &children,
96 const QCString &name, bool writeType, DocImage::Type type, const QCString &width,
97 const QCString &height, const QCString engine = QCString(), const QCString &alt = QCString(), bool inlineImage = FALSE)
98{
99 t << "<" << cmd;
100 if (writeType)
101 {
102 t << " type=\"";
103 switch(type)
104 {
105 case DocImage::Html: t << "html"; break;
106 case DocImage::Latex: t << "latex"; break;
107 case DocImage::Rtf: t << "rtf"; break;
108 case DocImage::DocBook: t << "docbook"; break;
109 case DocImage::Xml: t << "xml"; break;
110 }
111 t << "\"";
112 }
113 if (!name.isEmpty())
114 {
115 t << " name=\"" << convertToXML(name, TRUE) << "\"";
116 }
117 if (!width.isEmpty())
118 {
119 t << " width=\"" << convertToXML(width) << "\"";
120 }
121 if (!height.isEmpty())
122 {
123 t << " height=\"" << convertToXML(height) << "\"";
124 }
125 if (!engine.isEmpty())
126 {
127 t << " engine=\"" << convertToXML(engine) << "\"";
128 }
129 if (!alt.isEmpty())
130 {
131 t << " alt=\"" << convertToXML(alt) << "\"";
132 }
133 if (inlineImage)
134 {
135 t << " inline=\"yes\"";
136 }
137 if (doCaption)
138 {
139 t << " caption=\"";
140 visitCaption(visitor, children);
141 t << "\"";
142 }
143 t << ">";
144}
145
146static void visitPostEnd(TextStream &t, const char *cmd)
147{
148 t << "</" << cmd << ">\n";
149}
150
152 : m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE),
153 m_langExt(langExt), m_sectionLevel(0)
154{
155}
156
157 //--------------------------------------
158 // visitor functions for leaf nodes
159 //--------------------------------------
160
162{
163 if (m_hide) return;
164 filter(w.word());
165}
166
168{
169 if (m_hide) return;
170 startLink(w.ref(),w.file(),w.anchor());
171 filter(w.word());
172 endLink();
173}
174
176{
177 if (m_hide) return;
178 if (m_insidePre)
179 {
180 m_t << w.chars();
181 }
182 else
183 {
184 m_t << " ";
185 }
186}
187
189{
190 if (m_hide) return;
191 const char *res = HtmlEntityMapper::instance().xml(s.symbol());
192 if (res)
193 {
194 m_t << res;
195 }
196 else
197 {
198 err("XML: non supported HTML-entity found: {}\n",HtmlEntityMapper::instance().html(s.symbol(),TRUE));
199 }
200}
201
203{
204 if (m_hide) return;
205 const char *res = EmojiEntityMapper::instance().name(s.index());
206 if (res)
207 {
208 QCString name=res;
209 name = name.mid(1,name.length()-2);
210 m_t << "<emoji name=\"" << name << "\" unicode=\"";
212 m_t << "\"/>";
213 }
214 else
215 {
216 m_t << s.name();
217 }
218}
219
221{
222 if (m_hide) return;
223 m_t << "<ulink url=\"";
224 if (u.isEmail()) m_t << "mailto:";
225 filter(u.url());
226 m_t << "\">";
227 filter(u.url());
228 m_t << "</ulink>";
229}
230
232{
233 if (m_hide) return;
234 m_t << "<linebreak/>\n";
235}
236
238{
239 if (m_hide) return;
240 m_t << "<hruler/>\n";
241}
242
244{
245 if (m_hide) return;
246 switch (s.style())
247 {
249 if (s.enable()) m_t << "<bold>"; else m_t << "</bold>";
250 break;
252 if (s.enable()) m_t << "<s>"; else m_t << "</s>";
253 break;
255 if (s.enable()) m_t << "<strike>"; else m_t << "</strike>";
256 break;
258 if (s.enable()) m_t << "<del>"; else m_t << "</del>";
259 break;
261 if (s.enable()) m_t << "<underline>"; else m_t << "</underline>";
262 break;
264 if (s.enable()) m_t << "<ins>"; else m_t << "</ins>";
265 break;
267 if (s.enable()) m_t << "<emphasis>"; else m_t << "</emphasis>";
268 break;
272 if (s.enable()) m_t << "<computeroutput>"; else m_t << "</computeroutput>";
273 break;
275 if (s.enable()) m_t << "<subscript>"; else m_t << "</subscript>";
276 break;
278 if (s.enable()) m_t << "<superscript>"; else m_t << "</superscript>";
279 break;
281 if (s.enable()) m_t << "<center>"; else m_t << "</center>";
282 break;
284 if (s.enable()) m_t << "<small>"; else m_t << "</small>";
285 break;
287 if (s.enable()) m_t << "<cite>"; else m_t << "</cite>";
288 break;
290 if (s.enable())
291 {
292 m_t << "<preformatted>";
294 }
295 else
296 {
297 m_t << "</preformatted>";
299 }
300 break;
301 case DocStyleChange::Div: /* HTML only */ break;
302 case DocStyleChange::Span: /* HTML only */ break;
303 }
304}
305
307{
308 if (m_hide) return;
309 QCString lang = m_langExt;
310 if (!s.language().isEmpty()) // explicit language setting
311 {
312 lang = s.language();
313 }
314 SrcLangExt langExt = getLanguageFromCodeLang(lang);
315 switch(s.type())
316 {
318 m_t << "<programlisting";
319 if (!s.language().isEmpty())
320 m_t << " filename=\"" << lang << "\">";
321 else
322 m_t << ">";
323 getCodeParser(lang).parseCode(m_ci,s.context(),s.text(),langExt,
324 Config_getBool(STRIP_CODE_COMMENTS),
325 CodeParserOptions().setExample(s.isExample(),s.exampleFile()));
326 m_t << "</programlisting>";
327 break;
329 m_t << "<javadocliteral>";
330 filter(s.text());
331 m_t << "</javadocliteral>";
332 break;
334 m_t << "<javadoccode>";
335 filter(s.text());
336 m_t << "</javadoccode>";
337 break;
339 m_t << "<verbatim>";
340 filter(s.text());
341 m_t << "</verbatim>";
342 break;
344 if (s.isBlock())
345 {
346 m_t << "<htmlonly block=\"yes\">";
347 }
348 else
349 {
350 m_t << "<htmlonly>";
351 }
352 filter(s.text());
353 m_t << "</htmlonly>";
354 break;
356 m_t << "<rtfonly>";
357 filter(s.text());
358 m_t << "</rtfonly>";
359 break;
361 m_t << "<manonly>";
362 filter(s.text());
363 m_t << "</manonly>";
364 break;
366 m_t << "<latexonly>";
367 filter(s.text());
368 m_t << "</latexonly>";
369 break;
371 m_t << "<docbookonly>";
372 filter(s.text());
373 m_t << "</docbookonly>";
374 break;
376 m_t << s.text();
377 break;
378 case DocVerbatim::Dot:
379 visitPreStart(m_t, "dot", s.hasCaption(), *this, s.children(), QCString(""), FALSE, DocImage::Html, s.width(), s.height());
380 filter(s.text());
381 visitPostEnd(m_t, "dot");
382 break;
383 case DocVerbatim::Msc:
384 visitPreStart(m_t, "msc", s.hasCaption(), *this, s.children(), QCString(""), FALSE, DocImage::Html, s.width(), s.height());
385 filter(s.text());
386 visitPostEnd(m_t, "msc");
387 break;
389 visitPreStart(m_t, "plantuml", s.hasCaption(), *this, s.children(), QCString(""), FALSE, DocImage::Html, s.width(), s.height(), s.engine());
390 filter(s.text());
391 visitPostEnd(m_t, "plantuml");
392 break;
393 }
394}
395
397{
398 if (m_hide) return;
399 m_t << "<anchor id=\"" << anc.file() << "_1" << anc.anchor() << "\"/>";
400}
401
403{
404 if (m_hide) return;
406 //printf("XMLDocVisitor: DocInclude type=%d trimleft=%d\n",inc.type(),inc.trimLeft());
407 switch(inc.type())
408 {
410 {
411 m_t << "<programlisting filename=\"" << inc.file() << "\">";
412 FileInfo cfi( inc.file().str() );
413 auto fd = createFileDef( cfi.dirPath(), cfi.fileName());
415 inc.text(),
416 langExt,
417 inc.stripCodeComments(),
419 .setExample(inc.isExample(),inc.exampleFile())
420 .setFileDef(fd.get())
421 .setInlineFragment(true)
422 );
423 m_t << "</programlisting>";
424 }
425 break;
427 m_t << "<programlisting filename=\"" << inc.file() << "\">";
429 inc.text(),
430 langExt,
431 inc.stripCodeComments(),
433 .setExample(inc.isExample(),inc.exampleFile())
434 .setInlineFragment(true)
435 .setShowLineNumbers(false)
436 );
437 m_t << "</programlisting>";
438 break;
441 break;
443 if (inc.isBlock())
444 {
445 m_t << "<htmlonly block=\"yes\">";
446 }
447 else
448 {
449 m_t << "<htmlonly>";
450 }
451 filter(inc.text());
452 m_t << "</htmlonly>";
453 break;
455 m_t << "<latexonly>";
456 filter(inc.text());
457 m_t << "</latexonly>";
458 break;
460 m_t << "<rtfonly>";
461 filter(inc.text());
462 m_t << "</rtfonly>";
463 break;
465 m_t << "<manonly>";
466 filter(inc.text());
467 m_t << "</manonly>";
468 break;
470 filter(inc.text());
471 break;
473 m_t << "<docbookonly>";
474 filter(inc.text());
475 m_t << "</docbookonly>";
476 break;
478 m_t << "<verbatim>";
479 filter(inc.text());
480 m_t << "</verbatim>";
481 break;
484 m_t << "<programlisting filename=\"" << inc.file() << "\">";
486 inc.file(),
487 inc.blockId(),
488 inc.context(),
490 inc.trimLeft(),
492 );
493 m_t << "</programlisting>";
494 break;
495 }
496}
497
499{
500 //printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
501 // op.type(),op.isFirst(),op.isLast(),qPrint(op.text()));
502 if (op.isFirst())
503 {
504 if (!m_hide)
505 {
506 m_t << "<programlisting filename=\"" << op.includeFileName() << "\">";
507 }
509 m_hide = TRUE;
510 }
512 if (locLangExt.isEmpty()) locLangExt = m_langExt;
513 SrcLangExt langExt = getLanguageFromFileName(locLangExt);
514 if (op.type()!=DocIncOperator::Skip)
515 {
516 m_hide = popHidden();
517 if (!m_hide)
518 {
519 std::unique_ptr<FileDef> fd;
520 if (!op.includeFileName().isEmpty())
521 {
522 FileInfo cfi( op.includeFileName().str() );
523 fd = createFileDef( cfi.dirPath(), cfi.fileName() );
524 }
525
526 getCodeParser(locLangExt).parseCode(m_ci,op.context(),
527 op.text(),langExt,
530 .setExample(op.isExample(), op.exampleFile())
531 .setFileDef(fd.get())
532 .setStartLine(op.line())
534 );
535 }
537 m_hide=TRUE;
538 }
539 if (op.isLast())
540 {
541 m_hide = popHidden();
542 if (!m_hide) m_t << "</programlisting>";
543 }
544 else
545 {
546 if (!m_hide) m_t << "\n";
547 }
548}
549
551{
552 if (m_hide) return;
553 m_t << "<formula id=\"" << f.id() << "\">";
554 filter(f.text());
555 m_t << "</formula>";
556}
557
559{
560 if (m_hide) return;
561 m_t << "<indexentry>"
562 "<primaryie>";
563 filter(ie.entry());
564 m_t << "</primaryie>"
565 "<secondaryie></secondaryie>"
566 "</indexentry>";
567}
568
570{
571 const DocSimpleSect *sect = std::get_if<DocSimpleSect>(sep.parent());
572 if (sect)
573 {
574 endSimpleSect(m_t,*sect);
575 startSimpleSect(m_t,*sect);
576 }
577}
578
580{
581 if (m_hide) return;
582 auto opt = cite.option();
583 if (!cite.file().isEmpty())
584 {
585 if (!opt.noCite()) startLink(cite.ref(),cite.file(),cite.anchor());
586
587 filter(cite.getText());
588
589 if (!opt.noCite()) endLink();
590 }
591 else
592 {
593 m_t << "<b>";
594 if (!opt.noPar()) filter("[");
595 filter(cite.target());
596 if (!opt.noPar()) filter("]");
597 m_t << "</b>";
598 }
599}
600
601//--------------------------------------
602// visitor functions for compound nodes
603//--------------------------------------
604
606{
607 if (m_hide) return;
608 if (l.isEnumList())
609 {
610 m_t << "<orderedlist>\n";
611 }
612 else
613 {
614 m_t << "<itemizedlist>\n";
615 }
616 visitChildren(l);
617 if (l.isEnumList())
618 {
619 m_t << "</orderedlist>\n";
620 }
621 else
622 {
623 m_t << "</itemizedlist>\n";
624 }
625}
626
628{
629 if (m_hide) return;
630 switch (li.itemNumber())
631 {
632 case DocAutoList::Unchecked: // unchecked
633 m_t << "<listitem override=\"unchecked\">";
634 break;
635 case DocAutoList::Checked_x: // checked with x
636 case DocAutoList::Checked_X: // checked with X
637 m_t << "<listitem override=\"checked\">";
638 break;
639 default:
640 m_t << "<listitem>";
641 break;
642 }
643 visitChildren(li);
644 m_t << "</listitem>";
645}
646
648{
649 if (m_hide) return;
650 m_t << "<para>";
651 visitChildren(p);
652 m_t << "</para>\n";
653}
654
656{
657 visitChildren(r);
658}
659
661{
662 if (m_hide) return;
664 if (s.title())
665 {
666 std::visit(*this,*s.title());
667 }
668 visitChildren(s);
670}
671
673{
674 if (m_hide) return;
675 m_t << "<title>";
676 visitChildren(t);
677 m_t << "</title>";
678}
679
681{
682 if (m_hide) return;
683 m_t << "<itemizedlist>\n";
684 visitChildren(l);
685 m_t << "</itemizedlist>\n";
686}
687
689{
690 if (m_hide) return;
691 m_t << "<listitem>";
692 if (li.paragraph())
693 {
694 std::visit(*this,*li.paragraph());
695 }
696 m_t << "</listitem>\n";
697}
698
700{
701 if (m_hide) return;
702 int orgSectionLevel = m_sectionLevel;
703 QCString sectId = s.file();
704 if (!s.anchor().isEmpty()) sectId += "_1"+s.anchor();
705 while (m_sectionLevel+1<s.level()) // fix missing intermediate levels
706 {
708 m_t << "<sect" << m_sectionLevel << " id=\"" << sectId << "_1s" << m_sectionLevel << "\">";
709 }
711 m_t << "<sect" << s.level() << " id=\"" << sectId << "\">\n";
712 if (s.title())
713 {
714 std::visit(*this,*s.title());
715 }
716 visitChildren(s);
717 m_t << "</sect" << s.level() << ">";
719 while (orgSectionLevel<m_sectionLevel) // fix missing intermediate levels
720 {
721 m_t << "</sect" << m_sectionLevel << ">";
723 }
724 m_t << "\n";
725}
726
728{
729 if (m_hide) return;
730 if (s.type()==DocHtmlList::Ordered)
731 {
732 m_t << "<orderedlist";
733 for (const auto &opt : s.attribs())
734 {
735 m_t << " " << opt.name << "=\"" << opt.value << "\"";
736 }
737 m_t << ">\n";
738 }
739 else
740 {
741 m_t << "<itemizedlist>\n";
742 }
743 visitChildren(s);
744 if (s.type()==DocHtmlList::Ordered)
745 {
746 m_t << "</orderedlist>\n";
747 }
748 else
749 {
750 m_t << "</itemizedlist>\n";
751 }
752}
753
755{
756 if (m_hide) return;
757 m_t << "<listitem";
758 for (const auto &opt : l.attribs())
759 {
760 if (opt.name=="value")
761 {
762 m_t << " " << opt.name << "=\"" << opt.value << "\"";
763 }
764 }
765 m_t << ">\n";
766 visitChildren(l);
767 m_t << "</listitem>\n";
768}
769
771{
772 if (m_hide) return;
773 m_t << "<variablelist>\n";
774 visitChildren(dl);
775 m_t << "</variablelist>\n";
776}
777
779{
780 if (m_hide) return;
781 m_t << "<varlistentry><term>";
782 visitChildren(dt);
783 m_t << "</term></varlistentry>\n";
784}
785
787{
788 if (m_hide) return;
789 m_t << "<listitem>";
790 visitChildren(dd);
791 m_t << "</listitem>\n";
792}
793
795{
796 if (m_hide) return;
797 m_t << "<table rows=\"" << t.numRows()
798 << "\" cols=\"" << t.numColumns() << "\"" ;
799 for (const auto &opt : t.attribs())
800 {
801 if (opt.name=="width")
802 {
803 m_t << " " << opt.name << "=\"" << opt.value << "\"";
804 }
805 }
806 m_t << ">";
807 if (t.caption())
808 {
809 std::visit(*this,*t.caption());
810 }
811 visitChildren(t);
812 m_t << "</table>\n";
813}
814
816{
817 if (m_hide) return;
818 m_t << "<row>\n";
819 visitChildren(r);
820 m_t << "</row>\n";
821}
822
824{
825 if (m_hide) return;
826 if (c.isHeading()) m_t << "<entry thead=\"yes\""; else m_t << "<entry thead=\"no\"";
827 for (const auto &opt : c.attribs())
828 {
829 if (opt.name=="colspan" || opt.name=="rowspan")
830 {
831 m_t << " " << opt.name << "=\"" << opt.value.toInt() << "\"";
832 }
833 else if (opt.name=="align" &&
834 (opt.value=="right" || opt.value=="left" || opt.value=="center"))
835 {
836 m_t << " align=\"" << opt.value << "\"";
837 }
838 else if (opt.name=="valign" &&
839 (opt.value == "bottom" || opt.value == "top" || opt.value == "middle"))
840 {
841 m_t << " valign=\"" << opt.value << "\"";
842 }
843 else if (opt.name=="width")
844 {
845 m_t << " width=\"" << opt.value << "\"";
846 }
847 else if (opt.name=="class") // handle markdown generated attributes
848 {
849 if (opt.value.startsWith("markdownTable")) // handle markdown generated attributes
850 {
851 if (opt.value.endsWith("Right"))
852 {
853 m_t << " align='right'";
854 }
855 else if (opt.value.endsWith("Left"))
856 {
857 m_t << " align='left'";
858 }
859 else if (opt.value.endsWith("Center"))
860 {
861 m_t << " align='center'";
862 }
863 // skip 'markdownTable*' value ending with "None"
864 }
865 else if (!opt.value.isEmpty())
866 {
867 m_t << " class=\"" << convertToXML(opt.value) << "\"";
868 }
869 }
870 }
871 m_t << ">";
872 visitChildren(c);
873 m_t << "</entry>";
874}
875
877{
878 if (m_hide) return;
879 m_t << "<caption";
880 if (!c.file().isEmpty())
881 {
882 m_t << " id=\"" << stripPath(c.file()) << "_1" << c.anchor() << "\"";
883 }
884 m_t << ">";
885 visitChildren(c);
886 m_t << "</caption>\n";
887}
888
890{
891 if (m_hide) return;
892 m_t << "<internal>";
893 visitChildren(i);
894 m_t << "</internal>\n";
895}
896
898{
899 if (m_hide) return;
900 m_t << "<ulink url=\"" << convertToXML(href.url(), TRUE) << "\">";
901 visitChildren(href);
902 m_t << "</ulink>";
903}
904
906{
907 if (m_hide) return;
908 m_t << "<summary>";
909 visitChildren(s);
910 m_t << "</summary>";
911}
912
914{
915 if (m_hide) return;
916 m_t << "<details>";
917 auto summary = d.summary();
918 if (summary)
919 {
920 std::visit(*this,*summary);
921 }
922 visitChildren(d);
923 m_t << "</details>";
924}
925
927{
928 if (m_hide) return;
929 m_t << "<heading level=\"" << header.level() << "\">";
930 visitChildren(header);
931 m_t << "</heading>\n";
932}
933
935{
936 if (m_hide) return;
937
938 QCString url = img.url();
939 QCString baseName;
940 if (url.isEmpty())
941 {
942 baseName = img.relPath()+img.name();
943 }
944 else
945 {
946 baseName = correctURL(url,img.relPath());
947 }
948 HtmlAttribList attribs = img.attribs();
949 auto it = std::find_if(attribs.begin(),attribs.end(),
950 [](const auto &att) { return att.name=="alt"; });
951 QCString altValue = it!=attribs.end() ? it->value : "";
952 visitPreStart(m_t, "image", FALSE, *this, img.children(), baseName, TRUE,
953 img.type(), img.width(), img.height(), QCString(),
954 altValue, img.isInlineImage());
955
956 // copy the image to the output dir
957 FileDef *fd = nullptr;
958 bool ambig;
959 if (url.isEmpty() && (fd=findFileDef(Doxygen::imageNameLinkedMap,img.name(),ambig)))
960 {
961 copyFile(fd->absFilePath(),Config_getString(XML_OUTPUT)+"/"+baseName);
962 }
963 visitChildren(img);
964 visitPostEnd(m_t, "image");
965}
966
968{
969 if (m_hide) return;
970 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
971 visitPreStart(m_t, "dotfile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
972 visitChildren(df);
973 visitPostEnd(m_t, "dotfile");
974}
975
977{
978 if (m_hide) return;
979 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
980 visitPreStart(m_t, "mscfile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
981 visitChildren(df);
982 visitPostEnd(m_t, "mscfile");
983}
984
986{
987 if (m_hide) return;
988 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
989 visitPreStart(m_t, "diafile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
990 visitChildren(df);
991 visitPostEnd(m_t, "diafile");
992}
993
995{
996 if (m_hide) return;
997 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
998 visitPreStart(m_t, "plantumlfile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
999 visitChildren(df);
1000 visitPostEnd(m_t, "plantumlfile");
1001}
1002
1004{
1005 if (m_hide) return;
1006 startLink(lnk.ref(),lnk.file(),lnk.anchor());
1007 visitChildren(lnk);
1008 endLink();
1009}
1010
1012{
1013 if (m_hide) return;
1014 if (!ref.file().isEmpty())
1015 {
1016 startLink(ref.ref(),ref.file(),ref.isSubPage() ? QCString() : ref.anchor());
1017 }
1018 if (!ref.hasLinkText()) filter(ref.targetTitle());
1019 visitChildren(ref);
1020 if (!ref.file().isEmpty()) endLink();
1021}
1022
1024{
1025 if (m_hide) return;
1026 m_t << "<tocitem id=\"" << ref.file();
1027 if (!ref.anchor().isEmpty()) m_t << "_1" << ref.anchor();
1028 m_t << "\"";
1029 m_t << ">";
1030 visitChildren(ref);
1031 m_t << "</tocitem>\n";
1032}
1033
1035{
1036 if (m_hide) return;
1037 m_t << "<toclist>\n";
1038 visitChildren(l);
1039 m_t << "</toclist>\n";
1040}
1041
1043{
1044 if (m_hide) return;
1045 m_t << "<parameterlist kind=\"";
1046 switch(s.type())
1047 {
1049 m_t << "param"; break;
1051 m_t << "retval"; break;
1053 m_t << "exception"; break;
1055 m_t << "templateparam"; break;
1056 default:
1057 ASSERT(0);
1058 }
1059 m_t << "\">";
1060 visitChildren(s);
1061 m_t << "</parameterlist>\n";
1062}
1063
1065{
1066 m_t << "</parametertype>\n";
1067 m_t << "<parametertype>";
1068}
1069
1071{
1072 if (m_hide) return;
1073 m_t << "<parameteritem>\n";
1074 m_t << "<parameternamelist>\n";
1075 for (const auto &param : pl.parameters())
1076 {
1077 if (!pl.paramTypes().empty())
1078 {
1079 m_t << "<parametertype>";
1080 for (const auto &type : pl.paramTypes())
1081 {
1082 std::visit(*this,type);
1083 }
1084 m_t << "</parametertype>\n";
1085 }
1086 m_t << "<parametername";
1088 {
1089 m_t << " direction=\"";
1090 if (pl.direction()==DocParamSect::In)
1091 {
1092 m_t << "in";
1093 }
1094 else if (pl.direction()==DocParamSect::Out)
1095 {
1096 m_t << "out";
1097 }
1098 else if (pl.direction()==DocParamSect::InOut)
1099 {
1100 m_t << "inout";
1101 }
1102 m_t << "\"";
1103 }
1104 m_t << ">";
1105 std::visit(*this,param);
1106 m_t << "</parametername>\n";
1107 }
1108 m_t << "</parameternamelist>\n";
1109 m_t << "<parameterdescription>\n";
1110 for (const auto &par : pl.paragraphs())
1111 {
1112 std::visit(*this,par);
1113 }
1114 m_t << "</parameterdescription>\n";
1115 m_t << "</parameteritem>\n";
1116}
1117
1119{
1120 if (m_hide) return;
1121 if (x.title().isEmpty()) return;
1122 m_t << "<xrefsect id=\"";
1123 m_t << x.file() << "_1" << x.anchor();
1124 m_t << "\">";
1125 m_t << "<xreftitle>";
1126 filter(x.title());
1127 m_t << "</xreftitle>";
1128 m_t << "<xrefdescription>";
1129 visitChildren(x);
1130 if (x.title().isEmpty()) return;
1131 m_t << "</xrefdescription>";
1132 m_t << "</xrefsect>";
1133}
1134
1136{
1137 if (m_hide) return;
1138 startLink(QCString(),ref.file(),ref.anchor());
1139 visitChildren(ref);
1140 endLink();
1141 m_t << " ";
1142}
1143
1145{
1146 visitChildren(t);
1147}
1148
1150{
1151 if (m_hide) return;
1152 m_t << "<blockquote>";
1153 visitChildren(q);
1154 m_t << "</blockquote>";
1155}
1156
1158{
1159}
1160
1162{
1163 if (m_hide) return;
1164 m_t << "<parblock>";
1165 visitChildren(pb);
1166 m_t << "</parblock>";
1167}
1168
1169
1171{
1172 m_t << convertToXML(str);
1173}
1174
1175void XmlDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1176{
1177 //printf("XmlDocVisitor: file=%s anchor=%s\n",qPrint(file),qPrint(anchor));
1178 m_t << "<ref refid=\"" << file;
1179 if (!anchor.isEmpty()) m_t << "_1" << anchor;
1180 m_t << "\" kindref=\"";
1181 if (!anchor.isEmpty()) m_t << "member"; else m_t << "compound";
1182 m_t << "\"";
1183 if (!ref.isEmpty()) m_t << " external=\"" << ref << "\"";
1184 m_t << ">";
1185}
1186
1188{
1189 m_t << "</ref>";
1190}
1191
void parseCodeFragment(OutputCodeList &codeOutList, const QCString &fileName, const QCString &blockId, const QCString &scopeName, bool showLineNumbers, bool trimLeft, bool stripCodeComments)
static CodeFragmentManager & instance()
virtual void parseCode(OutputCodeList &codeOutList, const QCString &scopeName, const QCString &input, SrcLangExt lang, bool stripCodeComments, const CodeParserOptions &options)=0
Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
Node representing an anchor.
Definition docnode.h:229
QCString anchor() const
Definition docnode.h:232
QCString file() const
Definition docnode.h:233
Node representing an auto List.
Definition docnode.h:571
bool isEnumList() const
Definition docnode.h:580
Node representing an item of a auto list.
Definition docnode.h:595
int itemNumber() const
Definition docnode.h:598
Node representing a citation of some bibliographic reference.
Definition docnode.h:245
QCString getText() const
Definition docnode.cpp:959
CiteInfoOption option() const
Definition docnode.h:253
QCString target() const
Definition docnode.h:252
QCString anchor() const
Definition docnode.h:251
QCString ref() const
Definition docnode.h:250
QCString file() const
Definition docnode.h:248
DocNodeList & children()
Definition docnode.h:143
Node representing a dia file.
Definition docnode.h:731
QCString height() const
Definition docnode.h:689
QCString file() const
Definition docnode.h:685
QCString width() const
Definition docnode.h:688
Node representing a dot file.
Definition docnode.h:713
Node representing an emoji.
Definition docnode.h:341
int index() const
Definition docnode.h:345
QCString name() const
Definition docnode.h:344
Node representing an item of a cross-referenced list.
Definition docnode.h:529
QCString text() const
Definition docnode.h:533
int id() const
Definition docnode.h:535
Node representing a Hypertext reference.
Definition docnode.h:823
QCString url() const
Definition docnode.h:830
Node representing a horizontal ruler.
Definition docnode.h:216
Node representing an HTML blockquote.
Definition docnode.h:1291
Node representing a HTML table caption.
Definition docnode.h:1228
QCString anchor() const
Definition docnode.h:1235
QCString file() const
Definition docnode.h:1234
Node representing a HTML table cell.
Definition docnode.h:1193
bool isHeading() const
Definition docnode.h:1200
const HtmlAttribList & attribs() const
Definition docnode.h:1205
Node representing a HTML description data.
Definition docnode.h:1181
Node representing a Html description list.
Definition docnode.h:901
Node representing a Html description item.
Definition docnode.h:888
Node Html details.
Definition docnode.h:857
const DocNodeVariant * summary() const
Definition docnode.h:864
Node Html heading.
Definition docnode.h:873
int level() const
Definition docnode.h:877
Node representing a Html list.
Definition docnode.h:1000
const HtmlAttribList & attribs() const
Definition docnode.h:1006
Type type() const
Definition docnode.h:1005
Node representing a HTML list item.
Definition docnode.h:1165
const HtmlAttribList & attribs() const
Definition docnode.h:1170
Node representing a HTML table row.
Definition docnode.h:1246
Node Html summary.
Definition docnode.h:844
Node representing a HTML table.
Definition docnode.h:1269
size_t numRows() const
Definition docnode.h:1273
size_t numColumns() const
Definition docnode.h:1278
const DocNodeVariant * caption() const
Definition docnode.cpp:2189
const HtmlAttribList & attribs() const
Definition docnode.h:1275
Node representing an image.
Definition docnode.h:642
const HtmlAttribList & attribs() const
Definition docnode.h:656
QCString relPath() const
Definition docnode.h:652
QCString name() const
Definition docnode.h:648
QCString url() const
Definition docnode.h:653
QCString height() const
Definition docnode.h:651
Type type() const
Definition docnode.h:647
QCString width() const
Definition docnode.h:650
@ DocBook
Definition docnode.h:644
bool isInlineImage() const
Definition docnode.h:654
Node representing a include/dontinclude operator block.
Definition docnode.h:477
bool stripCodeComments() const
Definition docnode.h:506
bool isLast() const
Definition docnode.h:503
QCString includeFileName() const
Definition docnode.h:509
QCString text() const
Definition docnode.h:499
QCString context() const
Definition docnode.h:501
QCString exampleFile() const
Definition docnode.h:508
int line() const
Definition docnode.h:497
Type type() const
Definition docnode.h:485
bool isFirst() const
Definition docnode.h:502
bool showLineNo() const
Definition docnode.h:498
bool isExample() const
Definition docnode.h:507
Node representing an included text block from file.
Definition docnode.h:435
QCString blockId() const
Definition docnode.h:454
QCString extension() const
Definition docnode.h:450
bool isBlock() const
Definition docnode.h:458
bool stripCodeComments() const
Definition docnode.h:455
@ LatexInclude
Definition docnode.h:437
@ SnippetWithLines
Definition docnode.h:438
@ DontIncWithLines
Definition docnode.h:439
@ IncWithLines
Definition docnode.h:438
@ HtmlInclude
Definition docnode.h:437
@ VerbInclude
Definition docnode.h:437
@ DontInclude
Definition docnode.h:437
@ DocbookInclude
Definition docnode.h:439
Type type() const
Definition docnode.h:451
QCString exampleFile() const
Definition docnode.h:457
QCString text() const
Definition docnode.h:452
QCString file() const
Definition docnode.h:449
bool trimLeft() const
Definition docnode.h:459
bool isExample() const
Definition docnode.h:456
QCString context() const
Definition docnode.h:453
Node representing an entry in the index.
Definition docnode.h:552
QCString entry() const
Definition docnode.h:559
Node representing an internal section of documentation.
Definition docnode.h:969
Node representing an internal reference to some item.
Definition docnode.h:807
QCString file() const
Definition docnode.h:811
QCString anchor() const
Definition docnode.h:813
Node representing a line break.
Definition docnode.h:202
Node representing a word that can be linked to something.
Definition docnode.h:165
QCString file() const
Definition docnode.h:171
QCString ref() const
Definition docnode.h:173
QCString word() const
Definition docnode.h:170
QCString anchor() const
Definition docnode.h:174
Node representing a msc file.
Definition docnode.h:722
DocNodeVariant * parent()
Definition docnode.h:90
Node representing an block of paragraphs.
Definition docnode.h:979
Node representing a paragraph in the documentation tree.
Definition docnode.h:1080
Node representing a parameter list.
Definition docnode.h:1125
const DocNodeList & parameters() const
Definition docnode.h:1129
const DocNodeList & paramTypes() const
Definition docnode.h:1130
DocParamSect::Direction direction() const
Definition docnode.h:1133
const DocNodeList & paragraphs() const
Definition docnode.h:1131
Node representing a parameter section.
Definition docnode.h:1053
Type type() const
Definition docnode.h:1068
Node representing a uml file.
Definition docnode.h:740
Node representing a reference to some item.
Definition docnode.h:778
QCString anchor() const
Definition docnode.h:785
QCString targetTitle() const
Definition docnode.h:786
bool isSubPage() const
Definition docnode.h:792
QCString file() const
Definition docnode.h:782
QCString ref() const
Definition docnode.h:784
bool hasLinkText() const
Definition docnode.h:788
Root node of documentation tree.
Definition docnode.h:1313
Node representing a reference to a section.
Definition docnode.h:935
QCString file() const
Definition docnode.h:939
QCString anchor() const
Definition docnode.h:940
Node representing a list of section references.
Definition docnode.h:959
Node representing a normal section.
Definition docnode.h:914
QCString file() const
Definition docnode.h:922
int level() const
Definition docnode.h:918
QCString anchor() const
Definition docnode.h:920
const DocNodeVariant * title() const
Definition docnode.h:919
Node representing a separator.
Definition docnode.h:365
Node representing a simple list.
Definition docnode.h:990
Node representing a simple list item.
Definition docnode.h:1153
const DocNodeVariant * paragraph() const
Definition docnode.h:1157
Node representing a simple section.
Definition docnode.h:1017
Type type() const
Definition docnode.h:1026
const DocNodeVariant * title() const
Definition docnode.h:1033
Node representing a separator between two simple sections of the same type.
Definition docnode.h:1044
Node representing a style change.
Definition docnode.h:268
Style style() const
Definition docnode.h:307
bool enable() const
Definition docnode.h:309
Node representing a special symbol.
Definition docnode.h:328
HtmlEntityMapper::SymType symbol() const
Definition docnode.h:332
Root node of a text fragment.
Definition docnode.h:1304
Node representing a simple section title.
Definition docnode.h:608
Node representing a URL (or email address).
Definition docnode.h:188
QCString url() const
Definition docnode.h:192
bool isEmail() const
Definition docnode.h:193
Node representing a verbatim, unparsed text fragment.
Definition docnode.h:376
QCString height() const
Definition docnode.h:392
bool hasCaption() const
Definition docnode.h:390
QCString language() const
Definition docnode.h:388
const DocNodeList & children() const
Definition docnode.h:395
bool isBlock() const
Definition docnode.h:389
bool isExample() const
Definition docnode.h:385
QCString context() const
Definition docnode.h:384
Type type() const
Definition docnode.h:382
QCString text() const
Definition docnode.h:383
QCString exampleFile() const
Definition docnode.h:386
QCString engine() const
Definition docnode.h:393
@ JavaDocLiteral
Definition docnode.h:378
QCString width() const
Definition docnode.h:391
Node representing a VHDL flow chart.
Definition docnode.h:749
CodeParserInterface & getCodeParser(const QCString &langExt)
void pushHidden(bool hide)
bool popHidden()
Node representing some amount of white space.
Definition docnode.h:354
QCString chars() const
Definition docnode.h:358
Node representing a word.
Definition docnode.h:153
QCString word() const
Definition docnode.h:156
Node representing an item of a cross-referenced list.
Definition docnode.h:621
QCString anchor() const
Definition docnode.h:625
QCString file() const
Definition docnode.h:624
QCString title() const
Definition docnode.h:626
static FileNameLinkedMap * imageNameLinkedMap
Definition doxygen.h:105
const char * name(int index) const
Access routine to the name of the Emoji entity.
Definition emoji.cpp:2026
static EmojiEntityMapper & instance()
Returns the one and only instance of the Emoji entity mapper.
Definition emoji.cpp:1978
A model of a file symbol.
Definition filedef.h:99
virtual QCString absFilePath() const =0
Minimal replacement for QFileInfo.
Definition fileinfo.h:23
std::string fileName() const
Definition fileinfo.cpp:118
std::string dirPath(bool absPath=true) const
Definition fileinfo.cpp:137
bool empty() const
checks whether the container is empty
Definition growvector.h:140
Class representing a list of HTML attributes.
Definition htmlattrib.h:33
const char * xml(SymType symb) const
Access routine to the XML code of the HTML entity.
static HtmlEntityMapper & instance()
Returns the one and only instance of the HTML entity mapper.
Class representing a list of different code generators.
Definition outputlist.h:165
This is an alternative implementation of QCString.
Definition qcstring.h:101
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:241
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
const std::string & str() const
Definition qcstring.h:552
Text streaming class that buffers data.
Definition textstream.h:36
Concrete visitor implementation for XML output.
OutputCodeList & m_ci
void visitChildren(const T &t)
TextStream & m_t
void filter(const QCString &str)
void startLink(const QCString &ref, const QCString &file, const QCString &anchor)
XmlDocVisitor(TextStream &t, OutputCodeList &ci, const QCString &langExt)
void operator()(const DocWord &)
QCString m_langExt
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:268
static void visitPreStart(TextStream &t, bool hasCaption, QCString name, QCString width, QCString height, bool inlineImage=FALSE)
static void visitPostEnd(TextStream &t, bool hasCaption, bool inlineImage=FALSE)
#define err(fmt,...)
Definition message.h:127
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
#define ASSERT(x)
Definition qcstring.h:39
Options to configure the code parser.
Definition parserintf.h:78
CodeParserOptions & setStartLine(int lineNr)
Definition parserintf.h:101
CodeParserOptions & setInlineFragment(bool enable)
Definition parserintf.h:107
CodeParserOptions & setShowLineNumbers(bool enable)
Definition parserintf.h:113
CodeParserOptions & setFileDef(const FileDef *fd)
Definition parserintf.h:98
SrcLangExt
Definition types.h:207
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5147
QCString correctURL(const QCString &url, const QCString &relPath)
Corrects URL url according to the relative path relPath.
Definition util.cpp:5877
QCString stripPath(const QCString &s)
Definition util.cpp:4890
SrcLangExt getLanguageFromCodeLang(QCString &fileName)
Routine to handle the language attribute of the \code command.
Definition util.cpp:5165
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:3854
bool copyFile(const QCString &src, const QCString &dest)
Copies the contents of file with name src to the newly created file with name dest.
Definition util.cpp:5809
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5189
FileDef * findFileDef(const FileNameLinkedMap *fnMap, const QCString &n, bool &ambig)
Definition util.cpp:2838
A bunch of utility functions.
static void visitCaption(XmlDocVisitor &visitor, const DocNodeList &children)
static void visitPostEnd(TextStream &t, const char *cmd)
static void endSimpleSect(TextStream &t, const DocSimpleSect &)
static void startSimpleSect(TextStream &t, const DocSimpleSect &s)
static void visitPreStart(TextStream &t, const char *cmd, bool doCaption, XmlDocVisitor &visitor, const DocNodeList &children, const QCString &name, bool writeType, DocImage::Type type, const QCString &width, const QCString &height, const QCString engine=QCString(), const QCString &alt=QCString(), bool inlineImage=FALSE)