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: %s\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;
270 if (s.enable()) m_t << "<computeroutput>"; else m_t << "</computeroutput>";
271 break;
273 if (s.enable()) m_t << "<subscript>"; else m_t << "</subscript>";
274 break;
276 if (s.enable()) m_t << "<superscript>"; else m_t << "</superscript>";
277 break;
279 if (s.enable()) m_t << "<center>"; else m_t << "</center>";
280 break;
282 if (s.enable()) m_t << "<small>"; else m_t << "</small>";
283 break;
285 if (s.enable()) m_t << "<cite>"; else m_t << "</cite>";
286 break;
288 if (s.enable())
289 {
290 m_t << "<preformatted>";
292 }
293 else
294 {
295 m_t << "</preformatted>";
297 }
298 break;
299 case DocStyleChange::Div: /* HTML only */ break;
300 case DocStyleChange::Span: /* HTML only */ break;
301 }
302}
303
305{
306 if (m_hide) return;
307 QCString lang = m_langExt;
308 if (!s.language().isEmpty()) // explicit language setting
309 {
310 lang = s.language();
311 }
312 SrcLangExt langExt = getLanguageFromCodeLang(lang);
313 switch(s.type())
314 {
316 m_t << "<programlisting";
317 if (!s.language().isEmpty())
318 m_t << " filename=\"" << lang << "\">";
319 else
320 m_t << ">";
321 getCodeParser(lang).parseCode(m_ci,s.context(),s.text(),langExt,
322 Config_getBool(STRIP_CODE_COMMENTS),
323 s.isExample(),s.exampleFile());
324 m_t << "</programlisting>";
325 break;
327 m_t << "<javadocliteral>";
328 filter(s.text());
329 m_t << "</javadocliteral>";
330 break;
332 m_t << "<javadoccode>";
333 filter(s.text());
334 m_t << "</javadoccode>";
335 break;
337 m_t << "<verbatim>";
338 filter(s.text());
339 m_t << "</verbatim>";
340 break;
342 if (s.isBlock())
343 {
344 m_t << "<htmlonly block=\"yes\">";
345 }
346 else
347 {
348 m_t << "<htmlonly>";
349 }
350 filter(s.text());
351 m_t << "</htmlonly>";
352 break;
354 m_t << "<rtfonly>";
355 filter(s.text());
356 m_t << "</rtfonly>";
357 break;
359 m_t << "<manonly>";
360 filter(s.text());
361 m_t << "</manonly>";
362 break;
364 m_t << "<latexonly>";
365 filter(s.text());
366 m_t << "</latexonly>";
367 break;
369 m_t << "<docbookonly>";
370 filter(s.text());
371 m_t << "</docbookonly>";
372 break;
374 m_t << s.text();
375 break;
376 case DocVerbatim::Dot:
377 visitPreStart(m_t, "dot", s.hasCaption(), *this, s.children(), QCString(""), FALSE, DocImage::Html, s.width(), s.height());
378 filter(s.text());
379 visitPostEnd(m_t, "dot");
380 break;
381 case DocVerbatim::Msc:
382 visitPreStart(m_t, "msc", s.hasCaption(), *this, s.children(), QCString(""), FALSE, DocImage::Html, s.width(), s.height());
383 filter(s.text());
384 visitPostEnd(m_t, "msc");
385 break;
387 visitPreStart(m_t, "plantuml", s.hasCaption(), *this, s.children(), QCString(""), FALSE, DocImage::Html, s.width(), s.height(), s.engine());
388 filter(s.text());
389 visitPostEnd(m_t, "plantuml");
390 break;
391 }
392}
393
395{
396 if (m_hide) return;
397 m_t << "<anchor id=\"" << anc.file() << "_1" << anc.anchor() << "\"/>";
398}
399
401{
402 if (m_hide) return;
404 //printf("XMLDocVisitor: DocInclude type=%d trimleft=%d\n",inc.type(),inc.trimLeft());
405 switch(inc.type())
406 {
408 {
409 m_t << "<programlisting filename=\"" << inc.file() << "\">";
410 FileInfo cfi( inc.file().str() );
411 auto fd = createFileDef( cfi.dirPath(), cfi.fileName());
413 inc.text(),
414 langExt,
415 inc.stripCodeComments(),
416 inc.isExample(),
417 inc.exampleFile(),
418 fd.get(), // fileDef,
419 -1, // start line
420 -1, // end line
421 FALSE, // inline fragment
422 nullptr, // memberDef
423 TRUE // show line numbers
424 );
425 m_t << "</programlisting>";
426 }
427 break;
429 m_t << "<programlisting filename=\"" << inc.file() << "\">";
431 inc.text(),
432 langExt,
433 inc.stripCodeComments(),
434 inc.isExample(),
435 inc.exampleFile(),
436 nullptr, // fileDef
437 -1, // startLine
438 -1, // endLine
439 TRUE, // inlineFragment
440 nullptr, // memberDef
441 FALSE // show line numbers
442 );
443 m_t << "</programlisting>";
444 break;
447 break;
449 if (inc.isBlock())
450 {
451 m_t << "<htmlonly block=\"yes\">";
452 }
453 else
454 {
455 m_t << "<htmlonly>";
456 }
457 filter(inc.text());
458 m_t << "</htmlonly>";
459 break;
461 m_t << "<latexonly>";
462 filter(inc.text());
463 m_t << "</latexonly>";
464 break;
466 m_t << "<rtfonly>";
467 filter(inc.text());
468 m_t << "</rtfonly>";
469 break;
471 m_t << "<manonly>";
472 filter(inc.text());
473 m_t << "</manonly>";
474 break;
476 filter(inc.text());
477 break;
479 m_t << "<docbookonly>";
480 filter(inc.text());
481 m_t << "</docbookonly>";
482 break;
484 m_t << "<verbatim>";
485 filter(inc.text());
486 m_t << "</verbatim>";
487 break;
490 m_t << "<programlisting filename=\"" << inc.file() << "\">";
492 inc.file(),
493 inc.blockId(),
494 inc.context(),
496 inc.trimLeft(),
498 );
499 m_t << "</programlisting>";
500 break;
501 }
502}
503
505{
506 //printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
507 // op.type(),op.isFirst(),op.isLast(),qPrint(op.text()));
508 if (op.isFirst())
509 {
510 if (!m_hide)
511 {
512 m_t << "<programlisting filename=\"" << op.includeFileName() << "\">";
513 }
515 m_hide = TRUE;
516 }
517 QCString locLangExt = getFileNameExtension(op.includeFileName());
518 if (locLangExt.isEmpty()) locLangExt = m_langExt;
519 SrcLangExt langExt = getLanguageFromFileName(locLangExt);
520 if (op.type()!=DocIncOperator::Skip)
521 {
522 m_hide = popHidden();
523 if (!m_hide)
524 {
525 std::unique_ptr<FileDef> fd;
526 if (!op.includeFileName().isEmpty())
527 {
528 FileInfo cfi( op.includeFileName().str() );
529 fd = createFileDef( cfi.dirPath(), cfi.fileName() );
530 }
531
532 getCodeParser(locLangExt).parseCode(m_ci,op.context(),
533 op.text(),langExt,
535 op.isExample(),
536 op.exampleFile(),
537 fd.get(), // fileDef
538 op.line(), // startLine
539 -1, // endLine
540 FALSE, // inline fragment
541 nullptr, // memberDef
542 op.showLineNo() // show line numbers
543 );
544 }
546 m_hide=TRUE;
547 }
548 if (op.isLast())
549 {
550 m_hide = popHidden();
551 if (!m_hide) m_t << "</programlisting>";
552 }
553 else
554 {
555 if (!m_hide) m_t << "\n";
556 }
557}
558
560{
561 if (m_hide) return;
562 m_t << "<formula id=\"" << f.id() << "\">";
563 filter(f.text());
564 m_t << "</formula>";
565}
566
568{
569 if (m_hide) return;
570 m_t << "<indexentry>"
571 "<primaryie>";
572 filter(ie.entry());
573 m_t << "</primaryie>"
574 "<secondaryie></secondaryie>"
575 "</indexentry>";
576}
577
579{
580 const DocSimpleSect *sect = std::get_if<DocSimpleSect>(sep.parent());
581 if (sect)
582 {
583 endSimpleSect(m_t,*sect);
584 startSimpleSect(m_t,*sect);
585 }
586}
587
589{
590 if (m_hide) return;
591 if (!cite.file().isEmpty()) startLink(cite.ref(),cite.file(),cite.anchor());
592 filter(cite.text());
593 if (!cite.file().isEmpty()) endLink();
594}
595
596//--------------------------------------
597// visitor functions for compound nodes
598//--------------------------------------
599
601{
602 if (m_hide) return;
603 if (l.isEnumList())
604 {
605 m_t << "<orderedlist>\n";
606 }
607 else
608 {
609 m_t << "<itemizedlist>\n";
610 }
611 visitChildren(l);
612 if (l.isEnumList())
613 {
614 m_t << "</orderedlist>\n";
615 }
616 else
617 {
618 m_t << "</itemizedlist>\n";
619 }
620}
621
623{
624 if (m_hide) return;
625 switch (li.itemNumber())
626 {
627 case DocAutoList::Unchecked: // unchecked
628 m_t << "<listitem override=\"unchecked\">";
629 break;
630 case DocAutoList::Checked_x: // checked with x
631 case DocAutoList::Checked_X: // checked with X
632 m_t << "<listitem override=\"checked\">";
633 break;
634 default:
635 m_t << "<listitem>";
636 break;
637 }
638 visitChildren(li);
639 m_t << "</listitem>";
640}
641
643{
644 if (m_hide) return;
645 m_t << "<para>";
646 visitChildren(p);
647 m_t << "</para>\n";
648}
649
651{
652 visitChildren(r);
653}
654
656{
657 if (m_hide) return;
659 if (s.title())
660 {
661 std::visit(*this,*s.title());
662 }
663 visitChildren(s);
665}
666
668{
669 if (m_hide) return;
670 m_t << "<title>";
671 visitChildren(t);
672 m_t << "</title>";
673}
674
676{
677 if (m_hide) return;
678 m_t << "<itemizedlist>\n";
679 visitChildren(l);
680 m_t << "</itemizedlist>\n";
681}
682
684{
685 if (m_hide) return;
686 m_t << "<listitem>";
687 if (li.paragraph())
688 {
689 std::visit(*this,*li.paragraph());
690 }
691 m_t << "</listitem>\n";
692}
693
695{
696 if (m_hide) return;
697 int orgSectionLevel = m_sectionLevel;
698 QCString sectId = s.file();
699 if (!s.anchor().isEmpty()) sectId += "_1"+s.anchor();
700 while (m_sectionLevel+1<s.level()) // fix missing intermediate levels
701 {
703 m_t << "<sect" << m_sectionLevel << " id=\"" << sectId << "_1s" << m_sectionLevel << "\">";
704 }
706 m_t << "<sect" << s.level() << " id=\"" << sectId << "\">\n";
707 if (s.title())
708 {
709 std::visit(*this,*s.title());
710 }
711 visitChildren(s);
712 m_t << "</sect" << s.level() << ">";
714 while (orgSectionLevel<m_sectionLevel) // fix missing intermediate levels
715 {
716 m_t << "</sect" << m_sectionLevel << ">";
718 }
719 m_t << "\n";
720}
721
723{
724 if (m_hide) return;
725 if (s.type()==DocHtmlList::Ordered)
726 {
727 m_t << "<orderedlist";
728 for (const auto &opt : s.attribs())
729 {
730 m_t << " " << opt.name << "=\"" << opt.value << "\"";
731 }
732 m_t << ">\n";
733 }
734 else
735 {
736 m_t << "<itemizedlist>\n";
737 }
738 visitChildren(s);
739 if (s.type()==DocHtmlList::Ordered)
740 {
741 m_t << "</orderedlist>\n";
742 }
743 else
744 {
745 m_t << "</itemizedlist>\n";
746 }
747}
748
750{
751 if (m_hide) return;
752 m_t << "<listitem";
753 for (const auto &opt : l.attribs())
754 {
755 if (opt.name=="value")
756 {
757 m_t << " " << opt.name << "=\"" << opt.value << "\"";
758 }
759 }
760 m_t << ">\n";
761 visitChildren(l);
762 m_t << "</listitem>\n";
763}
764
766{
767 if (m_hide) return;
768 m_t << "<variablelist>\n";
769 visitChildren(dl);
770 m_t << "</variablelist>\n";
771}
772
774{
775 if (m_hide) return;
776 m_t << "<varlistentry><term>";
777 visitChildren(dt);
778 m_t << "</term></varlistentry>\n";
779}
780
782{
783 if (m_hide) return;
784 m_t << "<listitem>";
785 visitChildren(dd);
786 m_t << "</listitem>\n";
787}
788
790{
791 if (m_hide) return;
792 m_t << "<table rows=\"" << t.numRows()
793 << "\" cols=\"" << t.numColumns() << "\"" ;
794 for (const auto &opt : t.attribs())
795 {
796 if (opt.name=="width")
797 {
798 m_t << " " << opt.name << "=\"" << opt.value << "\"";
799 }
800 }
801 m_t << ">";
802 if (t.caption())
803 {
804 std::visit(*this,*t.caption());
805 }
806 visitChildren(t);
807 m_t << "</table>\n";
808}
809
811{
812 if (m_hide) return;
813 m_t << "<row>\n";
814 visitChildren(r);
815 m_t << "</row>\n";
816}
817
819{
820 if (m_hide) return;
821 if (c.isHeading()) m_t << "<entry thead=\"yes\""; else m_t << "<entry thead=\"no\"";
822 for (const auto &opt : c.attribs())
823 {
824 if (opt.name=="colspan" || opt.name=="rowspan")
825 {
826 m_t << " " << opt.name << "=\"" << opt.value.toInt() << "\"";
827 }
828 else if (opt.name=="align" &&
829 (opt.value=="right" || opt.value=="left" || opt.value=="center"))
830 {
831 m_t << " align=\"" << opt.value << "\"";
832 }
833 else if (opt.name=="valign" &&
834 (opt.value == "bottom" || opt.value == "top" || opt.value == "middle"))
835 {
836 m_t << " valign=\"" << opt.value << "\"";
837 }
838 else if (opt.name=="width")
839 {
840 m_t << " width=\"" << opt.value << "\"";
841 }
842 else if (opt.name=="class") // handle markdown generated attributes
843 {
844 if (opt.value.startsWith("markdownTable")) // handle markdown generated attributes
845 {
846 if (opt.value.endsWith("Right"))
847 {
848 m_t << " align='right'";
849 }
850 else if (opt.value.endsWith("Left"))
851 {
852 m_t << " align='left'";
853 }
854 else if (opt.value.endsWith("Center"))
855 {
856 m_t << " align='center'";
857 }
858 // skip 'markdownTable*' value ending with "None"
859 }
860 else if (!opt.value.isEmpty())
861 {
862 m_t << " class=\"" << convertToXML(opt.value) << "\"";
863 }
864 }
865 }
866 m_t << ">";
867 visitChildren(c);
868 m_t << "</entry>";
869}
870
872{
873 if (m_hide) return;
874 m_t << "<caption";
875 if (!c.file().isEmpty())
876 {
877 m_t << " id=\"" << stripPath(c.file()) << "_1" << c.anchor() << "\"";
878 }
879 m_t << ">";
880 visitChildren(c);
881 m_t << "</caption>\n";
882}
883
885{
886 if (m_hide) return;
887 m_t << "<internal>";
888 visitChildren(i);
889 m_t << "</internal>\n";
890}
891
893{
894 if (m_hide) return;
895 m_t << "<ulink url=\"" << convertToXML(href.url(), TRUE) << "\">";
896 visitChildren(href);
897 m_t << "</ulink>";
898}
899
901{
902 if (m_hide) return;
903 m_t << "<summary>";
904 visitChildren(s);
905 m_t << "</summary>";
906}
907
909{
910 if (m_hide) return;
911 m_t << "<details>";
912 auto summary = d.summary();
913 if (summary)
914 {
915 std::visit(*this,*summary);
916 }
917 visitChildren(d);
918 m_t << "</details>";
919}
920
922{
923 if (m_hide) return;
924 m_t << "<heading level=\"" << header.level() << "\">";
925 visitChildren(header);
926 m_t << "</heading>\n";
927}
928
930{
931 if (m_hide) return;
932
933 QCString url = img.url();
934 QCString baseName;
935 if (url.isEmpty())
936 {
937 baseName = img.relPath()+img.name();
938 }
939 else
940 {
941 baseName = correctURL(url,img.relPath());
942 }
943 HtmlAttribList attribs = img.attribs();
944 auto it = std::find_if(attribs.begin(),attribs.end(),
945 [](const auto &att) { return att.name=="alt"; });
946 QCString altValue = it!=attribs.end() ? it->value : "";
947 visitPreStart(m_t, "image", FALSE, *this, img.children(), baseName, TRUE,
948 img.type(), img.width(), img.height(), QCString(),
949 altValue, img.isInlineImage());
950
951 // copy the image to the output dir
952 FileDef *fd = nullptr;
953 bool ambig;
954 if (url.isEmpty() && (fd=findFileDef(Doxygen::imageNameLinkedMap,img.name(),ambig)))
955 {
956 copyFile(fd->absFilePath(),Config_getString(XML_OUTPUT)+"/"+baseName);
957 }
958 visitChildren(img);
959 visitPostEnd(m_t, "image");
960}
961
963{
964 if (m_hide) return;
965 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
966 visitPreStart(m_t, "dotfile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
967 visitChildren(df);
968 visitPostEnd(m_t, "dotfile");
969}
970
972{
973 if (m_hide) return;
974 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
975 visitPreStart(m_t, "mscfile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
976 visitChildren(df);
977 visitPostEnd(m_t, "mscfile");
978}
979
981{
982 if (m_hide) return;
983 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
984 visitPreStart(m_t, "diafile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
985 visitChildren(df);
986 visitPostEnd(m_t, "diafile");
987}
988
990{
991 if (m_hide) return;
992 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
993 visitPreStart(m_t, "plantumlfile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
994 visitChildren(df);
995 visitPostEnd(m_t, "plantumlfile");
996}
997
999{
1000 if (m_hide) return;
1001 startLink(lnk.ref(),lnk.file(),lnk.anchor());
1002 visitChildren(lnk);
1003 endLink();
1004}
1005
1007{
1008 if (m_hide) return;
1009 if (!ref.file().isEmpty())
1010 {
1011 startLink(ref.ref(),ref.file(),ref.isSubPage() ? QCString() : ref.anchor());
1012 }
1013 if (!ref.hasLinkText()) filter(ref.targetTitle());
1014 visitChildren(ref);
1015 if (!ref.file().isEmpty()) endLink();
1016}
1017
1019{
1020 if (m_hide) return;
1021 m_t << "<tocitem id=\"" << ref.file();
1022 if (!ref.anchor().isEmpty()) m_t << "_1" << ref.anchor();
1023 m_t << "\"";
1024 m_t << ">";
1025 visitChildren(ref);
1026 m_t << "</tocitem>\n";
1027}
1028
1030{
1031 if (m_hide) return;
1032 m_t << "<toclist>\n";
1033 visitChildren(l);
1034 m_t << "</toclist>\n";
1035}
1036
1038{
1039 if (m_hide) return;
1040 m_t << "<parameterlist kind=\"";
1041 switch(s.type())
1042 {
1044 m_t << "param"; break;
1046 m_t << "retval"; break;
1048 m_t << "exception"; break;
1050 m_t << "templateparam"; break;
1051 default:
1052 ASSERT(0);
1053 }
1054 m_t << "\">";
1055 visitChildren(s);
1056 m_t << "</parameterlist>\n";
1057}
1058
1060{
1061 m_t << "</parametertype>\n";
1062 m_t << "<parametertype>";
1063}
1064
1066{
1067 if (m_hide) return;
1068 m_t << "<parameteritem>\n";
1069 m_t << "<parameternamelist>\n";
1070 for (const auto &param : pl.parameters())
1071 {
1072 if (!pl.paramTypes().empty())
1073 {
1074 m_t << "<parametertype>";
1075 for (const auto &type : pl.paramTypes())
1076 {
1077 std::visit(*this,type);
1078 }
1079 m_t << "</parametertype>\n";
1080 }
1081 m_t << "<parametername";
1083 {
1084 m_t << " direction=\"";
1085 if (pl.direction()==DocParamSect::In)
1086 {
1087 m_t << "in";
1088 }
1089 else if (pl.direction()==DocParamSect::Out)
1090 {
1091 m_t << "out";
1092 }
1093 else if (pl.direction()==DocParamSect::InOut)
1094 {
1095 m_t << "inout";
1096 }
1097 m_t << "\"";
1098 }
1099 m_t << ">";
1100 std::visit(*this,param);
1101 m_t << "</parametername>\n";
1102 }
1103 m_t << "</parameternamelist>\n";
1104 m_t << "<parameterdescription>\n";
1105 for (const auto &par : pl.paragraphs())
1106 {
1107 std::visit(*this,par);
1108 }
1109 m_t << "</parameterdescription>\n";
1110 m_t << "</parameteritem>\n";
1111}
1112
1114{
1115 if (m_hide) return;
1116 if (x.title().isEmpty()) return;
1117 m_t << "<xrefsect id=\"";
1118 m_t << x.file() << "_1" << x.anchor();
1119 m_t << "\">";
1120 m_t << "<xreftitle>";
1121 filter(x.title());
1122 m_t << "</xreftitle>";
1123 m_t << "<xrefdescription>";
1124 visitChildren(x);
1125 if (x.title().isEmpty()) return;
1126 m_t << "</xrefdescription>";
1127 m_t << "</xrefsect>";
1128}
1129
1131{
1132 if (m_hide) return;
1133 startLink(QCString(),ref.file(),ref.anchor());
1134 visitChildren(ref);
1135 endLink();
1136 m_t << " ";
1137}
1138
1140{
1141 visitChildren(t);
1142}
1143
1145{
1146 if (m_hide) return;
1147 m_t << "<blockquote>";
1148 visitChildren(q);
1149 m_t << "</blockquote>";
1150}
1151
1153{
1154}
1155
1157{
1158 if (m_hide) return;
1159 m_t << "<parblock>";
1160 visitChildren(pb);
1161 m_t << "</parblock>";
1162}
1163
1164
1166{
1167 m_t << convertToXML(str);
1168}
1169
1170void XmlDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1171{
1172 //printf("XmlDocVisitor: file=%s anchor=%s\n",qPrint(file),qPrint(anchor));
1173 m_t << "<ref refid=\"" << file;
1174 if (!anchor.isEmpty()) m_t << "_1" << anchor;
1175 m_t << "\" kindref=\"";
1176 if (!anchor.isEmpty()) m_t << "member"; else m_t << "compound";
1177 m_t << "\"";
1178 if (!ref.isEmpty()) m_t << " external=\"" << ref << "\"";
1179 m_t << ">";
1180}
1181
1183{
1184 m_t << "</ref>";
1185}
1186
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:552
bool isEnumList() const
Definition docnode.h:561
Node representing an item of a auto list.
Definition docnode.h:576
int itemNumber() const
Definition docnode.h:579
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:711
QCString height() const
Definition docnode.h:669
QCString file() const
Definition docnode.h:665
QCString width() const
Definition docnode.h:668
Node representing a dot file.
Definition docnode.h:693
Node representing an emoji.
Definition docnode.h:322
int index() const
Definition docnode.h:326
QCString name() const
Definition docnode.h:325
Node representing an item of a cross-referenced list.
Definition docnode.h:510
QCString text() const
Definition docnode.h:514
int id() const
Definition docnode.h:516
Node representing a Hypertext reference.
Definition docnode.h:803
QCString url() const
Definition docnode.h:810
Node representing a horizontal ruler.
Definition docnode.h:215
Node representing an HTML blockquote.
Definition docnode.h:1271
Node representing a HTML table caption.
Definition docnode.h:1208
QCString anchor() const
Definition docnode.h:1215
QCString file() const
Definition docnode.h:1214
Node representing a HTML table cell.
Definition docnode.h:1173
bool isHeading() const
Definition docnode.h:1180
const HtmlAttribList & attribs() const
Definition docnode.h:1185
Node representing a HTML description data.
Definition docnode.h:1161
Node representing a Html description list.
Definition docnode.h:881
Node representing a Html description item.
Definition docnode.h:868
Node Html details.
Definition docnode.h:837
const DocNodeVariant * summary() const
Definition docnode.h:844
Node Html heading.
Definition docnode.h:853
int level() const
Definition docnode.h:857
Node representing a Html list.
Definition docnode.h:980
const HtmlAttribList & attribs() const
Definition docnode.h:986
Type type() const
Definition docnode.h:985
Node representing a HTML list item.
Definition docnode.h:1145
const HtmlAttribList & attribs() const
Definition docnode.h:1150
Node representing a HTML table row.
Definition docnode.h:1226
Node Html summary.
Definition docnode.h:824
Node representing a HTML table.
Definition docnode.h:1249
size_t numRows() const
Definition docnode.h:1253
size_t numColumns() const
Definition docnode.h:1258
const DocNodeVariant * caption() const
Definition docnode.cpp:2027
const HtmlAttribList & attribs() const
Definition docnode.h:1255
Node representing an image.
Definition docnode.h:622
const HtmlAttribList & attribs() const
Definition docnode.h:636
QCString relPath() const
Definition docnode.h:632
QCString name() const
Definition docnode.h:628
QCString url() const
Definition docnode.h:633
QCString height() const
Definition docnode.h:631
Type type() const
Definition docnode.h:627
QCString width() const
Definition docnode.h:630
@ DocBook
Definition docnode.h:624
bool isInlineImage() const
Definition docnode.h:634
Node representing a include/dontinclude operator block.
Definition docnode.h:458
bool stripCodeComments() const
Definition docnode.h:487
bool isLast() const
Definition docnode.h:484
QCString includeFileName() const
Definition docnode.h:490
QCString text() const
Definition docnode.h:480
QCString context() const
Definition docnode.h:482
QCString exampleFile() const
Definition docnode.h:489
int line() const
Definition docnode.h:478
Type type() const
Definition docnode.h:466
bool isFirst() const
Definition docnode.h:483
bool showLineNo() const
Definition docnode.h:479
bool isExample() const
Definition docnode.h:488
Node representing an included text block from file.
Definition docnode.h:416
QCString blockId() const
Definition docnode.h:435
QCString extension() const
Definition docnode.h:431
bool isBlock() const
Definition docnode.h:439
bool stripCodeComments() const
Definition docnode.h:436
@ LatexInclude
Definition docnode.h:418
@ SnippetWithLines
Definition docnode.h:419
@ DontIncWithLines
Definition docnode.h:420
@ IncWithLines
Definition docnode.h:419
@ HtmlInclude
Definition docnode.h:418
@ VerbInclude
Definition docnode.h:418
@ DontInclude
Definition docnode.h:418
@ DocbookInclude
Definition docnode.h:420
Type type() const
Definition docnode.h:432
QCString exampleFile() const
Definition docnode.h:438
QCString text() const
Definition docnode.h:433
QCString file() const
Definition docnode.h:430
bool trimLeft() const
Definition docnode.h:440
bool isExample() const
Definition docnode.h:437
QCString context() const
Definition docnode.h:434
Node representing an entry in the index.
Definition docnode.h:533
QCString entry() const
Definition docnode.h:540
Node representing an internal section of documentation.
Definition docnode.h:949
Node representing an internal reference to some item.
Definition docnode.h:787
QCString file() const
Definition docnode.h:791
QCString anchor() const
Definition docnode.h:793
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:702
DocNodeVariant * parent()
Definition docnode.h:89
Node representing an block of paragraphs.
Definition docnode.h:959
Node representing a paragraph in the documentation tree.
Definition docnode.h:1060
Node representing a parameter list.
Definition docnode.h:1105
const DocNodeList & parameters() const
Definition docnode.h:1109
const DocNodeList & paramTypes() const
Definition docnode.h:1110
DocParamSect::Direction direction() const
Definition docnode.h:1113
const DocNodeList & paragraphs() const
Definition docnode.h:1111
Node representing a parameter section.
Definition docnode.h:1033
Type type() const
Definition docnode.h:1048
Node representing a uml file.
Definition docnode.h:720
Node representing a reference to some item.
Definition docnode.h:758
QCString anchor() const
Definition docnode.h:765
QCString targetTitle() const
Definition docnode.h:766
bool isSubPage() const
Definition docnode.h:772
QCString file() const
Definition docnode.h:762
QCString ref() const
Definition docnode.h:764
bool hasLinkText() const
Definition docnode.h:768
Root node of documentation tree.
Definition docnode.h:1293
Node representing a reference to a section.
Definition docnode.h:915
QCString file() const
Definition docnode.h:919
QCString anchor() const
Definition docnode.h:920
Node representing a list of section references.
Definition docnode.h:939
Node representing a normal section.
Definition docnode.h:894
QCString file() const
Definition docnode.h:902
int level() const
Definition docnode.h:898
QCString anchor() const
Definition docnode.h:900
const DocNodeVariant * title() const
Definition docnode.h:899
Node representing a separator.
Definition docnode.h:346
Node representing a simple list.
Definition docnode.h:970
Node representing a simple list item.
Definition docnode.h:1133
const DocNodeVariant * paragraph() const
Definition docnode.h:1137
Node representing a simple section.
Definition docnode.h:997
Type type() const
Definition docnode.h:1006
const DocNodeVariant * title() const
Definition docnode.h:1013
Node representing a separator between two simple sections of the same type.
Definition docnode.h:1024
Node representing a style change.
Definition docnode.h:264
Style style() const
Definition docnode.h:292
bool enable() const
Definition docnode.h:294
Node representing a special symbol.
Definition docnode.h:309
HtmlEntityMapper::SymType symbol() const
Definition docnode.h:313
Root node of a text fragment.
Definition docnode.h:1284
Node representing a simple section title.
Definition docnode.h:589
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:357
QCString height() const
Definition docnode.h:373
bool hasCaption() const
Definition docnode.h:371
QCString language() const
Definition docnode.h:369
const DocNodeList & children() const
Definition docnode.h:376
bool isBlock() const
Definition docnode.h:370
bool isExample() const
Definition docnode.h:366
QCString context() const
Definition docnode.h:365
Type type() const
Definition docnode.h:363
QCString text() const
Definition docnode.h:364
QCString exampleFile() const
Definition docnode.h:367
QCString engine() const
Definition docnode.h:374
@ JavaDocLiteral
Definition docnode.h:359
QCString width() const
Definition docnode.h:372
Node representing a VHDL flow chart.
Definition docnode.h:729
CodeParserInterface & getCodeParser(const QCString &langExt)
void pushHidden(bool hide)
bool popHidden()
Node representing some amount of white space.
Definition docnode.h:335
QCString chars() const
Definition docnode.h:339
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:601
QCString anchor() const
Definition docnode.h:605
QCString file() const
Definition docnode.h:604
QCString title() const
Definition docnode.h:606
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
virtual QCString absFilePath() const =0
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
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:526
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:265
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:84
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
#define ASSERT(x)
Definition qcstring.h:39
SrcLangExt
Language as given by extension.
Definition types.h:42
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5549
QCString correctURL(const QCString &url, const QCString &relPath)
Corrects URL url according to the relative path relPath.
Definition util.cpp:6257
QCString stripPath(const QCString &s)
Definition util.cpp:5292
SrcLangExt getLanguageFromCodeLang(QCString &fileName)
Routine to handle the language attribute of the \code command.
Definition util.cpp:5567
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:4266
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:6169
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5591
FileDef * findFileDef(const FileNameLinkedMap *fnMap, const QCString &n, bool &ambig)
Definition util.cpp:3262
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)