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 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(),
418 inc.isExample(),
419 inc.exampleFile(),
420 fd.get(), // fileDef,
421 -1, // start line
422 -1, // end line
423 FALSE, // inline fragment
424 nullptr, // memberDef
425 TRUE // show line numbers
426 );
427 m_t << "</programlisting>";
428 }
429 break;
431 m_t << "<programlisting filename=\"" << inc.file() << "\">";
433 inc.text(),
434 langExt,
435 inc.stripCodeComments(),
436 inc.isExample(),
437 inc.exampleFile(),
438 nullptr, // fileDef
439 -1, // startLine
440 -1, // endLine
441 TRUE, // inlineFragment
442 nullptr, // memberDef
443 FALSE // show line numbers
444 );
445 m_t << "</programlisting>";
446 break;
449 break;
451 if (inc.isBlock())
452 {
453 m_t << "<htmlonly block=\"yes\">";
454 }
455 else
456 {
457 m_t << "<htmlonly>";
458 }
459 filter(inc.text());
460 m_t << "</htmlonly>";
461 break;
463 m_t << "<latexonly>";
464 filter(inc.text());
465 m_t << "</latexonly>";
466 break;
468 m_t << "<rtfonly>";
469 filter(inc.text());
470 m_t << "</rtfonly>";
471 break;
473 m_t << "<manonly>";
474 filter(inc.text());
475 m_t << "</manonly>";
476 break;
478 filter(inc.text());
479 break;
481 m_t << "<docbookonly>";
482 filter(inc.text());
483 m_t << "</docbookonly>";
484 break;
486 m_t << "<verbatim>";
487 filter(inc.text());
488 m_t << "</verbatim>";
489 break;
492 m_t << "<programlisting filename=\"" << inc.file() << "\">";
494 inc.file(),
495 inc.blockId(),
496 inc.context(),
498 inc.trimLeft(),
500 );
501 m_t << "</programlisting>";
502 break;
503 }
504}
505
507{
508 //printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
509 // op.type(),op.isFirst(),op.isLast(),qPrint(op.text()));
510 if (op.isFirst())
511 {
512 if (!m_hide)
513 {
514 m_t << "<programlisting filename=\"" << op.includeFileName() << "\">";
515 }
517 m_hide = TRUE;
518 }
520 if (locLangExt.isEmpty()) locLangExt = m_langExt;
521 SrcLangExt langExt = getLanguageFromFileName(locLangExt);
522 if (op.type()!=DocIncOperator::Skip)
523 {
524 m_hide = popHidden();
525 if (!m_hide)
526 {
527 std::unique_ptr<FileDef> fd;
528 if (!op.includeFileName().isEmpty())
529 {
530 FileInfo cfi( op.includeFileName().str() );
531 fd = createFileDef( cfi.dirPath(), cfi.fileName() );
532 }
533
534 getCodeParser(locLangExt).parseCode(m_ci,op.context(),
535 op.text(),langExt,
537 op.isExample(),
538 op.exampleFile(),
539 fd.get(), // fileDef
540 op.line(), // startLine
541 -1, // endLine
542 FALSE, // inline fragment
543 nullptr, // memberDef
544 op.showLineNo() // show line numbers
545 );
546 }
548 m_hide=TRUE;
549 }
550 if (op.isLast())
551 {
552 m_hide = popHidden();
553 if (!m_hide) m_t << "</programlisting>";
554 }
555 else
556 {
557 if (!m_hide) m_t << "\n";
558 }
559}
560
562{
563 if (m_hide) return;
564 m_t << "<formula id=\"" << f.id() << "\">";
565 filter(f.text());
566 m_t << "</formula>";
567}
568
570{
571 if (m_hide) return;
572 m_t << "<indexentry>"
573 "<primaryie>";
574 filter(ie.entry());
575 m_t << "</primaryie>"
576 "<secondaryie></secondaryie>"
577 "</indexentry>";
578}
579
581{
582 const DocSimpleSect *sect = std::get_if<DocSimpleSect>(sep.parent());
583 if (sect)
584 {
585 endSimpleSect(m_t,*sect);
586 startSimpleSect(m_t,*sect);
587 }
588}
589
591{
592 if (m_hide) return;
593 auto opt = cite.option();
594 if (!cite.file().isEmpty())
595 {
596 if (!opt.noCite()) startLink(cite.ref(),cite.file(),cite.anchor());
597
598 filter(cite.getText());
599
600 if (!opt.noCite()) endLink();
601 }
602 else
603 {
604 m_t << "<b>";
605 if (!opt.noPar()) filter("[");
606 filter(cite.target());
607 if (!opt.noPar()) filter("]");
608 m_t << "</b>";
609 }
610}
611
612//--------------------------------------
613// visitor functions for compound nodes
614//--------------------------------------
615
617{
618 if (m_hide) return;
619 if (l.isEnumList())
620 {
621 m_t << "<orderedlist>\n";
622 }
623 else
624 {
625 m_t << "<itemizedlist>\n";
626 }
627 visitChildren(l);
628 if (l.isEnumList())
629 {
630 m_t << "</orderedlist>\n";
631 }
632 else
633 {
634 m_t << "</itemizedlist>\n";
635 }
636}
637
639{
640 if (m_hide) return;
641 switch (li.itemNumber())
642 {
643 case DocAutoList::Unchecked: // unchecked
644 m_t << "<listitem override=\"unchecked\">";
645 break;
646 case DocAutoList::Checked_x: // checked with x
647 case DocAutoList::Checked_X: // checked with X
648 m_t << "<listitem override=\"checked\">";
649 break;
650 default:
651 m_t << "<listitem>";
652 break;
653 }
654 visitChildren(li);
655 m_t << "</listitem>";
656}
657
659{
660 if (m_hide) return;
661 m_t << "<para>";
662 visitChildren(p);
663 m_t << "</para>\n";
664}
665
667{
668 visitChildren(r);
669}
670
672{
673 if (m_hide) return;
675 if (s.title())
676 {
677 std::visit(*this,*s.title());
678 }
679 visitChildren(s);
681}
682
684{
685 if (m_hide) return;
686 m_t << "<title>";
687 visitChildren(t);
688 m_t << "</title>";
689}
690
692{
693 if (m_hide) return;
694 m_t << "<itemizedlist>\n";
695 visitChildren(l);
696 m_t << "</itemizedlist>\n";
697}
698
700{
701 if (m_hide) return;
702 m_t << "<listitem>";
703 if (li.paragraph())
704 {
705 std::visit(*this,*li.paragraph());
706 }
707 m_t << "</listitem>\n";
708}
709
711{
712 if (m_hide) return;
713 int orgSectionLevel = m_sectionLevel;
714 QCString sectId = s.file();
715 if (!s.anchor().isEmpty()) sectId += "_1"+s.anchor();
716 while (m_sectionLevel+1<s.level()) // fix missing intermediate levels
717 {
719 m_t << "<sect" << m_sectionLevel << " id=\"" << sectId << "_1s" << m_sectionLevel << "\">";
720 }
722 m_t << "<sect" << s.level() << " id=\"" << sectId << "\">\n";
723 if (s.title())
724 {
725 std::visit(*this,*s.title());
726 }
727 visitChildren(s);
728 m_t << "</sect" << s.level() << ">";
730 while (orgSectionLevel<m_sectionLevel) // fix missing intermediate levels
731 {
732 m_t << "</sect" << m_sectionLevel << ">";
734 }
735 m_t << "\n";
736}
737
739{
740 if (m_hide) return;
741 if (s.type()==DocHtmlList::Ordered)
742 {
743 m_t << "<orderedlist";
744 for (const auto &opt : s.attribs())
745 {
746 m_t << " " << opt.name << "=\"" << opt.value << "\"";
747 }
748 m_t << ">\n";
749 }
750 else
751 {
752 m_t << "<itemizedlist>\n";
753 }
754 visitChildren(s);
755 if (s.type()==DocHtmlList::Ordered)
756 {
757 m_t << "</orderedlist>\n";
758 }
759 else
760 {
761 m_t << "</itemizedlist>\n";
762 }
763}
764
766{
767 if (m_hide) return;
768 m_t << "<listitem";
769 for (const auto &opt : l.attribs())
770 {
771 if (opt.name=="value")
772 {
773 m_t << " " << opt.name << "=\"" << opt.value << "\"";
774 }
775 }
776 m_t << ">\n";
777 visitChildren(l);
778 m_t << "</listitem>\n";
779}
780
782{
783 if (m_hide) return;
784 m_t << "<variablelist>\n";
785 visitChildren(dl);
786 m_t << "</variablelist>\n";
787}
788
790{
791 if (m_hide) return;
792 m_t << "<varlistentry><term>";
793 visitChildren(dt);
794 m_t << "</term></varlistentry>\n";
795}
796
798{
799 if (m_hide) return;
800 m_t << "<listitem>";
801 visitChildren(dd);
802 m_t << "</listitem>\n";
803}
804
806{
807 if (m_hide) return;
808 m_t << "<table rows=\"" << t.numRows()
809 << "\" cols=\"" << t.numColumns() << "\"" ;
810 for (const auto &opt : t.attribs())
811 {
812 if (opt.name=="width")
813 {
814 m_t << " " << opt.name << "=\"" << opt.value << "\"";
815 }
816 }
817 m_t << ">";
818 if (t.caption())
819 {
820 std::visit(*this,*t.caption());
821 }
822 visitChildren(t);
823 m_t << "</table>\n";
824}
825
827{
828 if (m_hide) return;
829 m_t << "<row>\n";
830 visitChildren(r);
831 m_t << "</row>\n";
832}
833
835{
836 if (m_hide) return;
837 if (c.isHeading()) m_t << "<entry thead=\"yes\""; else m_t << "<entry thead=\"no\"";
838 for (const auto &opt : c.attribs())
839 {
840 if (opt.name=="colspan" || opt.name=="rowspan")
841 {
842 m_t << " " << opt.name << "=\"" << opt.value.toInt() << "\"";
843 }
844 else if (opt.name=="align" &&
845 (opt.value=="right" || opt.value=="left" || opt.value=="center"))
846 {
847 m_t << " align=\"" << opt.value << "\"";
848 }
849 else if (opt.name=="valign" &&
850 (opt.value == "bottom" || opt.value == "top" || opt.value == "middle"))
851 {
852 m_t << " valign=\"" << opt.value << "\"";
853 }
854 else if (opt.name=="width")
855 {
856 m_t << " width=\"" << opt.value << "\"";
857 }
858 else if (opt.name=="class") // handle markdown generated attributes
859 {
860 if (opt.value.startsWith("markdownTable")) // handle markdown generated attributes
861 {
862 if (opt.value.endsWith("Right"))
863 {
864 m_t << " align='right'";
865 }
866 else if (opt.value.endsWith("Left"))
867 {
868 m_t << " align='left'";
869 }
870 else if (opt.value.endsWith("Center"))
871 {
872 m_t << " align='center'";
873 }
874 // skip 'markdownTable*' value ending with "None"
875 }
876 else if (!opt.value.isEmpty())
877 {
878 m_t << " class=\"" << convertToXML(opt.value) << "\"";
879 }
880 }
881 }
882 m_t << ">";
883 visitChildren(c);
884 m_t << "</entry>";
885}
886
888{
889 if (m_hide) return;
890 m_t << "<caption";
891 if (!c.file().isEmpty())
892 {
893 m_t << " id=\"" << stripPath(c.file()) << "_1" << c.anchor() << "\"";
894 }
895 m_t << ">";
896 visitChildren(c);
897 m_t << "</caption>\n";
898}
899
901{
902 if (m_hide) return;
903 m_t << "<internal>";
904 visitChildren(i);
905 m_t << "</internal>\n";
906}
907
909{
910 if (m_hide) return;
911 m_t << "<ulink url=\"" << convertToXML(href.url(), TRUE) << "\">";
912 visitChildren(href);
913 m_t << "</ulink>";
914}
915
917{
918 if (m_hide) return;
919 m_t << "<summary>";
920 visitChildren(s);
921 m_t << "</summary>";
922}
923
925{
926 if (m_hide) return;
927 m_t << "<details>";
928 auto summary = d.summary();
929 if (summary)
930 {
931 std::visit(*this,*summary);
932 }
933 visitChildren(d);
934 m_t << "</details>";
935}
936
938{
939 if (m_hide) return;
940 m_t << "<heading level=\"" << header.level() << "\">";
941 visitChildren(header);
942 m_t << "</heading>\n";
943}
944
946{
947 if (m_hide) return;
948
949 QCString url = img.url();
950 QCString baseName;
951 if (url.isEmpty())
952 {
953 baseName = img.relPath()+img.name();
954 }
955 else
956 {
957 baseName = correctURL(url,img.relPath());
958 }
959 HtmlAttribList attribs = img.attribs();
960 auto it = std::find_if(attribs.begin(),attribs.end(),
961 [](const auto &att) { return att.name=="alt"; });
962 QCString altValue = it!=attribs.end() ? it->value : "";
963 visitPreStart(m_t, "image", FALSE, *this, img.children(), baseName, TRUE,
964 img.type(), img.width(), img.height(), QCString(),
965 altValue, img.isInlineImage());
966
967 // copy the image to the output dir
968 FileDef *fd = nullptr;
969 bool ambig;
970 if (url.isEmpty() && (fd=findFileDef(Doxygen::imageNameLinkedMap,img.name(),ambig)))
971 {
972 copyFile(fd->absFilePath(),Config_getString(XML_OUTPUT)+"/"+baseName);
973 }
974 visitChildren(img);
975 visitPostEnd(m_t, "image");
976}
977
979{
980 if (m_hide) return;
981 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
982 visitPreStart(m_t, "dotfile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
983 visitChildren(df);
984 visitPostEnd(m_t, "dotfile");
985}
986
988{
989 if (m_hide) return;
990 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
991 visitPreStart(m_t, "mscfile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
992 visitChildren(df);
993 visitPostEnd(m_t, "mscfile");
994}
995
997{
998 if (m_hide) return;
999 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
1000 visitPreStart(m_t, "diafile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
1001 visitChildren(df);
1002 visitPostEnd(m_t, "diafile");
1003}
1004
1006{
1007 if (m_hide) return;
1008 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
1009 visitPreStart(m_t, "plantumlfile", FALSE, *this, df.children(), stripPath(df.file()), FALSE, DocImage::Html, df.width(), df.height());
1010 visitChildren(df);
1011 visitPostEnd(m_t, "plantumlfile");
1012}
1013
1015{
1016 if (m_hide) return;
1017 startLink(lnk.ref(),lnk.file(),lnk.anchor());
1018 visitChildren(lnk);
1019 endLink();
1020}
1021
1023{
1024 if (m_hide) return;
1025 if (!ref.file().isEmpty())
1026 {
1027 startLink(ref.ref(),ref.file(),ref.isSubPage() ? QCString() : ref.anchor());
1028 }
1029 if (!ref.hasLinkText()) filter(ref.targetTitle());
1030 visitChildren(ref);
1031 if (!ref.file().isEmpty()) endLink();
1032}
1033
1035{
1036 if (m_hide) return;
1037 m_t << "<tocitem id=\"" << ref.file();
1038 if (!ref.anchor().isEmpty()) m_t << "_1" << ref.anchor();
1039 m_t << "\"";
1040 m_t << ">";
1041 visitChildren(ref);
1042 m_t << "</tocitem>\n";
1043}
1044
1046{
1047 if (m_hide) return;
1048 m_t << "<toclist>\n";
1049 visitChildren(l);
1050 m_t << "</toclist>\n";
1051}
1052
1054{
1055 if (m_hide) return;
1056 m_t << "<parameterlist kind=\"";
1057 switch(s.type())
1058 {
1060 m_t << "param"; break;
1062 m_t << "retval"; break;
1064 m_t << "exception"; break;
1066 m_t << "templateparam"; break;
1067 default:
1068 ASSERT(0);
1069 }
1070 m_t << "\">";
1071 visitChildren(s);
1072 m_t << "</parameterlist>\n";
1073}
1074
1076{
1077 m_t << "</parametertype>\n";
1078 m_t << "<parametertype>";
1079}
1080
1082{
1083 if (m_hide) return;
1084 m_t << "<parameteritem>\n";
1085 m_t << "<parameternamelist>\n";
1086 for (const auto &param : pl.parameters())
1087 {
1088 if (!pl.paramTypes().empty())
1089 {
1090 m_t << "<parametertype>";
1091 for (const auto &type : pl.paramTypes())
1092 {
1093 std::visit(*this,type);
1094 }
1095 m_t << "</parametertype>\n";
1096 }
1097 m_t << "<parametername";
1099 {
1100 m_t << " direction=\"";
1101 if (pl.direction()==DocParamSect::In)
1102 {
1103 m_t << "in";
1104 }
1105 else if (pl.direction()==DocParamSect::Out)
1106 {
1107 m_t << "out";
1108 }
1109 else if (pl.direction()==DocParamSect::InOut)
1110 {
1111 m_t << "inout";
1112 }
1113 m_t << "\"";
1114 }
1115 m_t << ">";
1116 std::visit(*this,param);
1117 m_t << "</parametername>\n";
1118 }
1119 m_t << "</parameternamelist>\n";
1120 m_t << "<parameterdescription>\n";
1121 for (const auto &par : pl.paragraphs())
1122 {
1123 std::visit(*this,par);
1124 }
1125 m_t << "</parameterdescription>\n";
1126 m_t << "</parameteritem>\n";
1127}
1128
1130{
1131 if (m_hide) return;
1132 if (x.title().isEmpty()) return;
1133 m_t << "<xrefsect id=\"";
1134 m_t << x.file() << "_1" << x.anchor();
1135 m_t << "\">";
1136 m_t << "<xreftitle>";
1137 filter(x.title());
1138 m_t << "</xreftitle>";
1139 m_t << "<xrefdescription>";
1140 visitChildren(x);
1141 if (x.title().isEmpty()) return;
1142 m_t << "</xrefdescription>";
1143 m_t << "</xrefsect>";
1144}
1145
1147{
1148 if (m_hide) return;
1149 startLink(QCString(),ref.file(),ref.anchor());
1150 visitChildren(ref);
1151 endLink();
1152 m_t << " ";
1153}
1154
1156{
1157 visitChildren(t);
1158}
1159
1161{
1162 if (m_hide) return;
1163 m_t << "<blockquote>";
1164 visitChildren(q);
1165 m_t << "</blockquote>";
1166}
1167
1169{
1170}
1171
1173{
1174 if (m_hide) return;
1175 m_t << "<parblock>";
1176 visitChildren(pb);
1177 m_t << "</parblock>";
1178}
1179
1180
1182{
1183 m_t << convertToXML(str);
1184}
1185
1186void XmlDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1187{
1188 //printf("XmlDocVisitor: file=%s anchor=%s\n",qPrint(file),qPrint(anchor));
1189 m_t << "<ref refid=\"" << file;
1190 if (!anchor.isEmpty()) m_t << "_1" << anchor;
1191 m_t << "\" kindref=\"";
1192 if (!anchor.isEmpty()) m_t << "member"; else m_t << "compound";
1193 m_t << "\"";
1194 if (!ref.isEmpty()) m_t << " external=\"" << ref << "\"";
1195 m_t << ">";
1196}
1197
1199{
1200 m_t << "</ref>";
1201}
1202
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: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:939
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:2141
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: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:5718
QCString correctURL(const QCString &url, const QCString &relPath)
Corrects URL url according to the relative path relPath.
Definition util.cpp:6438
QCString stripPath(const QCString &s)
Definition util.cpp:5461
SrcLangExt getLanguageFromCodeLang(QCString &fileName)
Routine to handle the language attribute of the \code command.
Definition util.cpp:5736
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:4425
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:6370
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5760
FileDef * findFileDef(const FileNameLinkedMap *fnMap, const QCString &n, bool &ambig)
Definition util.cpp:3416
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)