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#include <stdlib.h>
19
20#include "docbookgen.h"
21#include "doxygen.h"
22#include "message.h"
23#include "config.h"
24#include "classlist.h"
25#include "classdef.h"
26#include "diagram.h"
27#include "util.h"
28#include "defargs.h"
29#include "outputgen.h"
30#include "dot.h"
31#include "dotcallgraph.h"
32#include "dotclassgraph.h"
33#include "dotdirdeps.h"
35#include "dotincldepgraph.h"
36#include "pagedef.h"
37#include "filename.h"
38#include "version.h"
39#include "docbookvisitor.h"
40#include "docparser.h"
41#include "language.h"
42#include "parserintf.h"
43#include "arguments.h"
44#include "memberlist.h"
45#include "groupdef.h"
46#include "memberdef.h"
47#include "namespacedef.h"
48#include "membername.h"
49#include "membergroup.h"
50#include "dirdef.h"
51#include "section.h"
52#include "dir.h"
53#include "outputlist.h"
54#include "moduledef.h"
55
56// no debug info
57#define Docbook_DB(x) do {} while(0)
58// debug to stdout
59//#define Docbook_DB(x) printf x
60// debug inside output
61//#define Docbook_DB(x) DString __t;__t.sprintf x;m_t << __t
62
63#if 0
64#define DB_GEN_C DB_GEN_C1(m_t)
65#define DB_GEN_C1(x) x << "<!-- DB_GEN_C " << __LINE__ << " -->\n";
66#define DB_GEN_C2(y) DB_GEN_C2a(m_t,y)
67#define DB_GEN_C2a(x,y) x << "<!-- DB_GEN_C " << __LINE__ << " " << y << " -->\n";
68#else
69#define DB_GEN_C
70#define DB_GEN_C1(x)
71#define DB_GEN_C2(y)
72#define DB_GEN_C2a(x,y)
73#endif
74
75//------------------
76
77inline void writeDocbookString(TextStream &t,const DString &s)
78{
80}
81
82inline void writeDocbookCodeString(bool hide,TextStream &t,const DString &str, size_t &col, size_t stripIndentAmount)
83{
84 if (str.empty()) return;
85 const int tabSize = Config_getInt(TAB_SIZE);
86 const char *s = str.data();
87 char c=0;
88 if (hide)
89 {
90 col = updateColumnCount(s,col);
91 }
92 else
93 {
94 while ((c=*s++))
95 {
96 switch(c)
97 {
98 case '\t':
99 {
100 int spacesToNextTabStop = tabSize - (col%tabSize);
101 while (spacesToNextTabStop--)
102 {
103 if (col>=stripIndentAmount) t << "&#32;";
104 col++;
105 }
106 break;
107 }
108 case ' ':
109 if (col>=stripIndentAmount) t << "&#32;";
110 col++;
111 break;
112 case '<': t << "&lt;"; col++; break;
113 case '>': t << "&gt;"; col++; break;
114 case '&': t << "&amp;"; col++; break;
115 case '\'': t << "&apos;"; col++; break;
116 case '"': t << "&quot;"; col++; break;
117 default:
118 {
119 uint8_t uc = static_cast<uint8_t>(c);
120 static const char *hex="0123456789ABCDEF";
121 if (uc<32)
122 {
123 t << "&#x24" << hex[uc>>4] << hex[uc&0xF] << ";";
124 }
125 else
126 {
127 t << c;
128 }
129 col++;
130 }
131 break;
132 }
133 }
134 }
135}
136
137static void addIndexTerm(TextStream &t, DString prim, DString sec = "")
138{
139 t << "<indexterm><primary>";
141 t << "</primary>";
142 if (!sec.empty())
143 {
144 t << "<secondary>";
146 t << "</secondary>";
147 }
148 t << "</indexterm>\n";
149}
150void writeDocbookLink(TextStream &t,const DString & /*extRef*/,const DString &compoundId,
151 const DString &anchorId,const DString & text,const DString & /*tooltip*/)
152{
153 t << "<link linkend=\"_" << stripPath(compoundId);
154 if (!anchorId.empty()) t << "_1" << anchorId;
155 t << "\"";
156 t << ">";
157 writeDocbookString(t,text);
158 t << "</link>";
159}
160
164
166{
167 Docbook_DB(("(codify \"%s\")\n",text));
168 writeDocbookCodeString(m_hide,*m_t,text,m_col,static_cast<size_t>(m_stripIndentAmount));
169}
170
175
180
185
187{
188 m_stripIndentAmount = amount;
189}
190
192 const DString &ref,const DString &file,
193 const DString &anchor,const DString &name,
194 const DString &tooltip)
195{
196 if (m_hide) return;
197 Docbook_DB(("(writeCodeLink)\n"));
198 writeDocbookLink(*m_t,ref,file,anchor,name,tooltip);
199 m_col+=name.length();
200}
201
203 const DString &,const DString &file,
204 const DString &,const DString &name,
205 const DString &,bool writeLineAnchor)
206{
207 if (m_hide) return;
208 Docbook_DB(("(writeCodeLinkLine)\n"));
209 if (!writeLineAnchor) return;
210 *m_t << "<anchor xml:id=\"_" << stripExtensionGeneral(stripPath(file),".xml");
211 *m_t << "_1l";
212 writeDocbookString(*m_t,name);
213 *m_t << "\"/>";
214 m_col+=name.length();
215}
216
218 const DString &, const SourceLinkInfo &, const SourceLinkInfo &
219 )
220{
221 Docbook_DB(("(writeToolTip)\n"));
222}
223
225{
226 if (m_hide) return;
227 Docbook_DB(("(startCodeLine)\n"));
228 m_insideCodeLine=true;
229 m_col=0;
230}
231
233{
234 if (m_hide) return;
235 if (m_insideCodeLine) *m_t << "\n";
236 Docbook_DB(("(endCodeLine)\n"));
237 m_lineNumber = -1;
238 m_refId.clear();
240 m_insideCodeLine=false;
241}
242
244{
245 if (m_hide) return;
246 Docbook_DB(("(startFontClass)\n"));
247 *m_t << "<emphasis role=\"" << colorClass << "\">";
249}
250
252{
253 if (m_hide) return;
254 Docbook_DB(("(endFontClass)\n"));
255 *m_t << "</emphasis>"; // non DocBook
256 m_insideSpecialHL=false;
257}
258
260{
261 Docbook_DB(("(writeCodeAnchor)\n"));
262}
263
265 const DString &anchor,int l,bool writeLineAnchor)
266{
267 if (m_hide) return;
268 Docbook_DB(("(writeLineNumber)\n"));
269 m_insideCodeLine = true;
270 if (Config_getBool(SOURCE_BROWSER))
271 {
272 DString lineNumber;
273 lineNumber.sprintf("%05d",l);
274
275 if (!m_sourceFileName.empty())
276 {
277 writeCodeLinkLine(CodeSymbolType::Default,ref,m_sourceFileName,anchor,lineNumber,DString(),writeLineAnchor);
278 }
279 if (!fileName.empty())
280 {
281 writeCodeLink(CodeSymbolType::Default,ref,fileName,anchor,lineNumber,DString());
282 }
283 else
284 {
285 codify(lineNumber);
286 }
287 *m_t << " ";
288 }
289 else
290 {
291 *m_t << l << " ";
292 }
293 m_col=0;
294}
295
300
302{
304 *m_t << "<programlisting linenumbering=\"unnumbered\">";
305}
306
308{
310 bool wasHidden = m_hide;
311 m_hide = false;
312 //endCodeLine checks is there is still an open code line, if so closes it.
313 endCodeLine();
314 m_hide = wasHidden;
315
316 *m_t << "</programlisting>";
317}
318
319//-------------------------------------------------------------------------------
320
328
345
367
369
374
376{
377 DString dir=Config_getString(DOCBOOK_OUTPUT);
378 Dir d(dir.str());
379 if (!d.exists() && !d.mkdir(dir.str()))
380 {
381 term("Could not create output directory {}\n",dir);
382 }
383
384 createSubDirs(d);
385}
387{
388 DString dname = Config_getString(DOCBOOK_OUTPUT);
389 Dir d(dname.str());
390 clearSubDirs(d);
391}
392
393
394void DocbookGenerator::startFile(const DString &name,bool,const DString &,const DString &,int,int)
395{
397 DString fileName=name;
398 DString pageName;
399 DString fileType="section";
400 if (fileName == "refman")
401 {
402 fileName="index";
403 fileType="book";
404 }
405 else if (fileName == "index")
406 {
407 fileName="mainpage";
408 fileType="chapter";
409 }
410 pageName = fileName;
412 if (!fileName.endsWith(".xml")) fileName+=".xml";
417
418 m_t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n";
419 m_t << "<" << fileType << " xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"";
420 if (!pageName.empty()) m_t << " xml:id=\"_" << stripPath(pageName) << "\"";
421 m_t << " xml:lang=\"" << theTranslator->trISOLang() << "\"";
422 m_t << ">\n";
423}
424
426{
429 m_inLevel = -1;
430 m_inGroup = false;
431
432 // Write page links only after all sections have been closed to avoid bugs
433 m_t << m_pageLinks;
434
435 DString fileType="section";
437 if (fileName == "index.xml")
438 {
439 fileType="book";
440 }
441 else if (fileName == "mainpage.xml")
442 {
443 fileType="chapter";
444 }
445 m_t << "</" << fileType << ">\n";
446 endPlainFile();
448}
449
451{
452DB_GEN_C2("IndexSection " << is)
453 switch (is)
454 {
456 {
457 DString dbk_projectName = Config_getString(PROJECT_NAME);
458 m_t << " <info>\n";
459 m_t << " <title>" << convertToDocbook(dbk_projectName) << "</title>\n";
460 m_t << " </info>\n";
461 }
462 break;
464 break;
466 break;
468 //Module Index\n"
469 break;
471 //Module Index\n"
472 break;
474 //Directory Index\n"
475 break;
477 //Namespace Index\n"
478 break;
480 //Concept Index\n"
481 break;
483 //Hierarchical Index\n"
484 break;
486 //m_t << "{"; //Class Index}\n"
487 break;
489 //Annotated File Index\n"
490 break;
492 //Annotated Page Index\n"
493 break;
495 m_t << "<chapter>\n";
496 m_t << " <title>";
497 break;
499 m_t << "<chapter>\n";
500 m_t << " <title>";
501 break;
503 m_t << "<chapter>\n";
504 m_t << " <title>";
505 break;
507 m_t << "<chapter>\n";
508 m_t << " <title>";
509 break;
511 m_t << "<chapter>\n";
512 m_t << " <title>";
513 break;
515 m_t << "<chapter>\n";
516 m_t << " <title>";
517 break;
519 m_t << "<chapter>\n";
520 m_t << " <title>";
521 break;
523 m_t << "<chapter>\n";
524 m_t << " <title>";
525 break;
527 break;
529 break;
531 break;
532 }
533}
534
536{
537DB_GEN_C2("IndexSection " << is)
538 switch (is)
539 {
541 break;
543 break;
545 {
547 {
548 writePageLink(DString("mainpage"), true);
549 }
550 }
551 break;
553 //m_t << "</chapter>\n";
554 break;
556 //m_t << "</chapter>\n";
557 break;
559 //m_t << "<xi:include href=\"dirs.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
560 //m_t << "</chapter>\n";
561 break;
563 //m_t << "<xi:include href=\"namespaces.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
564 //m_t << "</chapter>\n";
565 break;
567 //m_t << "<xi:include href=\"concepts.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
568 //m_t << "</chapter>\n";
569 break;
571 //m_t << "<xi:include href=\"hierarchy.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
572 //m_t << "</chapter>\n";
573 break;
575 //m_t << "</chapter>\n";
576 break;
578 //m_t << "<xi:include href=\"files.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
579 //m_t << "</chapter>\n";
580 break;
582 //m_t << "<xi:include href=\"pages.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
583 //m_t << "</chapter>\n";
584 break;
586 {
587 m_t << "</title>\n";
588 for (const auto &gd : *Doxygen::groupLinkedMap)
589 {
590 if (!gd->isReference() && !gd->isASubGroup())
591 {
592 writePageLink(gd->getOutputFileBase(), true);
593 }
594 }
595 }
596 m_t << "</chapter>\n";
597 break;
599 {
600 m_t << "</title>\n";
601 for (const auto &mod : ModuleManager::instance().modules())
602 {
603 if (!mod->isReference() && mod->isPrimaryInterface())
604 {
605 writePageLink(mod->getOutputFileBase(), true);
606 }
607 }
608 }
609 m_t << "</chapter>\n";
610 break;
611 break;
613 {
614 m_t << "</title>\n";
615 for (const auto &dd : *Doxygen::dirLinkedMap)
616 {
617 if (dd->isLinkableInProject())
618 {
619 m_t << " <xi:include href=\"" << dd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
620 }
621 }
622 }
623 m_t << "</chapter>\n";
624 break;
626 {
627 m_t << "</title>\n";
628 for (const auto &nd : *Doxygen::namespaceLinkedMap)
629 {
630 if (nd->isLinkableInProject() && !nd->isAlias())
631 {
632 m_t << " <xi:include href=\"" << nd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
633 }
634 }
635 }
636 m_t << "</chapter>\n";
637 break;
639 {
640 m_t << "</title>\n";
641 for (const auto &cd : *Doxygen::conceptLinkedMap)
642 {
643 if (cd->isLinkableInProject() && !cd->isAlias())
644 {
645 m_t << " <xi:include href=\"" << cd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
646 }
647 }
648 }
649 m_t << "</chapter>\n";
650 break;
652 {
653 m_t << "</title>\n";
654 for (const auto &cd : *Doxygen::classLinkedMap)
655 {
656 if (cd->isLinkableInProject() &&
657 !cd->isImplicitTemplateInstance() &&
658 !cd->isEmbeddedInOuterScope() &&
659 !cd->isAlias()
660 )
661 {
662 m_t << " <xi:include href=\"" << cd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
663 }
664 }
665 }
666 m_t << "</chapter>\n";
667 break;
669 {
670 m_t << "</title>\n";
671 for (const auto &fn : *Doxygen::inputNameLinkedMap)
672 {
673 for (const auto &fd : *fn)
674 {
675 if (fd->isLinkableInProject())
676 {
677 m_t << " <xi:include href=\"" << fd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
678 }
679 if (fd->generateSourceFile())
680 {
681 m_t << " <xi:include href=\"" << fd->getSourceFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
682 }
683 }
684 }
685 }
686 m_t << "</chapter>\n";
687 break;
689 {
690 m_t << "</title>\n";
691 for (const auto &pd : *Doxygen::exampleLinkedMap)
692 {
693 m_t << " <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
694 }
695 }
696 m_t << "</chapter>\n";
697 break;
699 for (const auto &pd : *Doxygen::pageLinkedMap)
700 {
701 if (!pd->getGroupDef() && !pd->isReference() && !pd->hasParentPage()
702 && Doxygen::mainPage.get() != pd.get())
703 {
704 writePageLink(pd->getOutputFileBase(), true);
705 }
706 }
707 break;
709 break;
711 m_t << "<index/>\n";
712 break;
713 }
714}
715void DocbookGenerator::writePageLink(const DString &name, bool first)
716{
718 DString link;
719 link.sprintf(" <xi:include href=\"%s.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n",
720 name.data());
721 if (first)
722 m_t << link;
723 else
724 // Buffer page links and write them after all sections are closed
725 m_pageLinks += link;
726}
727
728void DocbookGenerator::writeDoc(const IDocNodeAST *ast,const Definition *ctx,const MemberDef *,int,int sectionLevel)
729{
731 auto astImpl = dynamic_cast<const DocNodeAST*>(ast);
732 if (astImpl && sectionLevel<=m_tocState.maxLevel)
733 {
735 std::visit(visitor,astImpl->root);
736 }
737}
738
740{
742 m_t << "<para>\n";
743}
744
746{
748 m_t << "</para>\n";
749}
751{
753 m_t << text;
754}
756{
758 m_t << "<simplesect>\n";
760 m_t << " <title>";
761}
762
764{
766 m_t << " </title>\n";
767}
769{
771 m_t << convertToDocbook(str);
772}
773static DString objectLinkToString(const DString &, const DString &f,
774 const DString &anchor, const DString &text)
775{
777 DString result;
778 if (!anchor.empty())
779 {
780 if (!f.empty()) result += "<link linkend=\"_" + stripPath(f) + "_1" + anchor + "\">";
781 else result += "<link linkend=\"_" + anchor + "\">";
782 }
783 else
784 {
785 result += "<link linkend=\"_" + stripPath(f) + "\">";
786 }
788 result += "</link>";
789 return result;
790}
792 const DString &anchor, const DString &text)
793{
795 m_t << objectLinkToString(ref,f,anchor,text);
796}
798{
800 m_t << " <itemizedlist>\n";
802}
804{
806 if (m_inListItem[m_levelListItem]) m_t << "</listitem>\n";
808 m_t << " </itemizedlist>\n";
810 if (m_inSimpleSect[m_levelListItem]) m_t << "</simplesect>\n";
812}
814{
816 if (m_inListItem[m_levelListItem]) m_t << "</listitem>\n";
817 m_t << " <listitem><para>";
819}
821{
823 m_t << "</para>\n";
824}
826{
828 m_t << "<emphasis role=\"strong\">";
829}
831{
833 m_t << "</emphasis>";
834}
835void DocbookGenerator::startGroupHeader(const DString &,int extraIndentLevel)
836{
837DB_GEN_C2("m_inLevel " << m_inLevel)
838DB_GEN_C2("extraIndentLevel " << extraIndentLevel)
839 m_firstMember = true;
840 if (m_inSimpleSect[m_levelListItem]) m_t << "</simplesect>\n";
842 if (m_inLevel != -1) m_inGroup = true;
843 if (m_inLevel == extraIndentLevel) closeSection();
844 m_inLevel = extraIndentLevel;
845 openSection();
846 m_t << "<title>";
847}
849{
850DB_GEN_C2("m_inLevel " << m_inLevel)
851DB_GEN_C2("m_inGroup " << m_inGroup)
852 if (m_inGroup) closeSection();
853 m_inGroup = false;
854}
855
857{
859 m_t << "</title>\n";
860}
861
863{
865 if (openBracket) m_t << "(";
866}
872{
874 for (int i=0;i<n;i++) m_t << "&#160;";
875}
877{
879 m_t << "<?linebreak?>";
880}
882{
884 if (!m_denseText) m_t << "<computeroutput>";
885}
887{
889 if (!m_denseText) m_t << "</computeroutput>\n";
890}
892{
894 if (dense)
895 {
896 m_denseText = true;
897 m_t << "<programlisting linenumbering=\"unnumbered\">";
898 }
899}
901{
903 if (m_denseText)
904 {
905 m_denseText = false;
906 m_t << "</programlisting>";
907 }
908}
909void DocbookGenerator::startMemberDoc(const DString &clname, const DString &memname, const DString &, const DString &title,
910 int memCount, int memTotal, bool)
911{
912DB_GEN_C2("m_inLevel " << m_inLevel)
913 openSection();
914 m_t << " <title>" << convertToDocbook(title);
915 if (memTotal>1)
916 {
917 m_t << "<computeroutput>[" << memCount << "/" << memTotal << "]</computeroutput>";
918 }
919 m_t << "</title>\n";
920 if (!memname.empty() && memname[0]!='@')
921 {
922 addIndexTerm(m_t,memname,clname);
923 addIndexTerm(m_t,clname,memname);
924 }
925}
927{
929 m_t << "</computeroutput></para>";
930}
932{
934 m_t << "<title>";
935}
937{
939 m_t << "</title>\n";
940 if (!name.empty()) addIndexTerm(m_t, name);
941}
943 const DString &anchor,const DString &,
944 const DString &)
945{
948 {
950 m_firstMember = false;
951 }
952 if (!anchor.empty())
953 {
954 m_t << "<anchor xml:id=\"_" << stripPath(fName) << "_1" << anchor << "\"/>";
955 }
956}
958{
960}
962{
964}
966{
968 m_t << "<para><computeroutput>";
969}
975{
977 m_t << "<simplesect><title>";
978}
980{
982 m_t << "</title>\n";
983}
989{
991 m_t << "</simplesect>\n";
992}
994{
996 m_t << "<para>";
997}
998
1000{
1002 m_t << " <informalfigure>\n";
1003 m_t << " <mediaobject>\n";
1004 m_t << " <imageobject>\n";
1005 m_t << " <imagedata width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\""
1006 << relPath << fileName << ".png\">" << "</imagedata>\n";
1007 m_t << " </imageobject>\n";
1008 d.writeImage(m_t,dir(),relPath,fileName,false,false);
1009 m_t << " </mediaobject>\n";
1010 m_t << " </informalfigure>\n";
1011 m_t << "</para>\n";
1012}
1017
1018void DocbookGenerator::writeLabel(const DString &l,bool isLast)
1019{
1021 m_t << "<computeroutput>[" << l << "]</computeroutput>";
1022 if (!isLast) m_t << ", ";
1023}
1024
1030{
1032 m_t << "<simplesect><title>";
1034 m_t << "</title>";
1035}
1036
1038{
1040 m_t << "</simplesect>\n";
1041}
1043{
1045 m_t << "<simplesect><title>";
1046}
1048{
1050 m_t << "</title></simplesect>\n";
1051}
1053{
1055 char cs[2];
1056 cs[0]=c;
1057 cs[1]=0;
1058 docify(cs);
1059}
1061{
1063 m_t << "<computeroutput>";
1064}
1066{
1068 m_t << "</computeroutput>";
1069}
1071{
1073 if (!prefix.empty())
1074 {
1075 m_t << " " << prefix << "(";
1076 }
1077 else if (closeBracket)
1078 {
1079 m_t << ")";
1080 }
1081 m_t << " ";
1082}
1083
1085{
1087 m_t << " ";
1088}
1089
1094
1099
1100void DocbookGenerator::endParameterExtra(bool last,bool /*emptyList*/,bool closeBracket)
1101{
1103 if (last && closeBracket)
1104 {
1105 m_t << ")";
1106 }
1107}
1108
1109
1111{
1113 m_t << sep;
1114 if (!m_denseText) m_t << "<computeroutput>";
1115}
1116
1118{
1120 if (!m_denseText) m_t << "</computeroutput>\n";
1121}
1122
1127
1129{
1131 m_t << "</para>";
1132 m_t << "<para>";
1133}
1135{
1137 openSection("xml:id=\"_" + stripPath(lab) + "\"");
1138 m_t << "<title>";
1139}
1141{
1143 m_t << "</title>";
1144 closeSection();
1145}
1147{
1149 addIndexTerm(m_t, prim, sec);
1150}
1151
1153{
1155 int ncols=0;
1156 DString title;
1157 if (isEnum)
1158 {
1159 ncols = 2;
1161 }
1162 else
1163 {
1164 ncols = 3;
1166 }
1167 m_t << "<table frame=\"all\">\n";
1168 if (!title.empty()) m_t << "<title>" << convertToDocbook(title) << "</title>\n";
1169 m_t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n";
1170 for (int i = 0; i < ncols; i++)
1171 {
1172 m_t << " <colspec colname='c" << i+1 << "'/>\n";
1173 }
1174 m_t << "<tbody>\n";
1175 m_simpleTable = true;
1176}
1177
1179{
1181 m_t << " </tbody>\n";
1182 m_t << " </tgroup>\n";
1183 m_t << "</table>\n";
1184 m_simpleTable = false;
1185}
1186
1188{
1190 m_t << "<row><entry>";
1191}
1192
1194{
1196 m_t << "</entry>";
1197}
1198
1200{
1202 m_t << "<entry>";
1203}
1204
1206{
1208 m_t << "</entry>";
1209}
1210
1212{
1214 m_t << "<entry>";
1215}
1216
1218{
1220 m_t << "</entry></row>\n";
1221}
1222
1223void DocbookGenerator::startDescTable(const DString &title,bool hasInits)
1224{
1226 int ncols = (hasInits?3:2);
1227 m_t << "<informaltable frame=\"all\">\n";
1228 if (!title.empty()) m_t << "<title>" << convertToDocbook(title) << "</title>\n";
1229 m_t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n";
1230 int i = 1;
1231 m_t << " <colspec colname='c" << i++ << "'/>\n";
1232 if (hasInits) m_t << " <colspec colname='c" << i++ << "' align='right'/>\n";
1233 m_t << " <colspec colname='c" << i++ << "'/>\n";
1234 m_t << "<tbody>\n";
1235 m_descTable = true;
1236}
1237
1239{
1241 m_t << " </tbody>\n";
1242 m_t << " </tgroup>\n";
1243 m_t << "</informaltable>\n";
1244 m_descTable = false;
1245}
1246
1248{
1250 m_t << "<row>";
1251 m_t << "<entry>";
1252}
1253
1255{
1257 m_t << "</row>";
1258}
1259
1264
1269
1271{
1273 m_t << "</entry><entry>";
1274}
1275
1280
1282{
1284 m_t << "</entry><entry>";
1285}
1286
1288{
1290 m_t << "</entry>";
1291}
1342{
1344 m_inGroup = true;
1345}
1347{
1349 m_t << "<simplesect><title>";
1350 docify(header);
1351 m_t << "</title>\n";
1352}
1354{
1356 m_t << "<para><emphasis role=\"strong\">";
1357}
1363{
1365 m_t << ":";
1366}
1368{
1370 m_t << "</emphasis></para>\n";
1371}
1381{
1383 m_t << "</simplesect>\n";
1384}
1385
1387{
1388 m_t << "<section";
1389 if (!attr.empty()) m_t << " " << attr;
1390 m_t << ">\n";
1392}
1393
1395{
1396 m_t << "</section>\n";
1398}
1399
1401{
1402 while (m_openSectionCount>0)
1403 {
1404 closeSection();
1405 }
1406}
1407
1409 const DString &/*id*/,const DString &ref,
1410 const DString &file, const DString &anchor,
1411 const DString &title, const DString &name)
1412{
1414 m_t << theTranslator->trInheritedFrom(convertToDocbook(title), objectLinkToString(ref, file, anchor, name));
1415}
1416
1418{
1419 m_tocState.level=1;
1420 m_tocState.maxLevel=level;
1421 m_tocState.inLi = BoolVector(level+1,false);
1422 m_t << " <toc>\n";
1423 m_t << " <title>" << theTranslator->trRTFTableOfContents() << "</title>\n";
1424}
1425
1427{
1430 {
1431 m_t << "</tocdiv>\n";
1432 m_tocState.level--;
1433 }
1434 m_t << " </toc>\n";
1435}
1436
1438{
1439 SectionType type = si->type();
1440 if (type.isSection())
1441 {
1442 //printf(" level=%d title=%s\n",level,qPrint(si->title));
1443 int nextLevel = type.level();
1444 if (nextLevel>m_tocState.level)
1445 {
1446 for (int l=m_tocState.level;l<nextLevel;l++)
1447 {
1448 if (l < m_tocState.maxLevel) m_t << " <tocdiv>\n";
1449 }
1450 }
1451 else if (nextLevel<m_tocState.level)
1452 {
1453 for (int l=m_tocState.level;l>nextLevel;l--)
1454 {
1455 m_tocState.inLi[l]=false;
1456 if (l <= m_tocState.maxLevel) m_t << " </tocdiv>\n";
1457 }
1458 }
1459 if (nextLevel <= m_tocState.maxLevel)
1460 {
1461 DString label = convertToDocbook(si->label());
1462 m_t << " <tocentry>";
1463 }
1464 }
1465}
1466
1468{
1469 SectionType type = si->type();
1470 int nextLevel = type.level();
1471 if (type.isSection() && nextLevel <= m_tocState.maxLevel)
1472 {
1473 m_t << "</tocentry>\n";
1474 m_tocState.inLi[nextLevel]=true;
1475 m_tocState.level = nextLevel;
1476 }
1477}
1478
1479//-------------------------------------------------------------------------------------------------
1480
1481static constexpr auto hex="0123456789ABCDEF";
1482
1483/*! Converts a string to an DocBook-encoded string */
1484DString DocbookGenerator::convertToDocbook(const DString &s, bool retainNewline, bool /* citeEntry */)
1485{
1486 if (s.empty()) return s;
1487 DString result;
1488 result.reserve(s.length()+32);
1489 const char *p = s.data();
1490 char c = 0;
1491 while ((c=*p++))
1492 {
1493 switch (c)
1494 {
1495 case '\n':
1496 if (retainNewline)
1497 {
1498 result+="<literallayout>&#160;&#xa;</literallayout>";
1499 result+=c;
1500 }
1501 break;
1502 case '<': result+="&lt;"; break;
1503 case '>': result+="&gt;"; break;
1504 case '&': // possibility to have a special symbol
1505 p = writeHtmlEntity(result, p-1, [](HtmlEntityMapper::SymType symType) { return HtmlEntityMapper::instance().docbook(symType); }, "&amp;");
1506 break;
1507 case '\'': result+="&apos;"; break;
1508 case '"': result+="&quot;"; break;
1509 case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
1510 case 11: case 12: case 14: case 15: case 16: case 17: case 18:
1511 case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26:
1512 case 27: case 28: case 29: case 30: case 31:
1513 result+="&#x24";
1514 result+=hex[static_cast<uint8_t>(c)>>4];
1515 result+=hex[static_cast<uint8_t>(c)&0xF];
1516 result+=';';
1517 break;
1518 default:
1519 result+=c;
1520 break;
1521 }
1522 }
1523 return result;
1524}
1525
constexpr auto prefix
Definition anchor.cpp:44
Class representing a built-in class diagram.
Definition diagram.h:31
void writeImage(TextStream &t, const DString &path, const DString &relPath, const DString &file, bool generateMap, bool toIndex) const
Definition diagram.cpp:1361
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:89
void clear()
Definition dstring.h:219
DString()=default
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:153
DString & sprintf(const char *format,...)
Definition dstring.cpp:29
void reserve(size_t size)
Reserve space for size bytes without changing the string contents.
Definition dstring.h:222
const std::string & str() const
Definition dstring.h:634
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:162
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:156
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:75
bool mkdir(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:295
bool exists() const
Definition dir.cpp:257
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:89
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:79
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:81
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:51
void setSourceFileName(const DString &sourceFileName)
Definition docbookgen.h:80
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:333
void startGroupCollaboration() override
DString m_pageLinks
Definition docbookgen.h:345
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:321
void endTypewriter() override
void endConstraintType() override
DocbookCodeGenerator * m_codeGen
Definition docbookgen.h:334
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:353
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:120
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:339
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:320
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:338
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:26
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:115
static ConceptLinkedMap * conceptLinkedMap
Definition doxygen.h:97
static std::unique_ptr< PageDef > mainPage
Definition doxygen.h:100
static FileNameLinkedMap * inputNameLinkedMap
Definition doxygen.h:104
static ClassLinkedMap * classLinkedMap
Definition doxygen.h:95
static PageLinkedMap * exampleLinkedMap
Definition doxygen.h:98
static PageLinkedMap * pageLinkedMap
Definition doxygen.h:99
static DirLinkedMap * dirLinkedMap
Definition doxygen.h:127
static GroupLinkedMap * groupLinkedMap
Definition doxygen.h:114
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:48
static ModuleManager & instance()
Class representing a list of different code generators.
Definition outputlist.h:165
void add(OutputCodeIntfPtr &&p)
Definition outputlist.h:195
Abstract interface for output generators.
Definition outputgen.h:127
DString dir() const
Definition outputgen.cpp:52
TextStream m_t
Definition outputgen.h:116
DString fileName() const
Definition outputgen.cpp:57
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:32
@ isMainPage
Definition index.h:35
@ isTitlePageAuthor
Definition index.h:34
@ isFileIndex
Definition index.h:43
@ isFileDocumentation
Definition index.h:51
@ isPageDocumentation
Definition index.h:53
@ isDirDocumentation
Definition index.h:47
@ isModuleDocumentation
Definition index.h:45
@ isClassHierarchyIndex
Definition index.h:41
@ isModuleIndex
Definition index.h:36
@ isTopicIndex
Definition index.h:37
@ isConceptIndex
Definition index.h:40
@ isExampleDocumentation
Definition index.h:52
@ isClassDocumentation
Definition index.h:49
@ isPageIndex
Definition index.h:44
@ isCompoundIndex
Definition index.h:42
@ isEndIndex
Definition index.h:55
@ isConceptDocumentation
Definition index.h:50
@ isDirIndex
Definition index.h:38
@ isNamespaceIndex
Definition index.h:39
@ isNamespaceDocumentation
Definition index.h:48
@ isTitlePageStart
Definition index.h:33
@ isTopicDocumentation
Definition index.h:46
@ isPageDocumentation2
Definition index.h:54
Translator * theTranslator
Definition language.cpp:71
#define term(fmt,...)
Definition message.h:137
Definition dstring.h:879
OutputCodeDefer< DocbookCodeGenerator > DocbookCodeGeneratorDefer
Definition outputlist.h:106
CodeSymbolType
Definition types.h:481
size_t updateColumnCount(const char *s, size_t col)
Definition util.cpp:6924
DString stripExtensionGeneral(const DString &fName, const DString &ext)
Definition util.cpp:4983
void clearSubDirs(const Dir &d)
Definition util.cpp:3710
void createSubDirs(const Dir &d)
Definition util.cpp:3683
DString relativePathToRoot(const DString &name)
Definition util.cpp:3626
const char * writeHtmlEntity(T &result, const char *s, HtmlEntityMapperFunc &&mapper, const char *fallback)
Definition util.cpp:7045
DString stripPath(const DString &s)
Definition util.cpp:4998
A bunch of utility functions.