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