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// own header
17#include "xmldocvisitor.h"
18
19// other includes
20#include "codefragment.h"
21#include "config.h"
22#include "docparser.h"
23#include "doxygen.h"
24#include "emoji.h"
25#include "filedef.h"
26#include "fileinfo.h"
27#include "filename.h"
28#include "htmlentity.h"
29#include "message.h"
30#include "outputgen.h"
31#include "parserintf.h"
32#include "util.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 DString &name, bool writeType, DocImage::Type type, const DString &width,
96 const DString &height, const DString engine = DString(), const DString &alt = DString(), 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.empty())
113 {
114 t << " name=\"" << convertToXML(name, true) << "\"";
115 }
116 if (!width.empty())
117 {
118 t << " width=\"" << convertToXML(width) << "\"";
119 }
120 if (!height.empty())
121 {
122 t << " height=\"" << convertToXML(height) << "\"";
123 }
124 if (!engine.empty())
125 {
126 t << " engine=\"" << convertToXML(engine) << "\"";
127 }
128 if (!alt.empty())
129 {
130 t << " alt=\"" << convertToXML(alt) << "\"";
131 }
132 if (inlineImage)
133 {
134 t << " inline=\"yes\"";
135 }
136 if (doCaption)
137 {
138 t << " caption=\"";
139 visitCaption(visitor, children);
140 t << "\"";
141 }
142 t << ">";
143}
144
145static void visitPostEnd(TextStream &t, const char *cmd)
146{
147 t << "</" << cmd << ">\n";
148}
149
151 : m_t(t), m_ci(ci), m_insidePre(false), m_hide(false),
152 m_langExt(langExt), m_sectionLevel(0)
153{
154}
155
156 //--------------------------------------
157 // visitor functions for leaf nodes
158 //--------------------------------------
159
161{
162 if (m_hide) return;
163 filter(w.word());
164}
165
167{
168 if (m_hide) return;
169 startLink(w.ref(),w.file(),w.anchor());
170 filter(w.word());
171 endLink();
172}
173
175{
176 if (m_hide) return;
177 if (m_insidePre)
178 {
179 m_t << w.chars();
180 }
181 else
182 {
183 m_t << " ";
184 }
185}
186
188{
189 if (m_hide) return;
190 const char *res = HtmlEntityMapper::instance().xml(s.symbol());
191 if (res)
192 {
193 m_t << res;
194 }
195 else
196 {
197 err("XML: non supported HTML-entity found: {}\n",HtmlEntityMapper::instance().html(s.symbol(),true));
198 }
199}
200
202{
203 if (m_hide) return;
204 const char *res = EmojiEntityMapper::instance().name(s.index());
205 if (res)
206 {
207 DString name=res;
208 name = name.mid(1,name.length()-2);
209 m_t << "<emoji name=\"" << name << "\" unicode=\"";
211 m_t << "\"/>";
212 }
213 else
214 {
215 m_t << s.name();
216 }
217}
218
220{
221 if (m_hide) return;
222 m_t << "<ulink url=\"";
223 if (u.isEmail()) m_t << "mailto:";
224 filter(u.url());
225 m_t << "\">";
226 filter(u.url());
227 m_t << "</ulink>";
228}
229
231{
232 if (m_hide) return;
233 m_t << "<linebreak/>\n";
234}
235
237{
238 if (m_hide) return;
239 m_t << "<hruler/>\n";
240}
241
243{
244 if (m_hide) return;
245 switch (s.style())
246 {
248 if (s.enable()) m_t << "<bold>"; else m_t << "</bold>";
249 break;
251 if (s.enable()) m_t << "<s>"; else m_t << "</s>";
252 break;
254 if (s.enable()) m_t << "<strike>"; else m_t << "</strike>";
255 break;
257 if (s.enable()) m_t << "<del>"; else m_t << "</del>";
258 break;
260 if (s.enable()) m_t << "<underline>"; else m_t << "</underline>";
261 break;
263 if (s.enable()) m_t << "<ins>"; else m_t << "</ins>";
264 break;
266 if (s.enable()) m_t << "<emphasis>"; else m_t << "</emphasis>";
267 break;
271 if (s.enable()) m_t << "<computeroutput>"; else m_t << "</computeroutput>";
272 break;
274 if (s.enable()) m_t << "<subscript>"; else m_t << "</subscript>";
275 break;
277 if (s.enable()) m_t << "<superscript>"; else m_t << "</superscript>";
278 break;
280 if (s.enable()) m_t << "<center>"; else m_t << "</center>";
281 break;
283 if (s.enable()) m_t << "<small>"; else m_t << "</small>";
284 break;
286 if (s.enable()) m_t << "<cite>"; else m_t << "</cite>";
287 break;
289 if (s.enable())
290 {
291 m_t << "<preformatted>";
292 m_insidePre=true;
293 }
294 else
295 {
296 m_t << "</preformatted>";
297 m_insidePre=false;
298 }
299 break;
300 case DocStyleChange::Div: /* HTML only */ break;
301 case DocStyleChange::Span: /* HTML only */ break;
302 }
303}
304
306{
307 if (m_hide) return;
308 DString lang = m_langExt;
309 if (!s.language().empty()) // explicit language setting
310 {
311 lang = s.language();
312 }
313 SrcLangExt langExt = getLanguageFromCodeLang(lang);
314 switch(s.type())
315 {
317 m_t << "<programlisting";
318 if (!s.language().empty())
319 m_t << " filename=\"" << lang << "\">";
320 else
321 m_t << ">";
322 getCodeParser(lang).parseCode(m_ci,s.context(),s.text(),langExt,
323 Config_getBool(STRIP_CODE_COMMENTS),
324 CodeParserOptions().setExample(s.isExample(),s.exampleFile()));
325 m_t << "</programlisting>";
326 break;
328 m_t << "<javadocliteral>";
329 filter(s.text());
330 m_t << "</javadocliteral>";
331 break;
333 m_t << "<javadoccode>";
334 filter(s.text());
335 m_t << "</javadoccode>";
336 break;
338 m_t << "<verbatim>";
339 filter(s.text());
340 m_t << "</verbatim>";
341 break;
343 if (s.isBlock())
344 {
345 m_t << "<htmlonly block=\"yes\">";
346 }
347 else
348 {
349 m_t << "<htmlonly>";
350 }
351 filter(s.text());
352 m_t << "</htmlonly>";
353 break;
355 m_t << "<rtfonly>";
356 filter(s.text());
357 m_t << "</rtfonly>";
358 break;
360 m_t << "<manonly>";
361 filter(s.text());
362 m_t << "</manonly>";
363 break;
365 m_t << "<latexonly>";
366 filter(s.text());
367 m_t << "</latexonly>";
368 break;
370 m_t << "<docbookonly>";
371 filter(s.text());
372 m_t << "</docbookonly>";
373 break;
375 m_t << s.text();
376 break;
377 case DocVerbatim::Dot:
378 visitPreStart(m_t, "dot", s.hasCaption(), *this, s.children(), DString(""), false, DocImage::Html, s.width(), s.height());
379 filter(s.text());
380 visitPostEnd(m_t, "dot");
381 break;
382 case DocVerbatim::Msc:
383 visitPreStart(m_t, "msc", s.hasCaption(), *this, s.children(), DString(""), false, DocImage::Html, s.width(), s.height());
384 filter(s.text());
385 visitPostEnd(m_t, "msc");
386 break;
388 visitPreStart(m_t, "plantuml", s.hasCaption(), *this, s.children(), DString(""), false, DocImage::Html, s.width(), s.height(), s.engine());
389 filter(s.text());
390 visitPostEnd(m_t, "plantuml");
391 break;
393 visitPreStart(m_t, "mermaid", s.hasCaption(), *this, s.children(), DString(""), false, DocImage::Html, s.width(), s.height());
394 filter(s.text());
395 visitPostEnd(m_t, "mermaid");
396 break;
397 }
398}
399
401{
402 if (m_hide) return;
403 m_t << "<anchor id=\"" << anc.file() << "_1" << anc.anchor() << "\"/>";
404}
405
407{
408 if (m_hide) return;
410 //printf("XMLDocVisitor: DocInclude type=%d trimleft=%d\n",inc.type(),inc.trimLeft());
411 switch(inc.type())
412 {
414 {
415 m_t << "<programlisting filename=\"" << inc.file() << "\">";
416 FileInfo cfi( inc.file().str() );
417 auto fd = createFileDef( cfi.dirPath(), cfi.fileName());
419 inc.text(),
420 langExt,
421 inc.stripCodeComments(),
423 .setExample(inc.isExample(),inc.exampleFile())
424 .setFileDef(fd.get())
425 .setInlineFragment(true)
426 );
427 m_t << "</programlisting>";
428 }
429 break;
431 m_t << "<programlisting filename=\"" << inc.file() << "\">";
433 inc.text(),
434 langExt,
435 inc.stripCodeComments(),
437 .setExample(inc.isExample(),inc.exampleFile())
438 .setInlineFragment(true)
439 .setShowLineNumbers(false)
440 );
441 m_t << "</programlisting>";
442 break;
445 break;
447 if (inc.isBlock())
448 {
449 m_t << "<htmlonly block=\"yes\">";
450 }
451 else
452 {
453 m_t << "<htmlonly>";
454 }
455 filter(inc.text());
456 m_t << "</htmlonly>";
457 break;
459 m_t << "<latexonly>";
460 filter(inc.text());
461 m_t << "</latexonly>";
462 break;
464 m_t << "<rtfonly>";
465 filter(inc.text());
466 m_t << "</rtfonly>";
467 break;
469 m_t << "<manonly>";
470 filter(inc.text());
471 m_t << "</manonly>";
472 break;
474 filter(inc.text());
475 break;
477 m_t << "<docbookonly>";
478 filter(inc.text());
479 m_t << "</docbookonly>";
480 break;
482 m_t << "<verbatim>";
483 filter(inc.text());
484 m_t << "</verbatim>";
485 break;
488 m_t << "<programlisting filename=\"" << inc.file() << "\">";
490 inc.file(),
491 inc.blockId(),
492 inc.context(),
494 inc.trimLeft(),
496 );
497 m_t << "</programlisting>";
498 break;
499 }
500}
501
503{
504 //printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
505 // op.type(),op.isFirst(),op.isLast(),qPrint(op.text()));
506 if (op.isFirst())
507 {
508 if (!m_hide)
509 {
510 m_t << "<programlisting filename=\"" << op.includeFileName() << "\">";
511 }
513 m_hide = true;
514 }
516 if (locLangExt.empty()) locLangExt = m_langExt;
517 SrcLangExt langExt = getLanguageFromFileName(locLangExt);
518 if (op.type()!=DocIncOperator::Skip)
519 {
520 m_hide = popHidden();
521 if (!m_hide)
522 {
523 std::unique_ptr<FileDef> fd;
524 if (!op.includeFileName().empty())
525 {
526 FileInfo cfi( op.includeFileName().str() );
527 fd = createFileDef( cfi.dirPath(), cfi.fileName() );
528 }
529
530 getCodeParser(locLangExt).parseCode(m_ci,op.context(),
531 op.text(),langExt,
534 .setExample(op.isExample(), op.exampleFile())
535 .setFileDef(fd.get())
536 .setStartLine(op.line())
538 );
539 }
541 m_hide=true;
542 }
543 if (op.isLast())
544 {
545 m_hide = popHidden();
546 if (!m_hide) m_t << "</programlisting>";
547 }
548 else
549 {
550 if (!m_hide) m_t << "\n";
551 }
552}
553
555{
556 if (m_hide) return;
557 m_t << "<formula id=\"" << f.id() << "\">";
558 filter(f.text());
559 m_t << "</formula>";
560}
561
563{
564 if (m_hide) return;
565 m_t << "<indexentry>"
566 "<primaryie>";
567 filter(ie.entry());
568 m_t << "</primaryie>"
569 "<secondaryie></secondaryie>"
570 "</indexentry>";
571}
572
574{
575 const DocSimpleSect *sect = std::get_if<DocSimpleSect>(sep.parent());
576 if (sect)
577 {
578 endSimpleSect(m_t,*sect);
579 startSimpleSect(m_t,*sect);
580 }
581}
582
584{
585 if (m_hide) return;
586 auto opt = cite.option();
587 if (!cite.file().empty())
588 {
589 if (!opt.noCite()) startLink(cite.ref(),cite.file(),cite.anchor());
590
591 filter(cite.getText(), false, true);
592
593 if (!opt.noCite()) endLink();
594 }
595 else
596 {
597 m_t << "<b>";
598 if (!opt.noPar()) filter("[");
599 filter(cite.target());
600 if (!opt.noPar()) filter("]");
601 m_t << "</b>";
602 }
603}
604
605//--------------------------------------
606// visitor functions for compound nodes
607//--------------------------------------
608
610{
611 if (m_hide) return;
612 if (l.isEnumList())
613 {
614 m_t << "<orderedlist>\n";
615 }
616 else
617 {
618 m_t << "<itemizedlist>\n";
619 }
620 visitChildren(l);
621 if (l.isEnumList())
622 {
623 m_t << "</orderedlist>\n";
624 }
625 else
626 {
627 m_t << "</itemizedlist>\n";
628 }
629}
630
632{
633 if (m_hide) return;
634 switch (li.itemNumber())
635 {
636 case DocAutoList::Unchecked: // unchecked
637 m_t << "<listitem override=\"unchecked\">";
638 break;
639 case DocAutoList::Checked_x: // checked with x
640 case DocAutoList::Checked_X: // checked with X
641 m_t << "<listitem override=\"checked\">";
642 break;
643 default:
644 m_t << "<listitem>";
645 break;
646 }
647 visitChildren(li);
648 m_t << "</listitem>";
649}
650
652{
653 if (m_hide) return;
654 m_t << "<para>";
655 visitChildren(p);
656 m_t << "</para>\n";
657}
658
660{
661 visitChildren(r);
662}
663
665{
666 if (m_hide) return;
668 if (s.title())
669 {
670 std::visit(*this,*s.title());
671 }
672 visitChildren(s);
674}
675
677{
678 if (m_hide) return;
679 m_t << "<title>";
680 visitChildren(t);
681 m_t << "</title>";
682}
683
685{
686 if (m_hide) return;
687 m_t << "<itemizedlist>\n";
688 visitChildren(l);
689 m_t << "</itemizedlist>\n";
690}
691
693{
694 if (m_hide) return;
695 m_t << "<listitem>";
696 if (li.paragraph())
697 {
698 std::visit(*this,*li.paragraph());
699 }
700 m_t << "</listitem>\n";
701}
702
704{
705 if (m_hide) return;
706 int orgSectionLevel = m_sectionLevel;
707 DString sectId = s.file();
708 if (!s.anchor().empty()) sectId += "_1"+s.anchor();
709 while (m_sectionLevel+1<s.level()) // fix missing intermediate levels
710 {
712 m_t << "<sect" << m_sectionLevel << " id=\"" << sectId << "_1s" << m_sectionLevel << "\">";
713 }
715 m_t << "<sect" << s.level() << " id=\"" << sectId << "\">\n";
716 if (s.title())
717 {
718 std::visit(*this,*s.title());
719 }
720 visitChildren(s);
721 m_t << "</sect" << s.level() << ">";
723 while (orgSectionLevel<m_sectionLevel) // fix missing intermediate levels
724 {
725 m_t << "</sect" << m_sectionLevel << ">";
727 }
728 m_t << "\n";
729}
730
732{
733 if (m_hide) return;
734 if (s.type()==DocHtmlList::Ordered)
735 {
736 m_t << "<orderedlist";
737 for (const auto &opt : s.attribs())
738 {
739 m_t << " " << opt.name << "=\"" << opt.value << "\"";
740 }
741 m_t << ">\n";
742 }
743 else
744 {
745 m_t << "<itemizedlist>\n";
746 }
747 visitChildren(s);
748 if (s.type()==DocHtmlList::Ordered)
749 {
750 m_t << "</orderedlist>\n";
751 }
752 else
753 {
754 m_t << "</itemizedlist>\n";
755 }
756}
757
759{
760 if (m_hide) return;
761 m_t << "<listitem";
762 for (const auto &opt : l.attribs())
763 {
764 if (opt.name=="value")
765 {
766 m_t << " " << opt.name << "=\"" << opt.value << "\"";
767 }
768 }
769 m_t << ">\n";
770 visitChildren(l);
771 m_t << "</listitem>\n";
772}
773
775{
776 if (m_hide) return;
777 m_t << "<variablelist>\n";
778 visitChildren(dl);
779 m_t << "</variablelist>\n";
780}
781
783{
784 if (m_hide) return;
785 m_t << "<varlistentry><term>";
786 visitChildren(dt);
787 m_t << "</term></varlistentry>\n";
788}
789
791{
792 if (m_hide) return;
793 m_t << "<listitem>";
794 visitChildren(dd);
795 m_t << "</listitem>\n";
796}
797
799{
800 if (m_hide) return;
801 m_t << "<table rows=\"" << t.numRows()
802 << "\" cols=\"" << t.numColumns() << "\"" ;
803 for (const auto &opt : t.attribs())
804 {
805 if (opt.name=="width")
806 {
807 m_t << " " << opt.name << "=\"" << opt.value << "\"";
808 }
809 }
810 m_t << ">";
811 if (t.caption())
812 {
813 std::visit(*this,*t.caption());
814 }
815 visitChildren(t);
816 m_t << "</table>\n";
817}
818
820{
821 if (m_hide) return;
822 m_t << "<row>\n";
823 visitChildren(r);
824 m_t << "</row>\n";
825}
826
828{
829 if (m_hide) return;
830 if (c.isHeading()) m_t << "<entry thead=\"yes\""; else m_t << "<entry thead=\"no\"";
831 for (const auto &opt : c.attribs())
832 {
833 if (opt.name=="colspan" || opt.name=="rowspan")
834 {
835 m_t << " " << opt.name << "=\"" << opt.value.toInt() << "\"";
836 }
837 else if (opt.name=="align" &&
838 (opt.value=="right" || opt.value=="left" || opt.value=="center"))
839 {
840 m_t << " align=\"" << opt.value << "\"";
841 }
842 else if (opt.name=="valign" &&
843 (opt.value == "bottom" || opt.value == "top" || opt.value == "middle"))
844 {
845 m_t << " valign=\"" << opt.value << "\"";
846 }
847 else if (opt.name=="width")
848 {
849 m_t << " width=\"" << opt.value << "\"";
850 }
851 else if (opt.name=="class") // handle markdown generated attributes
852 {
853 if (opt.value.startsWith("markdownTable")) // handle markdown generated attributes
854 {
855 if (opt.value.endsWith("Right"))
856 {
857 m_t << " align='right'";
858 }
859 else if (opt.value.endsWith("Left"))
860 {
861 m_t << " align='left'";
862 }
863 else if (opt.value.endsWith("Center"))
864 {
865 m_t << " align='center'";
866 }
867 // skip 'markdownTable*' value ending with "None"
868 }
869 else if (!opt.value.empty())
870 {
871 m_t << " class=\"" << convertToXML(opt.value) << "\"";
872 }
873 }
874 }
875 m_t << ">";
876 visitChildren(c);
877 m_t << "</entry>";
878}
879
881{
882 if (m_hide) return;
883 m_t << "<caption";
884 if (!c.file().empty())
885 {
886 m_t << " id=\"" << stripPath(c.file()) << "_1" << c.anchor() << "\"";
887 }
888 m_t << ">";
889 visitChildren(c);
890 m_t << "</caption>\n";
891}
892
894{
895 if (m_hide) return;
896 m_t << "<internal>";
897 visitChildren(i);
898 m_t << "</internal>\n";
899}
900
902{
903 if (m_hide) return;
904 m_t << "<ulink url=\"" << convertToXML(href.url(), true) << "\">";
905 visitChildren(href);
906 m_t << "</ulink>";
907}
908
910{
911 if (m_hide) return;
912 m_t << "<summary>";
913 visitChildren(s);
914 m_t << "</summary>";
915}
916
918{
919 if (m_hide) return;
920 m_t << "<details>";
921 auto summary = d.summary();
922 if (summary)
923 {
924 std::visit(*this,*summary);
925 }
926 visitChildren(d);
927 m_t << "</details>";
928}
929
931{
932 if (m_hide) return;
933 m_t << "<heading level=\"" << header.level() << "\">";
934 visitChildren(header);
935 m_t << "</heading>\n";
936}
937
939{
940 if (m_hide) return;
941
942 DString url = img.url();
943 DString baseName;
944 if (url.empty())
945 {
946 baseName = img.relPath()+img.name();
947 }
948 else
949 {
950 baseName = correctURL(url,img.relPath());
951 }
952 HtmlAttribList attribs = img.attribs();
953 auto it = std::find_if(attribs.begin(),attribs.end(),
954 [](const auto &att) { return att.name=="alt"; });
955 DString altValue = it!=attribs.end() ? it->value : "";
956 visitPreStart(m_t, "image", false, *this, img.children(), baseName, true,
957 img.type(), img.width(), img.height(), DString(),
958 altValue, img.isInlineImage());
959
960 // copy the image to the output dir
961 FileDef *fd = nullptr;
962 bool ambig;
963 if (url.empty() && (fd=Doxygen::imageNameLinkedMap->findFileDef(img.name(),ambig)))
964 {
965 copyFile(fd->absFilePath(),Config_getString(XML_OUTPUT)+"/"+baseName);
966 }
967 visitChildren(img);
968 visitPostEnd(m_t, "image");
969}
970
972{
973 if (m_hide) return;
974 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
975 visitPreStart(m_t, "dotfile", false, *this, df.children(), stripPath(df.file()), false, DocImage::Html, df.width(), df.height());
976 visitChildren(df);
977 visitPostEnd(m_t, "dotfile");
978}
979
981{
982 if (m_hide) return;
983 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
984 visitPreStart(m_t, "mscfile", false, *this, df.children(), stripPath(df.file()), false, DocImage::Html, df.width(), df.height());
985 visitChildren(df);
986 visitPostEnd(m_t, "mscfile");
987}
988
990{
991 if (m_hide) return;
992 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
993 visitPreStart(m_t, "diafile", false, *this, df.children(), stripPath(df.file()), false, DocImage::Html, df.width(), df.height());
994 visitChildren(df);
995 visitPostEnd(m_t, "diafile");
996}
997
999{
1000 if (m_hide) return;
1001 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
1002 visitPreStart(m_t, "plantumlfile", false, *this, df.children(), stripPath(df.file()), false, DocImage::Html, df.width(), df.height());
1003 visitChildren(df);
1004 visitPostEnd(m_t, "plantumlfile");
1005}
1006
1008{
1009 if (m_hide) return;
1010 copyFile(df.file(),Config_getString(XML_OUTPUT)+"/"+stripPath(df.file()));
1011 visitPreStart(m_t, "mermaidfile", false, *this, df.children(), stripPath(df.file()), false, DocImage::Html, df.width(), df.height());
1012 visitChildren(df);
1013 visitPostEnd(m_t, "mermaidfile");
1014}
1015
1017{
1018 if (m_hide) return;
1019 startLink(lnk.ref(),lnk.file(),lnk.anchor());
1020 visitChildren(lnk);
1021 endLink();
1022}
1023
1025{
1026 if (m_hide) return;
1027 if (!ref.file().empty())
1028 {
1029 startLink(ref.ref(),ref.file(),ref.isSubPage() ? DString() : ref.anchor());
1030 }
1031 if (!ref.hasLinkText()) filter(ref.targetTitle());
1032 visitChildren(ref);
1033 if (!ref.file().empty()) endLink();
1034}
1035
1037{
1038 if (m_hide) return;
1039 m_t << "<tocitem id=\"" << ref.file();
1040 if (!ref.anchor().empty()) m_t << "_1" << ref.anchor();
1041 m_t << "\"";
1042 m_t << ">";
1043 visitChildren(ref);
1044 m_t << "</tocitem>\n";
1045}
1046
1048{
1049 if (m_hide) return;
1050 m_t << "<toclist>\n";
1051 visitChildren(l);
1052 m_t << "</toclist>\n";
1053}
1054
1056{
1057 if (m_hide) return;
1058 m_t << "<parameterlist kind=\"";
1059 switch(s.type())
1060 {
1062 m_t << "param"; break;
1064 m_t << "retval"; break;
1066 m_t << "exception"; break;
1068 m_t << "templateparam"; break;
1069 default:
1070 ASSERT(0);
1071 }
1072 m_t << "\">";
1073 visitChildren(s);
1074 m_t << "</parameterlist>\n";
1075}
1076
1078{
1079 m_t << "</parametertype>\n";
1080 m_t << "<parametertype>";
1081}
1082
1084{
1085 if (m_hide) return;
1086 m_t << "<parameteritem>\n";
1087 m_t << "<parameternamelist>\n";
1088 for (const auto &param : pl.parameters())
1089 {
1090 if (!pl.paramTypes().empty())
1091 {
1092 m_t << "<parametertype>";
1093 for (const auto &type : pl.paramTypes())
1094 {
1095 std::visit(*this,type);
1096 }
1097 m_t << "</parametertype>\n";
1098 }
1099 m_t << "<parametername";
1101 {
1102 m_t << " direction=\"";
1103 if (pl.direction()==DocParamSect::In)
1104 {
1105 m_t << "in";
1106 }
1107 else if (pl.direction()==DocParamSect::Out)
1108 {
1109 m_t << "out";
1110 }
1111 else if (pl.direction()==DocParamSect::InOut)
1112 {
1113 m_t << "inout";
1114 }
1115 m_t << "\"";
1116 }
1117 m_t << ">";
1118 std::visit(*this,param);
1119 m_t << "</parametername>\n";
1120 }
1121 m_t << "</parameternamelist>\n";
1122 m_t << "<parameterdescription>\n";
1123 for (const auto &par : pl.paragraphs())
1124 {
1125 std::visit(*this,par);
1126 }
1127 m_t << "</parameterdescription>\n";
1128 m_t << "</parameteritem>\n";
1129}
1130
1132{
1133 if (m_hide) return;
1134 if (x.title().empty()) return;
1135 m_t << "<xrefsect id=\"";
1136 m_t << x.file() << "_1" << x.anchor();
1137 m_t << "\">";
1138 m_t << "<xreftitle>";
1139 filter(x.title());
1140 m_t << "</xreftitle>";
1141 m_t << "<xrefdescription>";
1142 visitChildren(x);
1143 if (x.title().empty()) return;
1144 m_t << "</xrefdescription>";
1145 m_t << "</xrefsect>";
1146}
1147
1149{
1150 if (m_hide) return;
1151 startLink(DString(),ref.file(),ref.anchor());
1152 visitChildren(ref);
1153 endLink();
1154 m_t << " ";
1155}
1156
1158{
1159 visitChildren(t);
1160}
1161
1163{
1164 if (m_hide) return;
1165 m_t << "<blockquote>";
1166 visitChildren(q);
1167 m_t << "</blockquote>";
1168}
1169
1171{
1172}
1173
1175{
1176 if (m_hide) return;
1177 m_t << "<parblock>";
1178 visitChildren(pb);
1179 m_t << "</parblock>";
1180}
1181
1182
1183void XmlDocVisitor::filter(const DString &str, const bool keepEntities, const bool citeEntry)
1184{
1185 m_t << convertToXML(str, keepEntities, citeEntry);
1186}
1187
1188void XmlDocVisitor::startLink(const DString &ref,const DString &file,const DString &anchor)
1189{
1190 //printf("XmlDocVisitor: file=%s anchor=%s\n",qPrint(file),qPrint(anchor));
1191 m_t << "<ref refid=\"" << file;
1192 if (!anchor.empty()) m_t << "_1" << anchor;
1193 m_t << "\" kindref=\"";
1194 if (!anchor.empty()) m_t << "member"; else m_t << "compound";
1195 m_t << "\"";
1196 if (!ref.empty()) m_t << " external=\"" << ref << "\"";
1197 m_t << ">";
1198}
1199
1201{
1202 m_t << "</ref>";
1203}
1204
static CodeFragmentManager & instance()
void parseCodeFragment(OutputCodeList &codeOutList, const DString &fileName, const DString &blockId, const DString &scopeName, bool showLineNumbers, bool trimLeft, bool stripCodeComments)
virtual void parseCode(OutputCodeList &codeOutList, const DString &scopeName, const DString &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.
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:318
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
const std::string & str() const
Definition dstring.h:645
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:151
Node representing an anchor.
Definition docnode.h:229
DString anchor() const
Definition docnode.h:232
DString 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
DString ref() const
Definition docnode.h:250
DString getText() const
Definition docnode.cpp:979
DString anchor() const
Definition docnode.h:251
CiteInfoOption option() const
Definition docnode.h:253
DString target() const
Definition docnode.h:252
DString file() const
Definition docnode.h:248
DocNodeList & children()
Definition docnode.h:143
Node representing a dia file.
Definition docnode.h:731
DString file() const
Definition docnode.h:685
DString width() const
Definition docnode.h:688
DString height() const
Definition docnode.h:689
Node representing a dot file.
Definition docnode.h:713
Node representing an emoji.
Definition docnode.h:341
int index() const
Definition docnode.h:345
DString name() const
Definition docnode.h:344
Node representing an item of a cross-referenced list.
Definition docnode.h:529
DString text() const
Definition docnode.h:533
int id() const
Definition docnode.h:535
Node representing a Hypertext reference.
Definition docnode.h:832
DString url() const
Definition docnode.h:839
Node representing a horizontal ruler.
Definition docnode.h:216
Node representing an HTML blockquote.
Definition docnode.h:1296
Node representing a HTML table caption.
Definition docnode.h:1233
DString file() const
Definition docnode.h:1239
DString anchor() const
Definition docnode.h:1240
Node representing a HTML table cell.
Definition docnode.h:1198
bool isHeading() const
Definition docnode.h:1205
const HtmlAttribList & attribs() const
Definition docnode.h:1210
Node representing a HTML description data.
Definition docnode.h:1186
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:1170
const HtmlAttribList & attribs() const
Definition docnode.h:1175
Node representing a HTML table row.
Definition docnode.h:1251
Node Html summary.
Definition docnode.h:853
Node representing a HTML table.
Definition docnode.h:1274
size_t numRows() const
Definition docnode.h:1278
size_t numColumns() const
Definition docnode.h:1283
const DocNodeVariant * caption() const
Definition docnode.cpp:2334
const HtmlAttribList & attribs() const
Definition docnode.h:1280
Node representing an image.
Definition docnode.h:642
const HtmlAttribList & attribs() const
Definition docnode.h:656
DString relPath() const
Definition docnode.h:652
Type type() const
Definition docnode.h:647
DString width() const
Definition docnode.h:650
DString name() const
Definition docnode.h:648
@ DocBook
Definition docnode.h:644
DString url() const
Definition docnode.h:653
bool isInlineImage() const
Definition docnode.h:654
DString height() const
Definition docnode.h:651
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
DString text() const
Definition docnode.h:499
DString context() const
Definition docnode.h:501
DString exampleFile() const
Definition docnode.h:508
DString includeFileName() const
Definition docnode.h:509
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
bool isBlock() const
Definition docnode.h:458
bool stripCodeComments() const
Definition docnode.h:455
DString blockId() const
Definition docnode.h:454
@ 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
DString context() const
Definition docnode.h:453
Type type() const
Definition docnode.h:451
DString exampleFile() const
Definition docnode.h:457
DString text() const
Definition docnode.h:452
DString file() const
Definition docnode.h:449
DString extension() const
Definition docnode.h:450
bool trimLeft() const
Definition docnode.h:459
bool isExample() const
Definition docnode.h:456
Node representing an entry in the index.
Definition docnode.h:552
DString 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
DString anchor() const
Definition docnode.h:822
DString file() const
Definition docnode.h:820
Node representing a line break.
Definition docnode.h:202
Node representing a word that can be linked to something.
Definition docnode.h:165
DString word() const
Definition docnode.h:170
DString anchor() const
Definition docnode.h:174
DString ref() const
Definition docnode.h:173
DString file() const
Definition docnode.h:171
Node representing a mermaid file.
Definition docnode.h:749
Node representing a msc file.
Definition docnode.h:722
DocNodeVariant * parent()
Definition docnode.h:89
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:1130
const DocNodeList & parameters() const
Definition docnode.h:1134
const DocNodeList & paramTypes() const
Definition docnode.h:1135
DocParamSect::Direction direction() const
Definition docnode.h:1138
const DocNodeList & paragraphs() const
Definition docnode.h:1136
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
DString ref() const
Definition docnode.h:793
DString file() const
Definition docnode.h:791
bool isSubPage() const
Definition docnode.h:801
DString anchor() const
Definition docnode.h:794
bool hasLinkText() const
Definition docnode.h:797
DString targetTitle() const
Definition docnode.h:795
Root node of documentation tree.
Definition docnode.h:1318
Node representing a reference to a section.
Definition docnode.h:944
DString anchor() const
Definition docnode.h:949
DString file() const
Definition docnode.h:948
Node representing a list of section references.
Definition docnode.h:968
Node representing a normal section.
Definition docnode.h:923
DString file() const
Definition docnode.h:931
int level() const
Definition docnode.h:927
DString 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:1158
const DocNodeVariant * paragraph() const
Definition docnode.h:1162
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:1309
Node representing a simple section title.
Definition docnode.h:608
Node representing a URL (or email address).
Definition docnode.h:188
DString url() const
Definition docnode.h:192
bool isEmail() const
Definition docnode.h:193
Node representing a verbatim, unparsed text fragment.
Definition docnode.h:376
DString text() const
Definition docnode.h:383
bool hasCaption() const
Definition docnode.h:390
DString height() const
Definition docnode.h:392
const DocNodeList & children() const
Definition docnode.h:395
DString language() const
Definition docnode.h:388
bool isBlock() const
Definition docnode.h:389
bool isExample() const
Definition docnode.h:385
Type type() const
Definition docnode.h:382
DString exampleFile() const
Definition docnode.h:386
DString width() const
Definition docnode.h:391
DString context() const
Definition docnode.h:384
DString engine() const
Definition docnode.h:393
@ JavaDocLiteral
Definition docnode.h:378
Node representing a VHDL flow chart.
Definition docnode.h:758
void pushHidden(bool hide)
CodeParserInterface & getCodeParser(const DString &langExt)
bool popHidden()
Node representing some amount of white space.
Definition docnode.h:354
DString chars() const
Definition docnode.h:358
Node representing a word.
Definition docnode.h:153
DString word() const
Definition docnode.h:156
Node representing an item of a cross-referenced list.
Definition docnode.h:621
DString anchor() const
Definition docnode.h:625
DString file() const
Definition docnode.h:624
DString title() const
Definition docnode.h:626
static FileNameLinkedMap * imageNameLinkedMap
Definition doxygen.h:98
const char * name(int index) const
Access routine to the name of the Emoji entity.
Definition emoji.cpp:2029
static EmojiEntityMapper & instance()
Returns the one and only instance of the Emoji entity mapper.
Definition emoji.cpp:1981
A model of a file symbol.
Definition filedef.h:97
virtual DString absFilePath() const =0
Minimal replacement for QFileInfo.
Definition fileinfo.h:26
std::string fileName() const
Definition fileinfo.cpp:122
std::string dirPath(bool absPath=true) const
Definition fileinfo.cpp:141
FileDef * findFileDef(const DString &n, bool &ambig) const
Returns the file definition in fnMap that matches the file name n.
Definition filename.cpp:38
bool empty() const
checks whether the container is empty
Definition growvector.h:140
Class representing a list of HTML attributes.
Definition htmlattrib.h:31
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:162
Text streaming class that buffers data.
Definition textstream.h:36
Concrete visitor implementation for XML output.
OutputCodeList & m_ci
void visitChildren(const T &t)
XmlDocVisitor(TextStream &t, OutputCodeList &ci, const DString &langExt)
TextStream & m_t
void filter(const DString &str, const bool keepEntities=false, const bool citeEntry=false)
void operator()(const DocWord &)
void startLink(const DString &ref, const DString &file, const DString &anchor)
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
std::unique_ptr< FileDef > createFileDef(const DString &p, const DString &n, const DString &ref, const DString &dn)
Definition filedef.cpp:267
#define err(fmt,...)
Definition message.h:127
#define ASSERT(x)
Definition message.h:142
Options to configure the code parser.
Definition parserintf.h:77
CodeParserOptions & setStartLine(int lineNr)
Definition parserintf.h:100
CodeParserOptions & setInlineFragment(bool enable)
Definition parserintf.h:106
CodeParserOptions & setShowLineNumbers(bool enable)
Definition parserintf.h:112
CodeParserOptions & setFileDef(const FileDef *fd)
Definition parserintf.h:97
SrcLangExt
Definition types.h:207
DString correctURL(const DString &url, const DString &relPath)
Corrects URL url according to the relative path relPath.
Definition util.cpp:4659
DString getFileNameExtension(const DString &fn)
Definition util.cpp:4210
SrcLangExt getLanguageFromFileName(const DString &fileName, SrcLangExt defLang)
Definition util.cpp:4168
DString convertToXML(const DString &s, bool keepEntities, const bool citeEntry)
Definition util.cpp:3232
bool copyFile(const DString &src, const DString &dest)
Copies the contents of file with name src to the newly created file with name dest.
Definition util.cpp:4619
DString stripPath(const DString &s)
Definition util.cpp:3960
SrcLangExt getLanguageFromCodeLang(DString &fileName)
Routine to handle the language attribute of the \code command.
Definition util.cpp:4186
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 visitPreStart(TextStream &t, const char *cmd, bool doCaption, XmlDocVisitor &visitor, const DocNodeList &children, const DString &name, bool writeType, DocImage::Type type, const DString &width, const DString &height, const DString engine=DString(), const DString &alt=DString(), bool inlineImage=false)
static void startSimpleSect(TextStream &t, const DocSimpleSect &s)