Doxygen
Loading...
Searching...
No Matches
docbookgen.cpp
Go to the documentation of this file.
1/******************************************************************************
2*
3*
4*
5* Copyright (C) 1997-2015 by Dimitri van Heesch.
6*
7* Permission to use, copy, modify, and distribute this software and its
8* documentation under the terms of the GNU General Public License is hereby
9* granted. No representations are made about the suitability of this software
10* for any purpose. It is provided "as is" without express or implied warranty.
11* See the GNU General Public License for more details.
12*
13* Documents produced by Doxygen are derivative works derived from the
14* input used in their production; they are not affected by this license.
15*
16*/
17
18// own header
19#include "docbookgen.h"
20
21// other headers
22#include "classdef.h"
23#include "classlist.h"
24#include "conceptdef.h"
25#include "config.h"
26#include "diagram.h"
27#include "dir.h"
28#include "docbookvisitor.h"
29#include "docparser.h"
30#include "dotcallgraph.h"
31#include "dotclassgraph.h"
32#include "dotdirdeps.h"
34#include "dotincldepgraph.h"
35#include "doxygen.h"
36#include "filename.h"
37#include "groupdef.h"
38#include "language.h"
39#include "message.h"
40#include "moduledef.h"
41#include "namespacedef.h"
42#include "outputgen.h"
43#include "outputlist.h"
44#include "pagedef.h"
45#include "parserintf.h"
46#include "section.h"
47#include "util.h"
48
49// no debug info
50#define Docbook_DB(x) do {} while(0)
51// debug to stdout
52//#define Docbook_DB(x) printf x
53// debug inside output
54//#define Docbook_DB(x) DString __t;__t.sprintf x;m_t << __t
55
56#if 0
57#define DB_GEN_C DB_GEN_C1(m_t)
58#define DB_GEN_C1(x) x << "<!-- DB_GEN_C " << __LINE__ << " -->\n";
59#define DB_GEN_C2(y) DB_GEN_C2a(m_t,y)
60#define DB_GEN_C2a(x,y) x << "<!-- DB_GEN_C " << __LINE__ << " " << y << " -->\n";
61#else
62#define DB_GEN_C
63#define DB_GEN_C1(x)
64#define DB_GEN_C2(y)
65#define DB_GEN_C2a(x,y)
66#endif
67
68//------------------
69
70inline void writeDocbookString(TextStream &t,const DString &s)
71{
73}
74
75inline void writeDocbookCodeString(bool hide,TextStream &t,const DString &str, size_t &col, size_t stripIndentAmount)
76{
77 if (str.empty()) return;
78 const int tabSize = Config_getInt(TAB_SIZE);
79 const char *s = str.data();
80 char c=0;
81 if (hide)
82 {
83 col = updateColumnCount(s,col);
84 }
85 else
86 {
87 while ((c=*s++))
88 {
89 switch(c)
90 {
91 case '\t':
92 {
93 int spacesToNextTabStop = tabSize - (col%tabSize);
94 while (spacesToNextTabStop--)
95 {
96 if (col>=stripIndentAmount) t << "&#32;";
97 col++;
98 }
99 break;
100 }
101 case ' ':
102 if (col>=stripIndentAmount) t << "&#32;";
103 col++;
104 break;
105 case '<': t << "&lt;"; col++; break;
106 case '>': t << "&gt;"; col++; break;
107 case '&': t << "&amp;"; col++; break;
108 case '\'': t << "&apos;"; col++; break;
109 case '"': t << "&quot;"; col++; break;
110 default:
111 {
112 uint8_t uc = static_cast<uint8_t>(c);
113 static const char *hex="0123456789ABCDEF";
114 if (uc<32)
115 {
116 t << "&#x24" << hex[uc>>4] << hex[uc&0xF] << ";";
117 }
118 else
119 {
120 t << c;
121 }
122 col++;
123 }
124 break;
125 }
126 }
127 }
128}
129
130static void addIndexTerm(TextStream &t, DString prim, DString sec = "")
131{
132 t << "<indexterm><primary>";
134 t << "</primary>";
135 if (!sec.empty())
136 {
137 t << "<secondary>";
139 t << "</secondary>";
140 }
141 t << "</indexterm>\n";
142}
143void writeDocbookLink(TextStream &t,const DString & /*extRef*/,const DString &compoundId,
144 const DString &anchorId,const DString & text,const DString & /*tooltip*/)
145{
146 t << "<link linkend=\"_" << stripPath(compoundId);
147 if (!anchorId.empty()) t << "_1" << anchorId;
148 t << "\"";
149 t << ">";
150 writeDocbookString(t,text);
151 t << "</link>";
152}
153
157
159{
160 Docbook_DB(("(codify \"%s\")\n",text));
161 writeDocbookCodeString(m_hide,*m_t,text,m_col,static_cast<size_t>(m_stripIndentAmount));
162}
163
168
173
178
180{
181 m_stripIndentAmount = amount;
182}
183
185 const DString &ref,const DString &file,
186 const DString &anchor,const DString &name,
187 const DString &tooltip)
188{
189 if (m_hide) return;
190 Docbook_DB(("(writeCodeLink)\n"));
191 writeDocbookLink(*m_t,ref,file,anchor,name,tooltip);
192 m_col+=name.length();
193}
194
196 const DString &,const DString &file,
197 const DString &,const DString &name,
198 const DString &,bool writeLineAnchor)
199{
200 if (m_hide) return;
201 Docbook_DB(("(writeCodeLinkLine)\n"));
202 if (!writeLineAnchor) return;
203 *m_t << "<anchor xml:id=\"_" << stripExtensionGeneral(stripPath(file),".xml");
204 *m_t << "_1l";
205 writeDocbookString(*m_t,name);
206 *m_t << "\"/>";
207 m_col+=name.length();
208}
209
211 const DString &, const SourceLinkInfo &, const SourceLinkInfo &
212 )
213{
214 Docbook_DB(("(writeToolTip)\n"));
215}
216
218{
219 if (m_hide) return;
220 Docbook_DB(("(startCodeLine)\n"));
221 m_insideCodeLine=true;
222 m_col=0;
223}
224
226{
227 if (m_hide) return;
228 if (m_insideCodeLine) *m_t << "\n";
229 Docbook_DB(("(endCodeLine)\n"));
230 m_lineNumber = -1;
231 m_refId.clear();
233 m_insideCodeLine=false;
234}
235
237{
238 if (m_hide) return;
239 Docbook_DB(("(startFontClass)\n"));
240 *m_t << "<emphasis role=\"" << colorClass << "\">";
242}
243
245{
246 if (m_hide) return;
247 Docbook_DB(("(endFontClass)\n"));
248 *m_t << "</emphasis>"; // non DocBook
249 m_insideSpecialHL=false;
250}
251
253{
254 Docbook_DB(("(writeCodeAnchor)\n"));
255}
256
258 const DString &anchor,int l,bool writeLineAnchor)
259{
260 if (m_hide) return;
261 Docbook_DB(("(writeLineNumber)\n"));
262 m_insideCodeLine = true;
263 if (Config_getBool(SOURCE_BROWSER))
264 {
265 DString lineNumber;
266 lineNumber.sprintf("%05d",l);
267
268 if (!m_sourceFileName.empty())
269 {
270 writeCodeLinkLine(CodeSymbolType::Default,ref,m_sourceFileName,anchor,lineNumber,DString(),writeLineAnchor);
271 }
272 if (!fileName.empty())
273 {
274 writeCodeLink(CodeSymbolType::Default,ref,fileName,anchor,lineNumber,DString());
275 }
276 else
277 {
278 codify(lineNumber);
279 }
280 *m_t << " ";
281 }
282 else
283 {
284 *m_t << l << " ";
285 }
286 m_col=0;
287}
288
293
295{
297 *m_t << "<programlisting linenumbering=\"unnumbered\">";
298}
299
301{
303 bool wasHidden = m_hide;
304 m_hide = false;
305 //endCodeLine checks is there is still an open code line, if so closes it.
306 endCodeLine();
307 m_hide = wasHidden;
308
309 *m_t << "</programlisting>";
310}
311
312//-------------------------------------------------------------------------------
313
321
338
360
362
367
369{
370 DString dir=Config_getString(DOCBOOK_OUTPUT);
371 Dir d(dir.str());
372 if (!d.exists() && !d.mkdir(dir.str()))
373 {
374 term("Could not create output directory {}\n",dir);
375 }
376
377 createSubDirs(d);
378}
380{
381 DString dname = Config_getString(DOCBOOK_OUTPUT);
382 Dir d(dname.str());
383 clearSubDirs(d);
384}
385
386
387void DocbookGenerator::startFile(const DString &name,bool,const DString &,const DString &,int,int)
388{
390 DString fileName=name;
391 DString pageName;
392 DString fileType="section";
393 if (fileName == "refman")
394 {
395 fileName="index";
396 fileType="book";
397 }
398 else if (fileName == "index")
399 {
400 fileName="mainpage";
401 fileType="chapter";
402 }
403 pageName = fileName;
405 if (!fileName.endsWith(".xml")) fileName+=".xml";
410
411 m_t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n";
412 m_t << "<" << fileType << " xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"";
413 if (!pageName.empty()) m_t << " xml:id=\"_" << stripPath(pageName) << "\"";
414 m_t << " xml:lang=\"" << theTranslator->trISOLang() << "\"";
415 m_t << ">\n";
416}
417
419{
422 m_inLevel = -1;
423 m_inGroup = false;
424
425 // Write page links only after all sections have been closed to avoid bugs
426 m_t << m_pageLinks;
427
428 DString fileType="section";
430 if (fileName == "index.xml")
431 {
432 fileType="book";
433 }
434 else if (fileName == "mainpage.xml")
435 {
436 fileType="chapter";
437 }
438 m_t << "</" << fileType << ">\n";
439 endPlainFile();
441}
442
444{
445DB_GEN_C2("IndexSection " << is)
446 switch (is)
447 {
449 {
450 DString dbk_projectName = Config_getString(PROJECT_NAME);
451 m_t << " <info>\n";
452 m_t << " <title>" << convertToDocbook(dbk_projectName) << "</title>\n";
453 m_t << " </info>\n";
454 }
455 break;
457 break;
459 break;
461 //Module Index\n"
462 break;
464 //Module Index\n"
465 break;
467 //Directory Index\n"
468 break;
470 //Namespace Index\n"
471 break;
473 //Concept Index\n"
474 break;
476 //Hierarchical Index\n"
477 break;
479 //m_t << "{"; //Class Index}\n"
480 break;
482 //Annotated File Index\n"
483 break;
485 //Annotated Page Index\n"
486 break;
488 m_t << "<chapter>\n";
489 m_t << " <title>";
490 break;
492 m_t << "<chapter>\n";
493 m_t << " <title>";
494 break;
496 m_t << "<chapter>\n";
497 m_t << " <title>";
498 break;
500 m_t << "<chapter>\n";
501 m_t << " <title>";
502 break;
504 m_t << "<chapter>\n";
505 m_t << " <title>";
506 break;
508 m_t << "<chapter>\n";
509 m_t << " <title>";
510 break;
512 m_t << "<chapter>\n";
513 m_t << " <title>";
514 break;
516 m_t << "<chapter>\n";
517 m_t << " <title>";
518 break;
520 break;
522 break;
524 break;
525 }
526}
527
529{
530DB_GEN_C2("IndexSection " << is)
531 switch (is)
532 {
534 break;
536 break;
538 {
540 {
541 writePageLink(DString("mainpage"), true);
542 }
543 }
544 break;
546 //m_t << "</chapter>\n";
547 break;
549 //m_t << "</chapter>\n";
550 break;
552 //m_t << "<xi:include href=\"dirs.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
553 //m_t << "</chapter>\n";
554 break;
556 //m_t << "<xi:include href=\"namespaces.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
557 //m_t << "</chapter>\n";
558 break;
560 //m_t << "<xi:include href=\"concepts.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
561 //m_t << "</chapter>\n";
562 break;
564 //m_t << "<xi:include href=\"hierarchy.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
565 //m_t << "</chapter>\n";
566 break;
568 //m_t << "</chapter>\n";
569 break;
571 //m_t << "<xi:include href=\"files.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
572 //m_t << "</chapter>\n";
573 break;
575 //m_t << "<xi:include href=\"pages.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
576 //m_t << "</chapter>\n";
577 break;
579 {
580 m_t << "</title>\n";
581 for (const auto &gd : *Doxygen::groupLinkedMap)
582 {
583 if (!gd->isReference() && !gd->isASubGroup())
584 {
585 writePageLink(gd->getOutputFileBase(), true);
586 }
587 }
588 }
589 m_t << "</chapter>\n";
590 break;
592 {
593 m_t << "</title>\n";
594 for (const auto &mod : ModuleManager::instance().modules())
595 {
596 if (!mod->isReference() && mod->isPrimaryInterface())
597 {
598 writePageLink(mod->getOutputFileBase(), true);
599 }
600 }
601 }
602 m_t << "</chapter>\n";
603 break;
604 break;
606 {
607 m_t << "</title>\n";
608 for (const auto &dd : *Doxygen::dirLinkedMap)
609 {
610 if (dd->isLinkableInProject())
611 {
612 m_t << " <xi:include href=\"" << dd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
613 }
614 }
615 }
616 m_t << "</chapter>\n";
617 break;
619 {
620 m_t << "</title>\n";
621 for (const auto &nd : *Doxygen::namespaceLinkedMap)
622 {
623 if (nd->isLinkableInProject() && !nd->isAlias())
624 {
625 m_t << " <xi:include href=\"" << nd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
626 }
627 }
628 }
629 m_t << "</chapter>\n";
630 break;
632 {
633 m_t << "</title>\n";
634 for (const auto &cd : *Doxygen::conceptLinkedMap)
635 {
636 if (cd->isLinkableInProject() && !cd->isAlias())
637 {
638 m_t << " <xi:include href=\"" << cd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
639 }
640 }
641 }
642 m_t << "</chapter>\n";
643 break;
645 {
646 m_t << "</title>\n";
647 for (const auto &cd : *Doxygen::classLinkedMap)
648 {
649 if (cd->isLinkableInProject() &&
650 !cd->isImplicitTemplateInstance() &&
651 !cd->isEmbeddedInOuterScope() &&
652 !cd->isAlias()
653 )
654 {
655 m_t << " <xi:include href=\"" << cd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
656 }
657 }
658 }
659 m_t << "</chapter>\n";
660 break;
662 {
663 m_t << "</title>\n";
664 for (const auto &fn : *Doxygen::inputNameLinkedMap)
665 {
666 for (const auto &fd : *fn)
667 {
668 if (fd->isLinkableInProject())
669 {
670 m_t << " <xi:include href=\"" << fd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
671 }
672 if (fd->generateSourceFile())
673 {
674 m_t << " <xi:include href=\"" << fd->getSourceFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
675 }
676 }
677 }
678 }
679 m_t << "</chapter>\n";
680 break;
682 {
683 m_t << "</title>\n";
684 for (const auto &pd : *Doxygen::exampleLinkedMap)
685 {
686 m_t << " <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
687 }
688 }
689 m_t << "</chapter>\n";
690 break;
692 for (const auto &pd : *Doxygen::pageLinkedMap)
693 {
694 if (!pd->getGroupDef() && !pd->isReference() && !pd->hasParentPage()
695 && Doxygen::mainPage.get() != pd.get())
696 {
697 writePageLink(pd->getOutputFileBase(), true);
698 }
699 }
700 break;
702 break;
704 m_t << "<index/>\n";
705 break;
706 }
707}
708void DocbookGenerator::writePageLink(const DString &name, bool first)
709{
711 DString link;
712 link.sprintf(" <xi:include href=\"%s.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n",
713 name.data());
714 if (first)
715 m_t << link;
716 else
717 // Buffer page links and write them after all sections are closed
718 m_pageLinks += link;
719}
720
721void DocbookGenerator::writeDoc(const IDocNodeAST *ast,const Definition *ctx,const MemberDef *,int,int sectionLevel)
722{
724 auto astImpl = dynamic_cast<const DocNodeAST*>(ast);
725 if (astImpl && sectionLevel<=m_tocState.maxLevel)
726 {
728 std::visit(visitor,astImpl->root);
729 }
730}
731
733{
735 m_t << "<para>\n";
736}
737
739{
741 m_t << "</para>\n";
742}
744{
746 m_t << text;
747}
749{
751 m_t << "<simplesect>\n";
753 m_t << " <title>";
754}
755
757{
759 m_t << " </title>\n";
760}
762{
764 m_t << convertToDocbook(str);
765}
766static DString objectLinkToString(const DString &, const DString &f,
767 const DString &anchor, const DString &text)
768{
770 DString result;
771 if (!anchor.empty())
772 {
773 if (!f.empty()) result += "<link linkend=\"_" + stripPath(f) + "_1" + anchor + "\">";
774 else result += "<link linkend=\"_" + anchor + "\">";
775 }
776 else
777 {
778 result += "<link linkend=\"_" + stripPath(f) + "\">";
779 }
781 result += "</link>";
782 return result;
783}
785 const DString &anchor, const DString &text)
786{
788 m_t << objectLinkToString(ref,f,anchor,text);
789}
791{
793 m_t << " <itemizedlist>\n";
795}
797{
799 if (m_inListItem[m_levelListItem]) m_t << "</listitem>\n";
801 m_t << " </itemizedlist>\n";
803 if (m_inSimpleSect[m_levelListItem]) m_t << "</simplesect>\n";
805}
807{
809 if (m_inListItem[m_levelListItem]) m_t << "</listitem>\n";
810 m_t << " <listitem><para>";
812}
814{
816 m_t << "</para>\n";
817}
819{
821 m_t << "<emphasis role=\"strong\">";
822}
824{
826 m_t << "</emphasis>";
827}
828void DocbookGenerator::startGroupHeader(const DString &,int extraIndentLevel)
829{
830DB_GEN_C2("m_inLevel " << m_inLevel)
831DB_GEN_C2("extraIndentLevel " << extraIndentLevel)
832 m_firstMember = true;
833 if (m_inSimpleSect[m_levelListItem]) m_t << "</simplesect>\n";
835 if (m_inLevel != -1) m_inGroup = true;
836 if (m_inLevel == extraIndentLevel) closeSection();
837 m_inLevel = extraIndentLevel;
838 openSection();
839 m_t << "<title>";
840}
842{
843DB_GEN_C2("m_inLevel " << m_inLevel)
844DB_GEN_C2("m_inGroup " << m_inGroup)
845 if (m_inGroup) closeSection();
846 m_inGroup = false;
847}
848
850{
852 m_t << "</title>\n";
853}
854
856{
858 if (openBracket) m_t << "(";
859}
865{
867 for (int i=0;i<n;i++) m_t << "&#160;";
868}
870{
872 m_t << "<?linebreak?>";
873}
875{
877 if (!m_denseText) m_t << "<computeroutput>";
878}
880{
882 if (!m_denseText) m_t << "</computeroutput>\n";
883}
885{
887 if (dense)
888 {
889 m_denseText = true;
890 m_t << "<programlisting linenumbering=\"unnumbered\">";
891 }
892}
894{
896 if (m_denseText)
897 {
898 m_denseText = false;
899 m_t << "</programlisting>";
900 }
901}
902void DocbookGenerator::startMemberDoc(const DString &clname, const DString &memname, const DString &, const DString &title,
903 int memCount, int memTotal, bool)
904{
905DB_GEN_C2("m_inLevel " << m_inLevel)
906 openSection();
907 m_t << " <title>" << convertToDocbook(title);
908 if (memTotal>1)
909 {
910 m_t << "<computeroutput>[" << memCount << "/" << memTotal << "]</computeroutput>";
911 }
912 m_t << "</title>\n";
913 if (!memname.empty() && memname[0]!='@')
914 {
915 addIndexTerm(m_t,memname,clname);
916 addIndexTerm(m_t,clname,memname);
917 }
918}
920{
922 m_t << "</computeroutput></para>";
923}
925{
927 m_t << "<title>";
928}
930{
932 m_t << "</title>\n";
933 if (!name.empty()) addIndexTerm(m_t, name);
934}
936 const DString &anchor,const DString &,
937 const DString &)
938{
941 {
943 m_firstMember = false;
944 }
945 if (!anchor.empty())
946 {
947 m_t << "<anchor xml:id=\"_" << stripPath(fName) << "_1" << anchor << "\"/>";
948 }
949}
951{
953}
955{
957}
959{
961 m_t << "<para><computeroutput>";
962}
968{
970 m_t << "<simplesect><title>";
971}
973{
975 m_t << "</title>\n";
976}
982{
984 m_t << "</simplesect>\n";
985}
987{
989 m_t << "<para>";
990}
991
993{
995 m_t << " <informalfigure>\n";
996 m_t << " <mediaobject>\n";
997 m_t << " <imageobject>\n";
998 m_t << " <imagedata width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\""
999 << relPath << fileName << ".png\">" << "</imagedata>\n";
1000 m_t << " </imageobject>\n";
1001 d.writeImage(m_t,dir(),relPath,fileName,false,false);
1002 m_t << " </mediaobject>\n";
1003 m_t << " </informalfigure>\n";
1004 m_t << "</para>\n";
1005}
1010
1011void DocbookGenerator::writeLabel(const DString &l,bool isLast)
1012{
1014 m_t << "<computeroutput>[" << l << "]</computeroutput>";
1015 if (!isLast) m_t << ", ";
1016}
1017
1023{
1025 m_t << "<simplesect><title>";
1027 m_t << "</title>";
1028}
1029
1031{
1033 m_t << "</simplesect>\n";
1034}
1036{
1038 m_t << "<simplesect><title>";
1039}
1041{
1043 m_t << "</title></simplesect>\n";
1044}
1046{
1048 char cs[2];
1049 cs[0]=c;
1050 cs[1]=0;
1051 docify(cs);
1052}
1054{
1056 m_t << "<computeroutput>";
1057}
1059{
1061 m_t << "</computeroutput>";
1062}
1064{
1066 if (!prefix.empty())
1067 {
1068 m_t << " " << prefix << "(";
1069 }
1070 else if (closeBracket)
1071 {
1072 m_t << ")";
1073 }
1074 m_t << " ";
1075}
1076
1078{
1080 m_t << " ";
1081}
1082
1087
1092
1093void DocbookGenerator::endParameterExtra(bool last,bool /*emptyList*/,bool closeBracket)
1094{
1096 if (last && closeBracket)
1097 {
1098 m_t << ")";
1099 }
1100}
1101
1102
1104{
1106 m_t << sep;
1107 if (!m_denseText) m_t << "<computeroutput>";
1108}
1109
1111{
1113 if (!m_denseText) m_t << "</computeroutput>\n";
1114}
1115
1120
1122{
1124 m_t << "</para>";
1125 m_t << "<para>";
1126}
1128{
1130 openSection("xml:id=\"_" + stripPath(lab) + "\"");
1131 m_t << "<title>";
1132}
1134{
1136 m_t << "</title>";
1137 closeSection();
1138}
1140{
1142 addIndexTerm(m_t, prim, sec);
1143}
1144
1146{
1148 int ncols=0;
1149 DString title;
1150 if (isEnum)
1151 {
1152 ncols = 2;
1154 }
1155 else
1156 {
1157 ncols = 3;
1159 }
1160 m_t << "<table frame=\"all\">\n";
1161 if (!title.empty()) m_t << "<title>" << convertToDocbook(title) << "</title>\n";
1162 m_t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n";
1163 for (int i = 0; i < ncols; i++)
1164 {
1165 m_t << " <colspec colname='c" << i+1 << "'/>\n";
1166 }
1167 m_t << "<tbody>\n";
1168 m_simpleTable = true;
1169}
1170
1172{
1174 m_t << " </tbody>\n";
1175 m_t << " </tgroup>\n";
1176 m_t << "</table>\n";
1177 m_simpleTable = false;
1178}
1179
1181{
1183 m_t << "<row><entry>";
1184}
1185
1187{
1189 m_t << "</entry>";
1190}
1191
1193{
1195 m_t << "<entry>";
1196}
1197
1199{
1201 m_t << "</entry>";
1202}
1203
1205{
1207 m_t << "<entry>";
1208}
1209
1211{
1213 m_t << "</entry></row>\n";
1214}
1215
1216void DocbookGenerator::startDescTable(const DString &title,bool hasInits)
1217{
1219 int ncols = (hasInits?3:2);
1220 m_t << "<informaltable frame=\"all\">\n";
1221 if (!title.empty()) m_t << "<title>" << convertToDocbook(title) << "</title>\n";
1222 m_t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n";
1223 int i = 1;
1224 m_t << " <colspec colname='c" << i++ << "'/>\n";
1225 if (hasInits) m_t << " <colspec colname='c" << i++ << "' align='right'/>\n";
1226 m_t << " <colspec colname='c" << i++ << "'/>\n";
1227 m_t << "<tbody>\n";
1228 m_descTable = true;
1229}
1230
1232{
1234 m_t << " </tbody>\n";
1235 m_t << " </tgroup>\n";
1236 m_t << "</informaltable>\n";
1237 m_descTable = false;
1238}
1239
1241{
1243 m_t << "<row>";
1244 m_t << "<entry>";
1245}
1246
1248{
1250 m_t << "</row>";
1251}
1252
1257
1262
1264{
1266 m_t << "</entry><entry>";
1267}
1268
1273
1275{
1277 m_t << "</entry><entry>";
1278}
1279
1281{
1283 m_t << "</entry>";
1284}
1335{
1337 m_inGroup = true;
1338}
1340{
1342 m_t << "<simplesect><title>";
1343 docify(header);
1344 m_t << "</title>\n";
1345}
1347{
1349 m_t << "<para><emphasis role=\"strong\">";
1350}
1356{
1358 m_t << ":";
1359}
1361{
1363 m_t << "</emphasis></para>\n";
1364}
1374{
1376 m_t << "</simplesect>\n";
1377}
1378
1380{
1381 m_t << "<section";
1382 if (!attr.empty()) m_t << " " << attr;
1383 m_t << ">\n";
1385}
1386
1388{
1389 m_t << "</section>\n";
1391}
1392
1394{
1395 while (m_openSectionCount>0)
1396 {
1397 closeSection();
1398 }
1399}
1400
1402 const DString &/*id*/,const DString &ref,
1403 const DString &file, const DString &anchor,
1404 const DString &title, const DString &name)
1405{
1407 m_t << theTranslator->trInheritedFrom(convertToDocbook(title), objectLinkToString(ref, file, anchor, name));
1408}
1409
1411{
1412 m_tocState.level=1;
1413 m_tocState.maxLevel=level;
1414 m_tocState.inLi = BoolVector(level+1,false);
1415 m_t << " <toc>\n";
1416 m_t << " <title>" << theTranslator->trRTFTableOfContents() << "</title>\n";
1417}
1418
1420{
1423 {
1424 m_t << "</tocdiv>\n";
1425 m_tocState.level--;
1426 }
1427 m_t << " </toc>\n";
1428}
1429
1431{
1432 SectionType type = si->type();
1433 if (type.isSection())
1434 {
1435 //printf(" level=%d title=%s\n",level,qPrint(si->title));
1436 int nextLevel = type.level();
1437 if (nextLevel>m_tocState.level)
1438 {
1439 for (int l=m_tocState.level;l<nextLevel;l++)
1440 {
1441 if (l < m_tocState.maxLevel) m_t << " <tocdiv>\n";
1442 }
1443 }
1444 else if (nextLevel<m_tocState.level)
1445 {
1446 for (int l=m_tocState.level;l>nextLevel;l--)
1447 {
1448 m_tocState.inLi[l]=false;
1449 if (l <= m_tocState.maxLevel) m_t << " </tocdiv>\n";
1450 }
1451 }
1452 if (nextLevel <= m_tocState.maxLevel)
1453 {
1454 DString label = convertToDocbook(si->label());
1455 m_t << " <tocentry>";
1456 }
1457 }
1458}
1459
1461{
1462 SectionType type = si->type();
1463 int nextLevel = type.level();
1464 if (type.isSection() && nextLevel <= m_tocState.maxLevel)
1465 {
1466 m_t << "</tocentry>\n";
1467 m_tocState.inLi[nextLevel]=true;
1468 m_tocState.level = nextLevel;
1469 }
1470}
1471
1472//-------------------------------------------------------------------------------------------------
1473
1474static constexpr auto hex="0123456789ABCDEF";
1475
1476/*! Converts a string to an DocBook-encoded string */
1477DString DocbookGenerator::convertToDocbook(const DString &s, bool retainNewline, bool /* citeEntry */)
1478{
1479 if (s.empty()) return s;
1480 DString result;
1481 result.reserve(s.length()+32);
1482 const char *p = s.data();
1483 char c = 0;
1484 while ((c=*p++))
1485 {
1486 switch (c)
1487 {
1488 case '\n':
1489 if (retainNewline)
1490 {
1491 result+="<literallayout>&#160;&#xa;</literallayout>";
1492 result+=c;
1493 }
1494 break;
1495 case '<': result+="&lt;"; break;
1496 case '>': result+="&gt;"; break;
1497 case '&': // possibility to have a special symbol
1499 result,
1500 p-1,
1501 [](HtmlEntityMapper::SymType symType) { return HtmlEntityMapper::instance().docbook(symType); },
1502 "&amp;");
1503 break;
1504 case '\'': result+="&apos;"; break;
1505 case '"': result+="&quot;"; break;
1506 case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
1507 case 11: case 12: case 14: case 15: case 16: case 17: case 18:
1508 case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26:
1509 case 27: case 28: case 29: case 30: case 31:
1510 result+="&#x24";
1511 result+=hex[static_cast<uint8_t>(c)>>4];
1512 result+=hex[static_cast<uint8_t>(c)&0xF];
1513 result+=';';
1514 break;
1515 default:
1516 result+=c;
1517 break;
1518 }
1519 }
1520 return result;
1521}
1522
constexpr auto prefix
Definition anchor.cpp:47
Class representing a built-in class diagram.
Definition diagram.h:29
void writeImage(TextStream &t, const DString &path, const DString &relPath, const DString &file, bool generateMap, bool toIndex) const
Definition diagram.cpp:1363
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
void clear()
Definition dstring.h:214
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
DString & sprintf(const char *format,...)
Definition dstring.cpp:34
void reserve(size_t size)
Reserve space for size bytes without changing the string contents.
Definition dstring.h:217
const std::string & str() const
Definition dstring.h:645
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:157
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:151
The common base class of all entity definitions found in the sources.
Definition definition.h:77
virtual DString getDefFileExtension() const =0
Class representing a directory in the file system.
Definition dir.h:73
bool mkdir(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:301
bool exists() const
Definition dir.cpp:263
Class representing the abstract syntax tree of a documentation block.
Definition docnode.h:1471
void startFontClass(const DString &colorClass) override
void writeLineNumber(const DString &extRef, const DString &compId, const DString &anchorId, int l, bool writeLineAnchor) override
void endFontClass() override
void codify(const DString &text) override
DocbookCodeGenerator(TextStream *t)
TextStream * m_t
Definition docbookgen.h:88
void stripCodeComments(bool b) override
void writeCodeLinkLine(CodeSymbolType type, const DString &ref, const DString &file, const DString &anchor, const DString &name, const DString &tooltip, bool)
void writeCodeLink(CodeSymbolType type, const DString &ref, const DString &file, const DString &anchor, const DString &name, const DString &tooltip) override
void setRelativePath(const DString &path)
Definition docbookgen.h:78
void endCodeFragment(const DString &style) override
void writeCodeAnchor(const DString &) override
void startCodeFragment(const DString &style) override
void writeTooltip(const DString &, const DocLinkInfo &, const DString &, const DString &, const SourceLinkInfo &, const SourceLinkInfo &) override
DString sourceFileName()
Definition docbookgen.h:80
void startSpecialComment() override
void endCodeLine() override
void endSpecialComment() override
void startCodeLine(int) override
void setStripIndentAmount(size_t amount) override
void setTextStream(TextStream *t)
Definition docbookgen.h:50
void setSourceFileName(const DString &sourceFileName)
Definition docbookgen.h:79
Concrete visitor implementation for Docbook output.
void endInlineMemberName() override
void writeRuler() override
void startParameterList(bool) override
void startLocalToc(int level) override
void startTocEntry(const SectionInfo *si) override
void writeDoc(const IDocNodeAST *node, const Definition *ctx, const MemberDef *md, int id, int sectionLevel) override
void startCallGraph() override
void endDescTableRow() override
void startDescTableData() override
void startParagraph(const DString &) override
void startIndexSection(IndexSection) override
void writeNonBreakableSpace(int) override
std::unique_ptr< OutputCodeList > m_codeList
Definition docbookgen.h:332
void startGroupCollaboration() override
DString m_pageLinks
Definition docbookgen.h:344
void addLabel(const DString &, const DString &) override
void startMemberGroupHeader(const DString &, bool) override
void endMemberGroup(bool) override
void cleanup() override
void startMemberHeader(const DString &anchor, int typ) override
void startParameterExtra() override
void endMemberItem(MemberItemType) override
void endLabels() override
void endPlainFile() override
Definition docbookgen.h:320
void endTypewriter() override
void endConstraintType() override
DocbookCodeGenerator * m_codeGen
Definition docbookgen.h:333
void endMemberTemplateParams(const DString &, const DString &) override
void docify(const DString &text) override
void writeLabel(const DString &, bool) override
void startConstraintType() override
void endTocEntry(const SectionInfo *si) override
void addCodeGen(OutputCodeList &list) override
void endMemberDocSimple(bool) override
void endMemberDocName() override
void startMemberDocSimple(bool) override
void endMemberGroupHeader(bool) override
void endDotGraph(DotClassGraph &g) override
void endSection(const DString &, SectionType) override
void endConstraintDocs() override
void endDescTableTitle() override
void startDoxyAnchor(const DString &fName, const DString &manName, const DString &anchor, const DString &name, const DString &args) override
void openSection(const DString &attr=DString())
void startConstraintParam() override
void endCompoundTemplateParams() override
void startTypewriter() override
void startMemberTemplateParams() override
void endTitleHead(const DString &fileName, const DString &name) override
TocState m_tocState
Definition docbookgen.h:352
void endGroupCollaboration(DotGroupCollaboration &g) override
void endTextBlock(bool) override
void endInlineMemberDoc() override
void endMemberHeader() override
void writeObjectLink(const DString &, const DString &, const DString &, const DString &) override
void startMemberDocList() override
void endLocalToc() override
OutputType type() const override
Definition docbookgen.h:119
void startConstraintList(const DString &) override
void startLabels() override
void endMemberDocPrefixItem() override
void exceptionEntry(const DString &, bool) override
void startTitleHead(const DString &) override
void startParameterName(bool) override
void endParameterDefVal() override
std::array< bool, 20 > m_inSimpleSect
Definition docbookgen.h:338
void startFile(const DString &name, bool isSource, const DString &manName, const DString &title, int id, int hierarchyLevel) override
void startGroupHeader(const DString &, int) override
void writeInheritedSectionTitle(const DString &, const DString &, const DString &, const DString &, const DString &, const DString &) override
void endDoxyAnchor(const DString &fileName, const DString &anchor) override
void addIndexItem(const DString &, const DString &) override
static DString convertToDocbook(const DString &s, bool retainNewline=false, bool citeEntry=false)
void writePageLink(const DString &, bool) override
void startMemberDocName(bool) override
void endDescTableData() override
void startDirDepGraph() override
void endIndexSection(IndexSection) override
void startCompoundTemplateParams() override
void startMemberGroup() override
void endParagraph() override
void startClassDiagram() override
void endParameterName() override
void startMemberDocPrefixItem() override
void startDescTableInit() override
void startMemberList() override
void endDirDepGraph(DotDirDeps &g) override
void lineBreak(const DString &) override
void startExamples() override
void endCallGraph(DotCallGraph &g) override
void endMemberDoc(bool) override
void startPlainFile(const DString &name) override
Definition docbookgen.h:319
void startDescTableRow() override
void startInclDepGraph() override
void startDotGraph() override
DocbookGenerator & operator=(const DocbookGenerator &)
void endBold() override
void startInlineMemberType() override
void startMemberItem(const DString &, MemberItemType, const DString &) override
void startBold() override
void endClassDiagram(const ClassDiagram &, const DString &, const DString &) override
void startSection(const DString &, const DString &, SectionType) override
void endMemberDocList() override
void startDescTable(const DString &title, bool hasInits) override
void startDescTableTitle() override
void endGroupHeader(int) override
void startInlineMemberDoc() override
void startConstraintDocs() override
std::array< bool, 20 > m_inListItem
Definition docbookgen.h:337
void endMemberList() override
void endParameterList() override
void startMemberDoc(const DString &, const DString &, const DString &, const DString &, int, int, bool) override
void endParameterExtra(bool, bool, bool) override
void startTextBlock(bool) override
void endDescTableInit() override
void startParameterDefVal(const char *sep) override
void endDescTable() override
void endFile() override
void endConstraintParam() override
void endInlineMemberType() override
void writeString(const DString &) override
static void init()
void startInlineMemberName() override
void endInclDepGraph(DotInclDepGraph &g) override
void writeChar(char) override
void endExamples() override
void endConstraintList() override
Representation of an call graph.
DString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const DString &path, const DString &fileName, const DString &relPath, bool writeImageMap=true, int graphId=-1)
Representation of a class inheritance or dependency graph.
DString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const DString &path, const DString &fileName, const DString &relPath, bool TBRank=true, bool imageMap=true, int graphId=-1)
Representation of an directory dependency graph.
Definition dotdirdeps.h:27
DString writeGraph(TextStream &out, GraphOutputFormat gf, EmbeddedOutputFormat ef, const DString &path, const DString &fileName, const DString &relPath, bool writeImageMap=true, int graphId=-1, bool linkRelations=true)
Representation of a group collaboration graph.
DString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const DString &path, const DString &fileName, const DString &relPath, bool writeImageMap=true, int graphId=-1)
Representation of an include dependency graph.
DString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const DString &path, const DString &fileName, const DString &relPath, bool writeImageMap=true, int graphId=-1)
static NamespaceLinkedMap * namespaceLinkedMap
Definition doxygen.h:108
static ConceptLinkedMap * conceptLinkedMap
Definition doxygen.h:90
static std::unique_ptr< PageDef > mainPage
Definition doxygen.h:93
static FileNameLinkedMap * inputNameLinkedMap
Definition doxygen.h:97
static ClassLinkedMap * classLinkedMap
Definition doxygen.h:88
static PageLinkedMap * exampleLinkedMap
Definition doxygen.h:91
static PageLinkedMap * pageLinkedMap
Definition doxygen.h:92
static DirLinkedMap * dirLinkedMap
Definition doxygen.h:120
static GroupLinkedMap * groupLinkedMap
Definition doxygen.h:107
const char * writeHtmlEntity(T &result, const char *s, HtmlEntityMapperFunc &&mapper, const char *fallback)
Definition htmlentity.h:127
static HtmlEntityMapper & instance()
Returns the one and only instance of the HTML entity mapper.
const char * docbook(SymType symb) const
Access routine to the docbook code of the HTML entity.
opaque representation of the abstract syntax tree (AST)
Definition docparser.h:50
A model of a class/file/namespace member symbol.
Definition memberdef.h:45
static ModuleManager & instance()
Class representing a list of different code generators.
Definition outputlist.h:162
void add(OutputCodeIntfPtr &&p)
Definition outputlist.h:192
Abstract interface for output generators.
Definition outputgen.h:124
DString dir() const
Definition outputgen.cpp:48
TextStream m_t
Definition outputgen.h:113
DString fileName() const
Definition outputgen.cpp:53
class that provide information about a section.
Definition section.h:58
SectionType type() const
Definition section.h:71
DString label() const
Definition section.h:69
constexpr bool isSection() const
Definition section.h:47
constexpr int level() const
Definition section.h:46
Text streaming class that buffers data.
Definition textstream.h:36
virtual DString trCompoundMembers()=0
virtual DString trInheritedFrom(const DString &members, const DString &what)=0
virtual DString trISOLang()=0
virtual DString trEnumerationValues()=0
virtual DString trRTFTableOfContents()=0
virtual DString trExamples()=0
#define Config_getInt(name)
Definition config.h:34
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
std::vector< bool > BoolVector
Definition containers.h:36
static constexpr auto hex
void writeDocbookCodeString(bool hide, TextStream &t, const DString &str, size_t &col, size_t stripIndentAmount)
static void addIndexTerm(TextStream &t, DString prim, DString sec="")
#define Docbook_DB(x)
void writeDocbookString(TextStream &t, const DString &s)
#define DB_GEN_C
#define DB_GEN_C1(x)
void writeDocbookLink(TextStream &t, const DString &, const DString &compoundId, const DString &anchorId, const DString &text, const DString &)
#define DB_GEN_C2(y)
static DString objectLinkToString(const DString &, const DString &f, const DString &anchor, const DString &text)
IndexSection
Definition index.h:31
@ isMainPage
Definition index.h:34
@ isTitlePageAuthor
Definition index.h:33
@ isFileIndex
Definition index.h:42
@ isFileDocumentation
Definition index.h:50
@ isPageDocumentation
Definition index.h:52
@ isDirDocumentation
Definition index.h:46
@ isModuleDocumentation
Definition index.h:44
@ isClassHierarchyIndex
Definition index.h:40
@ isModuleIndex
Definition index.h:35
@ isTopicIndex
Definition index.h:36
@ isConceptIndex
Definition index.h:39
@ isExampleDocumentation
Definition index.h:51
@ isClassDocumentation
Definition index.h:48
@ isPageIndex
Definition index.h:43
@ isCompoundIndex
Definition index.h:41
@ isEndIndex
Definition index.h:54
@ isConceptDocumentation
Definition index.h:49
@ isDirIndex
Definition index.h:37
@ isNamespaceIndex
Definition index.h:38
@ isNamespaceDocumentation
Definition index.h:47
@ isTitlePageStart
Definition index.h:32
@ isTopicDocumentation
Definition index.h:45
@ isPageDocumentation2
Definition index.h:53
Translator * theTranslator
Definition language.cpp:76
#define term(fmt,...)
Definition message.h:137
Definition dstring.h:913
size_t updateColumnCount(const char *s, size_t col)
Definition outputgen.cpp:58
OutputCodeDefer< DocbookCodeGenerator > DocbookCodeGeneratorDefer
Definition outputlist.h:103
CodeSymbolType
Definition types.h:481
DString stripExtensionGeneral(const DString &fName, const DString &ext)
Definition util.cpp:3945
void clearSubDirs(const Dir &d)
Definition util.cpp:2996
void createSubDirs(const Dir &d)
Definition util.cpp:2969
DString relativePathToRoot(const DString &name)
Definition util.cpp:2912
DString stripPath(const DString &s)
Definition util.cpp:3960
A bunch of utility functions.