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
35{
36 t << "<simplesect kind=\"";
37 switch(s.type())
38 {
40 t << "see"; break;
42 t << "return"; break;
44 t << "author"; break;
46 t << "authors"; break;
48 t << "version"; break;
50 t << "since"; break;
52 t << "date"; break;
54 t << "note"; break;
56 t << "warning"; break;
58 t << "pre"; break;
60 t << "post"; break;
62 t << "copyright"; break;
64 t << "invariant"; break;
66 t << "remark"; break;
68 t << "attention"; break;
70 t << "important"; break;
72 t << "par"; break;
74 t << "rcs"; break;
75 case DocSimpleSect::Unknown: break;
76 }
77 t << "\">";
78}
79
80static void endSimpleSect(TextStream &t,const DocSimpleSect &)
81{
82 t << "</simplesect>\n";
83}
84
85static void visitCaption(XmlDocVisitor &visitor, const DocNodeList &children)
86{
87 for (const auto &n : children)
88 {
89 std::visit(visitor,n);
90 }
91}
92
93static void visitPreStart(TextStream &t, const char *cmd, bool doCaption,
94 XmlDocVisitor &visitor, const DocNodeList &children,
95 const QCString &name, bool writeType, DocImage::Type type, const QCString &width,
96 const QCString &height, const QCString engine = QCString(), const QCString &alt = QCString(), bool inlineImage = FALSE)
97{
98 t << "<" << cmd;
99 if (writeType)
100 {
101 t << " type=\"";
102 switch(type)
103 {
104 case DocImage::Html: t << "html"; break;
105 case DocImage::Latex: t << "latex"; break;
106 case DocImage::Rtf: t << "rtf"; break;
107 case DocImage::DocBook: t << "docbook"; break;
108 case DocImage::Xml: t << "xml"; break;
109 }
110 t << "\"";
111 }
112 if (!name.isEmpty())
113 {
114 t << " name=\"" << convertToXML(name, TRUE) << "\"";
115 }
116 if (!width.isEmpty())
117 {
118 t << " width=\"" << convertToXML(width) << "\"";
119 }
120 if (!height.isEmpty())
121 {
122 t << " height=\"" << convertToXML(height) << "\"";
123 }
124 if (!engine.isEmpty())
125 {
126 t << " engine=\"" << convertToXML(engine) << "\"";
127 }
128 if (!alt.isEmpty())
129 {
130 t << " alt=\"" << convertToXML(alt) << "\"";
131 }
132 if (inlineImage)
133 {
134 t << " inline=\"yes\"";
135 }
136 if (doCaption)
137 {
138 t << " caption=\"";
139 visitCaption(visitor, children);
140 t << "\"";
141 }
142 t << ">";
143}
144
145static void visitPostEnd(TextStream &t, const char *cmd)
146{
147 t << "</" << cmd << ">\n";
148}
149
151 : m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE),
152 m_langExt(langExt), m_sectionLevel(0)
153{
154}
155
156 //--------------------------------------
157 // visitor functions for leaf nodes
158 //--------------------------------------
159
161{
162 if (m_hide) return;
163 filter(w.word());
164}
165
167{
168 if (m_hide) return;
169 startLink(w.ref(),w.file(),w.anchor());
170 filter(w.word());
171 endLink();
172}
173
175{
176 if (m_hide) return;
177 if (m_insidePre)
178 {
179 m_t << w.chars();
180 }
181 else
182 {
183 m_t << " ";
184 }
185}
186
188{
189 if (m_hide) return;
190 const char *res = HtmlEntityMapper::instance().xml(s.symbol());
191 if (res)
192 {
193 m_t << res;
194 }
195 else
196 {
197 err("XML: non supported HTML-entity found: {}\n",HtmlEntityMapper::instance().html(s.symbol(),TRUE));
198 }
199}
200
202{
203 if (m_hide) return;
204 const char *res = EmojiEntityMapper::instance().name(s.index());
205 if (res)
206 {
207 QCString name=res;
208 name = name.mid(1,name.length()-2);
209 m_t << "<emoji name=\"" << name << "\" unicode=\"";
211 m_t << "\"/>";
212 }
213 else
214 {
215 m_t << s.name();
216 }
217}
218
220{
221 if (m_hide) return;
222 m_t << "<ulink url=\"";
223 if (u.isEmail()) m_t << "mailto:";
224 filter(u.url());
225 m_t << "\">";
226 filter(u.url());
227 m_t << "</ulink>";
228}
229
231{
232 if (m_hide) return;
233 m_t << "<linebreak/>\n";
234}
235
237{
238 if (m_hide) return;
239 m_t << "<hruler/>\n";
240}
241
243{
244 if (m_hide) return;
245 switch (s.style())
246 {
248 if (s.enable()) m_t << "<bold>"; else m_t << "</bold>";
249 break;
251 if (s.enable()) m_t << "<s>"; else m_t << "</s>";
252 break;
254 if (s.enable()) m_t << "<strike>"; else m_t << "</strike>";
255 break;
257 if (s.enable()) m_t << "<del>"; else m_t << "</del>";
258 break;
260 if (s.enable()) m_t << "<underline>"; else m_t << "</underline>";
261 break;
263 if (s.enable()) m_t << "<ins>"; else m_t << "</ins>";
264 break;
266 if (s.enable()) m_t << "<emphasis>"; else m_t << "</emphasis>";
267 break;
271 if (s.enable()) m_t << "<computeroutput>"; else m_t << "</computeroutput>";
272 break;
274 if (s.enable()) m_t << "<subscript>"; else m_t << "</subscript>";
275 break;
277 if (s.enable()) m_t << "<superscript>"; else m_t << "</superscript>";
278 break;
280 if (s.enable()) m_t << "<center>"; else m_t << "</center>";
281 break;
283 if (s.enable()) m_t << "<small>"; else m_t << "</small>";
284 break;
286 if (s.enable()) m_t << "<cite>"; else m_t << "</cite>";
287 break;
289 if (s.enable())
290 {
291 m_t << "<preformatted>";
293 }
294 else
295 {
296 m_t << "</preformatted>";
298 }
299 break;
300 case DocStyleChange::Div: /* HTML only */ break;
301 case DocStyleChange::Span: /* HTML only */ break;
302 }
303}
304
306{
307 if (m_hide) return;
308 QCString lang = m_langExt;
309 if (!s.language().isEmpty()) // explicit language setting
310 {
311 lang = s.language();
312 }
313 SrcLangExt langExt = getLanguageFromCodeLang(lang);
314 switch(s.type())
315 {
317 m_t << "<programlisting";
318 if (!s.language().isEmpty())
319 m_t << " filename=\"" << lang << "\">";
320 else
321 m_t << ">";
322 getCodeParser(lang).parseCode(m_ci,s.context(),s.text(),langExt,
323 Config_getBool(STRIP_CODE_COMMENTS),
324 s.isExample(),s.exampleFile());
325 m_t << "</programlisting>";
326 break;
328 m_t << "<javadocliteral>";
329 filter(s.text());
330 m_t << "</javadocliteral>";
331 break;
333 m_t << "<javadoccode>";
334 filter(s.text());
335 m_t << "</javadoccode>";
336 break;
338 m_t << "<verbatim>";
339 filter(s.text());
340 m_t << "</verbatim>";
341 break;
343 if (s.isBlock())
344 {
345 m_t << "<htmlonly block=\"yes\">";
346 }
347 else
348 {
349 m_t << "<htmlonly>";
350 }
351 filter(s.text());
352 m_t << "</htmlonly>";
353 break;
355 m_t << "<rtfonly>";
356 filter(s.text());
357 m_t << "</rtfonly>";
358 break;
360 m_t << "<manonly>";
361 filter(s.text());
362 m_t << "</manonly>";
363 break;
365 m_t << "<latexonly>";
366 filter(s.text());
367 m_t << "</latexonly>";
368 break;
370 m_t << "<docbookonly>";
371 filter(s.text());
372 m_t << "</docbookonly>";
373 break;
375 m_t << s.text();
376 break;
377 case DocVerbatim::Dot:
378 visitPreStart(m_t, "dot", s.hasCaption(), *this, s.children(), QCString(""), FALSE, DocImage::Html, s.width(), s.height());
379 filter(s.text());
380 visitPostEnd(m_t, "dot");
381 break;
382 case DocVerbatim::Msc:
383 visitPreStart(m_t, "msc", s.hasCaption(), *this, s.children(), QCString(""), FALSE, DocImage::Html, s.width(), s.height());
384 filter(s.text());
385 visitPostEnd(m_t, "msc");
386 break;
388 visitPreStart(m_t, "plantuml", s.hasCaption(), *this, s.children(), QCString(""), FALSE, DocImage::Html, s.width(), s.height(), s.engine());
389 filter(s.text());
390 visitPostEnd(m_t, "plantuml");
391 break;
392 }
393}
394
396{
397 if (m_hide) return;
398 m_t << "<anchor id=\"" << anc.file() << "_1" << anc.anchor() << "\"/>";
399}
400
402{
403 if (m_hide) return;
405 //printf("XMLDocVisitor: DocInclude type=%d trimleft=%d\n",inc.type(),inc.trimLeft());
406 switch(inc.type())
407 {
409 {
410 m_t << "<programlisting filename=\"" << inc.file() << "\">";
411 FileInfo cfi( inc.file().str() );
412 auto fd = createFileDef( cfi.dirPath(), cfi.fileName());
414 inc.text(),
415 langExt,
416 inc.stripCodeComments(),
417 inc.isExample(),
418 inc.exampleFile(),
419 fd.get(), // fileDef,
420 -1, // start line
421 -1, // end line
422 FALSE, // inline fragment
423 nullptr, // memberDef
424 TRUE // show line numbers
425 );
426 m_t << "</programlisting>";
427 }
428 break;
430 m_t << "<programlisting filename=\"" << inc.file() << "\">";
432 inc.text(),
433 langExt,
434 inc.stripCodeComments(),
435 inc.isExample(),
436 inc.exampleFile(),
437 nullptr, // fileDef
438 -1, // startLine
439 -1, // endLine
440 TRUE, // inlineFragment
441 nullptr, // memberDef
442 FALSE // show line numbers
443 );
444 m_t << "</programlisting>";
445 break;
448 break;
450 if (inc.isBlock())
451 {
452 m_t << "<htmlonly block=\"yes\">";
453 }
454 else
455 {
456 m_t << "<htmlonly>";
457 }
458 filter(inc.text());
459 m_t << "</htmlonly>";
460 break;
462 m_t << "<latexonly>";
463 filter(inc.text());
464 m_t << "</latexonly>";
465 break;
467 m_t << "<rtfonly>";
468 filter(inc.text());
469 m_t << "</rtfonly>";
470 break;
472 m_t << "<manonly>";
473 filter(inc.text());
474 m_t << "</manonly>";
475 break;
477 filter(inc.text());
478 break;
480 m_t << "<docbookonly>";
481 filter(inc.text());
482 m_t << "</docbookonly>";
483 break;
485 m_t << "<verbatim>";
486 filter(inc.text());
487 m_t << "</verbatim>";
488 break;
491 m_t << "<programlisting filename=\"" << inc.file() << "\">";
493 inc.file(),
494 inc.blockId(),
495 inc.context(),
497 inc.trimLeft(),
499 );
500 m_t << "</programlisting>";
501 break;
502 }
503}
504
506{
507 //printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
508 // op.type(),op.isFirst(),op.isLast(),qPrint(op.text()));
509 if (op.isFirst())
510 {
511 if (!m_hide)
512 {
513 m_t << "<programlisting filename=\"" << op.includeFileName() << "\">";
514 }
516 m_hide = TRUE;
517 }
519 if (locLangExt.isEmpty()) locLangExt = m_langExt;
520 SrcLangExt langExt = getLanguageFromFileName(locLangExt);
521 if (op.type()!=DocIncOperator::Skip)
522 {
523 m_hide = popHidden();
524 if (!m_hide)
525 {
526 std::unique_ptr<FileDef> fd;
527 if (!op.includeFileName().isEmpty())
528 {
529 FileInfo cfi( op.includeFileName().str() );
530 fd = createFileDef( cfi.dirPath(), cfi.fileName() );
531 }
532
533 getCodeParser(locLangExt).parseCode(m_ci,op.context(),
534 op.text(),langExt,
536 op.isExample(),
537 op.exampleFile(),
538 fd.get(), // fileDef
539 op.line(), // startLine
540 -1, // endLine
541 FALSE, // inline fragment
542 nullptr, // memberDef
543 op.showLineNo() // show line numbers
544 );
545 }
547 m_hide=TRUE;
548 }
549 if (op.isLast())
550 {
551 m_hide = popHidden();
552 if (!m_hide) m_t << "</programlisting>";
553 }
554 else
555 {
556 if (!m_hide) m_t << "\n";
557 }
558}
559
561{
562 if (m_hide) return;
563 m_t << "<formula id=\"" << f.id() << "\">";
564 filter(f.text());
565 m_t << "</formula>";
566}
567
569{
570 if (m_hide) return;
571 m_t << "<indexentry>"
572 "<primaryie>";
573 filter(ie.entry());
574 m_t << "</primaryie>"
575 "<secondaryie></secondaryie>"
576 "</indexentry>";
577}
578
580{
581 const DocSimpleSect *sect = std::get_if<DocSimpleSect>(sep.parent());
582 if (sect)
583 {
584 endSimpleSect(m_t,*sect);
585 startSimpleSect(m_t,*sect);
586 }
587}
588
590{
591 if (m_hide) return;
592 if (!cite.file().isEmpty()) startLink(cite.ref(),cite.file(),cite.anchor());
593 filter(cite.text());
594 if (!cite.file().isEmpty()) endLink();
595}
596
597//--------------------------------------
598// visitor functions for compound nodes
599//--------------------------------------
600
602{
603 if (m_hide) return;
604 if (l.isEnumList())
605 {
606 m_t << "<orderedlist>\n";
607 }
608 else
609 {
610 m_t << "<itemizedlist>\n";
611 }
612 visitChildren(l);
613 if (l.isEnumList())
614 {
615 m_t << "</orderedlist>\n";
616 }
617 else
618 {
619 m_t << "</itemizedlist>\n";
620 }
621}
622
624{
625 if (m_hide) return;
626 switch (li.itemNumber())
627 {
628 case DocAutoList::Unchecked: // unchecked
629 m_t << "<listitem override=\"unchecked\">";
630 break;
631 case DocAutoList::Checked_x: // checked with x
632 case DocAutoList::Checked_X: // checked with X
633 m_t << "<listitem override=\"checked\">";
634 break;
635 default:
636 m_t << "<listitem>";
637 break;
638 }
639 visitChildren(li);
640 m_t << "</listitem>";
641}
642
644{
645 if (m_hide) return;
646 m_t << "<para>";
647 visitChildren(p);
648 m_t << "</para>\n";
649}
650
652{
653 visitChildren(r);
654}
655
657{
658 if (m_hide) return;
660 if (s.title())
661 {
662 std::visit(*this,*s.title());
663 }
664 visitChildren(s);
666}
667
669{
670 if (m_hide) return;
671 m_t << "<title>";
672 visitChildren(t);
673 m_t << "</title>";
674}
675
677{
678 if (m_hide) return;
679 m_t << "<itemizedlist>\n";
680 visitChildren(l);
681 m_t << "</itemizedlist>\n";
682}
683
685{
686 if (m_hide) return;
687 m_t << "<listitem>";
688 if (li.paragraph())
689 {
690 std::visit(*this,*li.paragraph());
691 }
692 m_t << "</listitem>\n";
693}
694
696{
697 if (m_hide) return;
698 int orgSectionLevel = m_sectionLevel;
699 QCString sectId = s.file();
700 if (!s.anchor().isEmpty()) sectId += "_1"+s.anchor();
701 while (m_sectionLevel+1<s.level()) // fix missing intermediate levels
702 {
704 m_t << "<sect" << m_sectionLevel << " id=\"" << sectId << "_1s" << m_sectionLevel << "\">";
705 }
707 m_t << "<sect" << s.level() << " id=\"" << sectId << "\">\n";
708 if (s.title())
709 {
710 std::visit(*this,*s.title());
711 }
712 visitChildren(s);
713 m_t << "</sect" << s.level() << ">";
715 while (orgSectionLevel<m_sectionLevel) // fix missing intermediate levels
716 {
717 m_t << "</sect" << m_sectionLevel << ">";
719 }
720 m_t << "\n";
721}
722
724{
725 if (m_hide) return;
726 if (s.type()==DocHtmlList::Ordered)
727 {
728 m_t << "<orderedlist";
729 for (const auto &opt : s.attribs())
730 {
731 m_t << " " << opt.name << "=\"" << opt.value << "\"";
732 }
733 m_t << ">\n";
734 }
735 else
736 {
737 m_t << "<itemizedlist>\n";
738 }
739 visitChildren(s);
740 if (s.type()==DocHtmlList::Ordered)
741 {
742 m_t << "</orderedlist>\n";
743 }
744 else
745 {
746 m_t << "</itemizedlist>\n";
747 }
748}
749
751{
752 if (m_hide) return;
753 m_t << "<listitem";
754 for (const auto &opt : l.attribs())
755 {
756 if (opt.name=="value")
757 {
758 m_t << " " << opt.name << "=\"" << opt.value << "\"";
759 }
760 }
761 m_t << ">\n";
762 visitChildren(l);
763 m_t << "</listitem>\n";
764}
765
767{
768 if (m_hide) return;
769 m_t << "<variablelist>\n";
770 visitChildren(dl);
771 m_t << "</variablelist>\n";
772}
773
775{
776 if (m_hide) return;
777 m_t << "<varlistentry><term>";
778 visitChildren(dt);
779 m_t << "</term></varlistentry>\n";
780}
781
783{
784 if (m_hide) return;
785 m_t << "<listitem>";
786 visitChildren(dd);
787 m_t << "</listitem>\n";
788}
789
791{
792 if (m_hide) return;
793 m_t << "<table rows=\"" << t.numRows()
794 << "\" cols=\"" << t.numColumns() << "\"" ;
795 for (const auto &opt : t.attribs())
796 {
797 if (opt.name=="width")
798 {
799 m_t << " " << opt.name << "=\"" << opt.value << "\"";
800 }
801 }
802 m_t << ">";
803 if (t.caption())
804 {
805 std::visit(*this,*t.caption());
806 }
807 visitChildren(t);
808 m_t << "</table>\n";
809}
810
812{
813 if (m_hide) return;
814 m_t << "<row>\n";
815 visitChildren(r);
816 m_t << "</row>\n";
817}
818
820{
821 if (m_hide) return;
822 if (c.isHeading()) m_t << "<entry thead=\"yes\""; else m_t << "<entry thead=\"no\"";
823 for (const auto &opt : c.attribs())
824 {
825 if (opt.name=="colspan" || opt.name=="rowspan")
826 {
827 m_t << " " << opt.name << "=\"" << opt.value.toInt() << "\"";
828 }
829 else if (opt.name=="align" &&
830 (opt.value=="right" || opt.value=="left" || opt.value=="center"))
831 {
832 m_t << " align=\"" << opt.value << "\"";
833 }
834 else if (opt.name=="valign" &&
835 (opt.value == "bottom" || opt.value == "top" || opt.value == "middle"))
836 {
837 m_t << " valign=\"" << opt.value << "\"";
838 }
839 else if (opt.name=="width")
840 {
841 m_t << " width=\"" << opt.value << "\"";
842 }
843 else if (opt.name=="class") // handle markdown generated attributes
844 {
845 if (opt.value.startsWith("markdownTable")) // handle markdown generated attributes
846 {
847 if (opt.value.endsWith("Right"))
848 {
849 m_t << " align='right'";
850 }
851 else if (opt.value.endsWith("Left"))
852 {
853 m_t << " align='left'";
854 }
855 else if (opt.value.endsWith("Center"))
856 {
857 m_t << " align='center'";
858 }
859 // skip 'markdownTable*' value ending with "None"
860 }
861 else if (!opt.value.isEmpty())
862 {
863 m_t << " class=\"" << convertToXML(opt.value) << "\"";
864 }
865 }
866 }
867 m_t << ">";
868 visitChildren(c);
869 m_t << "</entry>";
870}
871
873{
874 if (m_hide) return;
875 m_t << "<caption";
876 if (!c.file().isEmpty())
877 {
878 m_t << " id=\"" << stripPath(c.file()) << "_1" << c.anchor() << "\"";
879 }
880 m_t << ">";
881 visitChildren(c);
882 m_t << "</caption>\n";
883}
884
886{
887 if (m_hide) return;
888 m_t << "<internal>";
889 visitChildren(i);
890 m_t << "</internal>\n";
891}
892
894{
895 if (m_hide) return;
896 m_t << "<ulink url=\"" << convertToXML(href.url(), TRUE) << "\">";
897 visitChildren(href);
898 m_t << "</ulink>";
899}
900
902{
903 if (m_hide) return;
904 m_t << "<summary>";
905 visitChildren(s);
906 m_t << "</summary>";
907}
908
910{
911 if (m_hide) return;
912 m_t << "<details>";
913 auto summary = d.summary();
914 if (summary)
915 {
916 std::visit(*this,*summary);
917 }
918 visitChildren(d);
919 m_t << "</details>";
920}
921
923{
924 if (m_hide) return;
925 m_t << "<heading level=\"" << header.level() << "\">";
926 visitChildren(header);
927 m_t << "</heading>\n";
928}
929
931{
932 if (m_hide) return;
933
934 QCString url = img.url();
935 QCString baseName;
936 if (url.isEmpty())
937 {
938 baseName = img.relPath()+img.name();
939 }
940 else
941 {
942 baseName = correctURL(url,img.relPath());
943 }
944 HtmlAttribList attribs = img.attribs();
945 auto it = std::find_if(attribs.begin(),attribs.end(),
946 [](const auto &att) { return att.name=="alt"; });
947 QCString altValue = it!=attribs.end() ? it->value : "";
948 visitPreStart(m_t, "image", FALSE, *this, img.children(), baseName, TRUE,
949 img.type(), img.width(), img.height(), QCString(),
950 altValue, img.isInlineImage());
951
952 // copy the image to the output dir
953 FileDef *fd = nullptr;
954 bool ambig;
955 if (url.isEmpty() && (fd=findFileDef(Doxygen::imageNameLinkedMap,img.name(),ambig)))
956 {
957 copyFile(fd->absFilePath(),Config_getString(XML_OUTPUT)+"/"+baseName);
958 }
959 visitChildren(img);
960 visitPostEnd(m_t, "image");
961}
962
964{
965 if (m_hide) return;
966 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
967 visitPreStart(m_t, "dotfile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
968 visitChildren(df);
969 visitPostEnd(m_t, "dotfile");
970}
971
973{
974 if (m_hide) return;
975 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
976 visitPreStart(m_t, "mscfile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
977 visitChildren(df);
978 visitPostEnd(m_t, "mscfile");
979}
980
982{
983 if (m_hide) return;
984 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
985 visitPreStart(m_t, "diafile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
986 visitChildren(df);
987 visitPostEnd(m_t, "diafile");
988}
989
991{
992 if (m_hide) return;
993 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
994 visitPreStart(m_t, "plantumlfile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
995 visitChildren(df);
996 visitPostEnd(m_t, "plantumlfile");
997}
998
1000{
1001 if (m_hide) return;
1002 startLink(lnk.ref(),lnk.file(),lnk.anchor());
1003 visitChildren(lnk);
1004 endLink();
1005}
1006
1008{
1009 if (m_hide) return;
1010 if (!ref.file().isEmpty())
1011 {
1012 startLink(ref.ref(),ref.file(),ref.isSubPage() ? QCString() : ref.anchor());
1013 }
1014 if (!ref.hasLinkText()) filter(ref.targetTitle());
1015 visitChildren(ref);
1016 if (!ref.file().isEmpty()) endLink();
1017}
1018
1020{
1021 if (m_hide) return;
1022 m_t << "<tocitem id=\"" << ref.file();
1023 if (!ref.anchor().isEmpty()) m_t << "_1" << ref.anchor();
1024 m_t << "\"";
1025 m_t << ">";
1026 visitChildren(ref);
1027 m_t << "</tocitem>\n";
1028}
1029
1031{
1032 if (m_hide) return;
1033 m_t << "<toclist>\n";
1034 visitChildren(l);
1035 m_t << "</toclist>\n";
1036}
1037
1039{
1040 if (m_hide) return;
1041 m_t << "<parameterlist kind=\"";
1042 switch(s.type())
1043 {
1045 m_t << "param"; break;
1047 m_t << "retval"; break;
1049 m_t << "exception"; break;
1051 m_t << "templateparam"; break;
1052 default:
1053 ASSERT(0);
1054 }
1055 m_t << "\">";
1056 visitChildren(s);
1057 m_t << "</parameterlist>\n";
1058}
1059
1061{
1062 m_t << "</parametertype>\n";
1063 m_t << "<parametertype>";
1064}
1065
1067{
1068 if (m_hide) return;
1069 m_t << "<parameteritem>\n";
1070 m_t << "<parameternamelist>\n";
1071 for (const auto &param : pl.parameters())
1072 {
1073 if (!pl.paramTypes().empty())
1074 {
1075 m_t << "<parametertype>";
1076 for (const auto &type : pl.paramTypes())
1077 {
1078 std::visit(*this,type);
1079 }
1080 m_t << "</parametertype>\n";
1081 }
1082 m_t << "<parametername";
1084 {
1085 m_t << " direction=\"";
1086 if (pl.direction()==DocParamSect::In)
1087 {
1088 m_t << "in";
1089 }
1090 else if (pl.direction()==DocParamSect::Out)
1091 {
1092 m_t << "out";
1093 }
1094 else if (pl.direction()==DocParamSect::InOut)
1095 {
1096 m_t << "inout";
1097 }
1098 m_t << "\"";
1099 }
1100 m_t << ">";
1101 std::visit(*this,param);
1102 m_t << "</parametername>\n";
1103 }
1104 m_t << "</parameternamelist>\n";
1105 m_t << "<parameterdescription>\n";
1106 for (const auto &par : pl.paragraphs())
1107 {
1108 std::visit(*this,par);
1109 }
1110 m_t << "</parameterdescription>\n";
1111 m_t << "</parameteritem>\n";
1112}
1113
1115{
1116 if (m_hide) return;
1117 if (x.title().isEmpty()) return;
1118 m_t << "<xrefsect id=\"";
1119 m_t << x.file() << "_1" << x.anchor();
1120 m_t << "\">";
1121 m_t << "<xreftitle>";
1122 filter(x.title());
1123 m_t << "</xreftitle>";
1124 m_t << "<xrefdescription>";
1125 visitChildren(x);
1126 if (x.title().isEmpty()) return;
1127 m_t << "</xrefdescription>";
1128 m_t << "</xrefsect>";
1129}
1130
1132{
1133 if (m_hide) return;
1134 startLink(QCString(),ref.file(),ref.anchor());
1135 visitChildren(ref);
1136 endLink();
1137 m_t << " ";
1138}
1139
1141{
1142 visitChildren(t);
1143}
1144
1146{
1147 if (m_hide) return;
1148 m_t << "<blockquote>";
1149 visitChildren(q);
1150 m_t << "</blockquote>";
1151}
1152
1154{
1155}
1156
1158{
1159 if (m_hide) return;
1160 m_t << "<parblock>";
1161 visitChildren(pb);
1162 m_t << "</parblock>";
1163}
1164
1165
1167{
1168 m_t << convertToXML(str);
1169}
1170
1171void XmlDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1172{
1173 //printf("XmlDocVisitor: file=%s anchor=%s\n",qPrint(file),qPrint(anchor));
1174 m_t << "<ref refid=\"" << file;
1175 if (!anchor.isEmpty()) m_t << "_1" << anchor;
1176 m_t << "\" kindref=\"";
1177 if (!anchor.isEmpty()) m_t << "member"; else m_t << "compound";
1178 m_t << "\"";
1179 if (!ref.isEmpty()) m_t << " external=\"" << ref << "\"";
1180 m_t << ">";
1181}
1182
1184{
1185 m_t << "</ref>";
1186}
1187
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, bool isExampleBlock, const QCString &exampleName=QCString(), const FileDef *fileDef=nullptr, int startLine=-1, int endLine=-1, bool inlineFragment=FALSE, const MemberDef *memberDef=nullptr, bool showLineNumbers=TRUE, const Definition *searchCtx=nullptr, bool collectXRefs=TRUE)=0
Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
Node representing an anchor.
Definition docnode.h:228
QCString anchor() const
Definition docnode.h:231
QCString file() const
Definition docnode.h:232
Node representing an auto List.
Definition docnode.h:567
bool isEnumList() const
Definition docnode.h:576
Node representing an item of a auto list.
Definition docnode.h:591
int itemNumber() const
Definition docnode.h:594
Node representing a citation of some bibliographic reference.
Definition docnode.h:244
QCString text() const
Definition docnode.h:251
QCString anchor() const
Definition docnode.h:250
QCString ref() const
Definition docnode.h:249
QCString file() const
Definition docnode.h:247
DocNodeList & children()
Definition docnode.h:142
Node representing a dia file.
Definition docnode.h:726
QCString height() const
Definition docnode.h:684
QCString file() const
Definition docnode.h:680
QCString width() const
Definition docnode.h:683
Node representing a dot file.
Definition docnode.h:708
Node representing an emoji.
Definition docnode.h:337
int index() const
Definition docnode.h:341
QCString name() const
Definition docnode.h:340
Node representing an item of a cross-referenced list.
Definition docnode.h:525
QCString text() const
Definition docnode.h:529
int id() const
Definition docnode.h:531
Node representing a Hypertext reference.
Definition docnode.h:818
QCString url() const
Definition docnode.h:825
Node representing a horizontal ruler.
Definition docnode.h:215
Node representing an HTML blockquote.
Definition docnode.h:1286
Node representing a HTML table caption.
Definition docnode.h:1223
QCString anchor() const
Definition docnode.h:1230
QCString file() const
Definition docnode.h:1229
Node representing a HTML table cell.
Definition docnode.h:1188
bool isHeading() const
Definition docnode.h:1195
const HtmlAttribList & attribs() const
Definition docnode.h:1200
Node representing a HTML description data.
Definition docnode.h:1176
Node representing a Html description list.
Definition docnode.h:896
Node representing a Html description item.
Definition docnode.h:883
Node Html details.
Definition docnode.h:852
const DocNodeVariant * summary() const
Definition docnode.h:859
Node Html heading.
Definition docnode.h:868
int level() const
Definition docnode.h:872
Node representing a Html list.
Definition docnode.h:995
const HtmlAttribList & attribs() const
Definition docnode.h:1001
Type type() const
Definition docnode.h:1000
Node representing a HTML list item.
Definition docnode.h:1160
const HtmlAttribList & attribs() const
Definition docnode.h:1165
Node representing a HTML table row.
Definition docnode.h:1241
Node Html summary.
Definition docnode.h:839
Node representing a HTML table.
Definition docnode.h:1264
size_t numRows() const
Definition docnode.h:1268
size_t numColumns() const
Definition docnode.h:1273
const DocNodeVariant * caption() const
Definition docnode.cpp:2044
const HtmlAttribList & attribs() const
Definition docnode.h:1270
Node representing an image.
Definition docnode.h:637
const HtmlAttribList & attribs() const
Definition docnode.h:651
QCString relPath() const
Definition docnode.h:647
QCString name() const
Definition docnode.h:643
QCString url() const
Definition docnode.h:648
QCString height() const
Definition docnode.h:646
Type type() const
Definition docnode.h:642
QCString width() const
Definition docnode.h:645
@ DocBook
Definition docnode.h:639
bool isInlineImage() const
Definition docnode.h:649
Node representing a include/dontinclude operator block.
Definition docnode.h:473
bool stripCodeComments() const
Definition docnode.h:502
bool isLast() const
Definition docnode.h:499
QCString includeFileName() const
Definition docnode.h:505
QCString text() const
Definition docnode.h:495
QCString context() const
Definition docnode.h:497
QCString exampleFile() const
Definition docnode.h:504
int line() const
Definition docnode.h:493
Type type() const
Definition docnode.h:481
bool isFirst() const
Definition docnode.h:498
bool showLineNo() const
Definition docnode.h:494
bool isExample() const
Definition docnode.h:503
Node representing an included text block from file.
Definition docnode.h:431
QCString blockId() const
Definition docnode.h:450
QCString extension() const
Definition docnode.h:446
bool isBlock() const
Definition docnode.h:454
bool stripCodeComments() const
Definition docnode.h:451
@ LatexInclude
Definition docnode.h:433
@ SnippetWithLines
Definition docnode.h:434
@ DontIncWithLines
Definition docnode.h:435
@ IncWithLines
Definition docnode.h:434
@ HtmlInclude
Definition docnode.h:433
@ VerbInclude
Definition docnode.h:433
@ DontInclude
Definition docnode.h:433
@ DocbookInclude
Definition docnode.h:435
Type type() const
Definition docnode.h:447
QCString exampleFile() const
Definition docnode.h:453
QCString text() const
Definition docnode.h:448
QCString file() const
Definition docnode.h:445
bool trimLeft() const
Definition docnode.h:455
bool isExample() const
Definition docnode.h:452
QCString context() const
Definition docnode.h:449
Node representing an entry in the index.
Definition docnode.h:548
QCString entry() const
Definition docnode.h:555
Node representing an internal section of documentation.
Definition docnode.h:964
Node representing an internal reference to some item.
Definition docnode.h:802
QCString file() const
Definition docnode.h:806
QCString anchor() const
Definition docnode.h:808
Node representing a line break.
Definition docnode.h:201
Node representing a word that can be linked to something.
Definition docnode.h:164
QCString file() const
Definition docnode.h:170
QCString ref() const
Definition docnode.h:172
QCString word() const
Definition docnode.h:169
QCString anchor() const
Definition docnode.h:173
Node representing a msc file.
Definition docnode.h:717
DocNodeVariant * parent()
Definition docnode.h:89
Node representing an block of paragraphs.
Definition docnode.h:974
Node representing a paragraph in the documentation tree.
Definition docnode.h:1075
Node representing a parameter list.
Definition docnode.h:1120
const DocNodeList & parameters() const
Definition docnode.h:1124
const DocNodeList & paramTypes() const
Definition docnode.h:1125
DocParamSect::Direction direction() const
Definition docnode.h:1128
const DocNodeList & paragraphs() const
Definition docnode.h:1126
Node representing a parameter section.
Definition docnode.h:1048
Type type() const
Definition docnode.h:1063
Node representing a uml file.
Definition docnode.h:735
Node representing a reference to some item.
Definition docnode.h:773
QCString anchor() const
Definition docnode.h:780
QCString targetTitle() const
Definition docnode.h:781
bool isSubPage() const
Definition docnode.h:787
QCString file() const
Definition docnode.h:777
QCString ref() const
Definition docnode.h:779
bool hasLinkText() const
Definition docnode.h:783
Root node of documentation tree.
Definition docnode.h:1308
Node representing a reference to a section.
Definition docnode.h:930
QCString file() const
Definition docnode.h:934
QCString anchor() const
Definition docnode.h:935
Node representing a list of section references.
Definition docnode.h:954
Node representing a normal section.
Definition docnode.h:909
QCString file() const
Definition docnode.h:917
int level() const
Definition docnode.h:913
QCString anchor() const
Definition docnode.h:915
const DocNodeVariant * title() const
Definition docnode.h:914
Node representing a separator.
Definition docnode.h:361
Node representing a simple list.
Definition docnode.h:985
Node representing a simple list item.
Definition docnode.h:1148
const DocNodeVariant * paragraph() const
Definition docnode.h:1152
Node representing a simple section.
Definition docnode.h:1012
Type type() const
Definition docnode.h:1021
const DocNodeVariant * title() const
Definition docnode.h:1028
Node representing a separator between two simple sections of the same type.
Definition docnode.h:1039
Node representing a style change.
Definition docnode.h:264
Style style() const
Definition docnode.h:303
bool enable() const
Definition docnode.h:305
Node representing a special symbol.
Definition docnode.h:324
HtmlEntityMapper::SymType symbol() const
Definition docnode.h:328
Root node of a text fragment.
Definition docnode.h:1299
Node representing a simple section title.
Definition docnode.h:604
Node representing a URL (or email address)
Definition docnode.h:187
QCString url() const
Definition docnode.h:191
bool isEmail() const
Definition docnode.h:192
Node representing a verbatim, unparsed text fragment.
Definition docnode.h:372
QCString height() const
Definition docnode.h:388
bool hasCaption() const
Definition docnode.h:386
QCString language() const
Definition docnode.h:384
const DocNodeList & children() const
Definition docnode.h:391
bool isBlock() const
Definition docnode.h:385
bool isExample() const
Definition docnode.h:381
QCString context() const
Definition docnode.h:380
Type type() const
Definition docnode.h:378
QCString text() const
Definition docnode.h:379
QCString exampleFile() const
Definition docnode.h:382
QCString engine() const
Definition docnode.h:389
@ JavaDocLiteral
Definition docnode.h:374
QCString width() const
Definition docnode.h:387
Node representing a VHDL flow chart.
Definition docnode.h:744
CodeParserInterface & getCodeParser(const QCString &langExt)
void pushHidden(bool hide)
bool popHidden()
Node representing some amount of white space.
Definition docnode.h:350
QCString chars() const
Definition docnode.h:354
Node representing a word.
Definition docnode.h:152
QCString word() const
Definition docnode.h:155
Node representing an item of a cross-referenced list.
Definition docnode.h:616
QCString anchor() const
Definition docnode.h:620
QCString file() const
Definition docnode.h:619
QCString title() const
Definition docnode.h:621
static FileNameLinkedMap * imageNameLinkedMap
Definition doxygen.h:106
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:164
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:153
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
const std::string & str() const
Definition qcstring.h:537
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
SrcLangExt
Definition types.h:207
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5721
QCString correctURL(const QCString &url, const QCString &relPath)
Corrects URL url according to the relative path relPath.
Definition util.cpp:6404
QCString stripPath(const QCString &s)
Definition util.cpp:5464
SrcLangExt getLanguageFromCodeLang(QCString &fileName)
Routine to handle the language attribute of the \code command.
Definition util.cpp:5739
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:4428
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:6336
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5763
FileDef * findFileDef(const FileNameLinkedMap *fnMap, const QCString &n, bool &ambig)
Definition util.cpp:3415
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)