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) QCString __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 QCString &s)
78{
79 t << convertToDocBook(s);
80}
81
82inline void writeDocbookCodeString(bool hide,TextStream &t,const QCString &str, size_t &col, size_t stripIndentAmount)
83{
84 if (str.isEmpty()) 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, QCString prim, QCString sec = "")
138{
139 t << "<indexterm><primary>";
140 t << convertToDocBook(prim);
141 t << "</primary>";
142 if (!sec.isEmpty())
143 {
144 t << "<secondary>";
145 t << convertToDocBook(sec);
146 t << "</secondary>";
147 }
148 t << "</indexterm>\n";
149}
150void writeDocbookLink(TextStream &t,const QCString & /*extRef*/,const QCString &compoundId,
151 const QCString &anchorId,const QCString & text,const QCString & /*tooltip*/)
152{
153 t << "<link linkend=\"_" << stripPath(compoundId);
154 if (!anchorId.isEmpty()) 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 QCString &ref,const QCString &file,
193 const QCString &anchor,const QCString &name,
194 const QCString &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 QCString &,const QCString &file,
204 const QCString &,const QCString &name,
205 const QCString &,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 QCString &, const SourceLinkInfo &, const SourceLinkInfo &
219 )
220{
221 Docbook_DB(("(writeToolTip)\n"));
222}
223
225{
226 if (m_hide) return;
227 Docbook_DB(("(startCodeLine)\n"));
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();
239 m_external.clear();
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
257}
258
260{
261 Docbook_DB(("(writeCodeAnchor)\n"));
262}
263
265 const QCString &anchor,int l,bool writeLineAnchor)
266{
267 if (m_hide) return;
268 Docbook_DB(("(writeLineNumber)\n"));
270 if (Config_getBool(SOURCE_BROWSER))
271 {
272 QCString lineNumber;
273 lineNumber.sprintf("%05d",l);
274
275 if (!m_sourceFileName.isEmpty())
276 {
277 writeCodeLinkLine(CodeSymbolType::Default,ref,m_sourceFileName,anchor,lineNumber,QCString(),writeLineAnchor);
278 }
279 if (!fileName.isEmpty())
280 {
281 writeCodeLink(CodeSymbolType::Default,ref,fileName,anchor,lineNumber,QCString());
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
347{
348 if (this!=&og)
349 {
350 m_dir = og.m_dir;
351 m_codeList = std::make_unique<OutputCodeList>(*og.m_codeList);
353 m_codeGen->setTextStream(&m_t);
355 m_inGroup = og.m_inGroup;
361 m_inLevel = og.m_inLevel;
364 }
365 return *this;
366}
367
369
374
376{
377 QCString 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 QCString dname = Config_getString(DOCBOOK_OUTPUT);
389 Dir d(dname.str());
390 clearSubDirs(d);
391}
392
393
394void DocbookGenerator::startFile(const QCString &name,bool,const QCString &,const QCString &,int,int)
395{
397 QCString fileName=name;
398 QCString pageName;
399 QCString 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";
414 m_codeGen->setRelativePath(relPath);
415 m_codeGen->setSourceFileName(stripPath(fileName));
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.isEmpty()) m_t << " xml:id=\"_" << stripPath(pageName) << "\"";
421 m_t << " xml:lang=\"" << theTranslator->trISOLang() << "\"";
422 m_t << ">\n";
423}
424
426{
429 m_inLevel = -1;
431
432 // Write page links only after all sections have been closed to avoid bugs
433 m_t << m_pageLinks;
434
435 QCString fileType="section";
436 QCString fileName= m_codeGen->sourceFileName();
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();
447 m_codeGen->setSourceFileName("");
448}
449
451{
452DB_GEN_C2("IndexSection " << is)
453 switch (is)
454 {
456 {
457 QCString 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(QCString("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 QCString &name, bool first)
716{
718 QCString 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}
774 const QCString &anchor, const QCString &text)
775{
777 QCString result;
778 if (!anchor.isEmpty())
779 {
780 if (!f.isEmpty()) result += "<link linkend=\"_" + stripPath(f) + "_1" + anchor + "\">";
781 else result += "<link linkend=\"_" + anchor + "\">";
782 }
783 else
784 {
785 result += "<link linkend=\"_" + stripPath(f) + "\">";
786 }
787 result += convertToDocBook(text);
788 result += "</link>";
789 return result;
790}
792 const QCString &anchor, const QCString &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 QCString &,int extraIndentLevel)
836{
837DB_GEN_C2("m_inLevel " << m_inLevel)
838DB_GEN_C2("extraIndentLevel " << extraIndentLevel)
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();
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 {
897 m_t << "<programlisting linenumbering=\"unnumbered\">";
898 }
899}
901{
903 if (m_denseText)
904 {
906 m_t << "</programlisting>";
907 }
908}
909void DocbookGenerator::startMemberDoc(const QCString &clname, const QCString &memname, const QCString &, const QCString &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.isEmpty() && 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.isEmpty()) addIndexTerm(m_t, name);
941}
943 const QCString &anchor,const QCString &,
944 const QCString &)
945{
948 {
951 }
952 if (!anchor.isEmpty())
953 {
954 m_t << "<anchor xml:id=\"_" << stripPath(fName) << "_1" << anchor << "\"/>";
955 }
956}
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";
1009 m_t << " </mediaobject>\n";
1010 m_t << " </informalfigure>\n";
1011 m_t << "</para>\n";
1012}
1017
1018void DocbookGenerator::writeLabel(const QCString &l,bool isLast)
1019{
1021 m_t << "<computeroutput>[" << l << "]</computeroutput>";
1022 if (!isLast) m_t << ", ";
1023}
1024
1030{
1032 m_t << "<simplesect><title>";
1033 docify(theTranslator->trExamples());
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.isEmpty())
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 QCString title;
1157 if (isEnum)
1158 {
1159 ncols = 2;
1160 title = theTranslator->trEnumerationValues();
1161 }
1162 else
1163 {
1164 ncols = 3;
1165 title = theTranslator->trCompoundMembers();
1166 }
1167 m_t << "<table frame=\"all\">\n";
1168 if (!title.isEmpty()) 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 QCString &title,const bool hasInits)
1224{
1226 int ncols = (hasInits?3:2);
1227 m_t << "<informaltable frame=\"all\">\n";
1228 if (!title.isEmpty()) 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";
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}
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.isEmpty()) 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 QCString &/*id*/,const QCString &ref,
1410 const QCString &file, const QCString &anchor,
1411 const QCString &title, const QCString &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{
1428 if (m_tocState.level > m_tocState.maxLevel) m_tocState.level = m_tocState.maxLevel;
1429 while (m_tocState.level>1 && m_tocState.level <= m_tocState.maxLevel)
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 QCString 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 */
1484QCString convertToDocBook(const QCString &s, const bool retainNewline)
1485{
1486 if (s.isEmpty()) return s;
1487 QCString result;
1488 result.reserve(s.length()+32);
1489 const char *p = s.data();
1490 const char *q = nullptr;
1491 int cnt = 0;
1492 char c = 0;
1493 while ((c=*p++))
1494 {
1495 switch (c)
1496 {
1497 case '\n':
1498 if (retainNewline) result+="<literallayout>&#160;&#xa;</literallayout>";
1499 result+=c;
1500 break;
1501 case '<': result+="&lt;"; break;
1502 case '>': result+="&gt;"; break;
1503 case '&': // possibility to have a special symbol
1504 q = p;
1505 cnt = 2; // we have to count & and ; as well
1506 while ((*q >= 'a' && *q <= 'z') || (*q >= 'A' && *q <= 'Z') || (*q >= '0' && *q <= '9'))
1507 {
1508 cnt++;
1509 q++;
1510 }
1511 if (*q == ';')
1512 {
1513 --p; // we need & as well
1516 {
1517 p++;
1518 result+="&amp;";
1519 }
1520 else
1521 {
1522 result+=HtmlEntityMapper::instance().docbook(res);
1523 q++;
1524 p = q;
1525 }
1526 }
1527 else
1528 {
1529 result+="&amp;";
1530 }
1531 break;
1532 case '\'': result+="&apos;"; break;
1533 case '"': result+="&quot;"; break;
1534 case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
1535 case 11: case 12: case 14: case 15: case 16: case 17: case 18:
1536 case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26:
1537 case 27: case 28: case 29: case 30: case 31:
1538 result+="&#x24";
1539 result+=hex[static_cast<uint8_t>(c)>>4];
1540 result+=hex[static_cast<uint8_t>(c)&0xF];
1541 result+=';';
1542 break;
1543 default:
1544 result+=c;
1545 break;
1546 }
1547 }
1548 return result;
1549}
1550
constexpr auto prefix
Definition anchor.cpp:44
Class representing a built-in class diagram.
Definition diagram.h:31
void writeImage(TextStream &t, const QCString &path, const QCString &relPath, const QCString &file, bool generateMap=true) const
Definition diagram.cpp:1361
The common base class of all entity definitions found in the sources.
Definition definition.h:76
virtual QCString 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:1466
void endFontClass() override
void endCodeFragment(const QCString &style) override
DocbookCodeGenerator(TextStream *t)
TextStream * m_t
Definition docbookgen.h:89
void stripCodeComments(bool b) override
void writeCodeAnchor(const QCString &) override
void writeCodeLink(CodeSymbolType type, const QCString &ref, const QCString &file, const QCString &anchor, const QCString &name, const QCString &tooltip) override
void startSpecialComment() override
void endCodeLine() override
void endSpecialComment() override
void codify(const QCString &text) override
void writeCodeLinkLine(CodeSymbolType type, const QCString &ref, const QCString &file, const QCString &anchor, const QCString &name, const QCString &tooltip, bool)
void startCodeLine(int) override
void setStripIndentAmount(size_t amount) override
void startFontClass(const QCString &colorClass) override
void writeTooltip(const QCString &, const DocLinkInfo &, const QCString &, const QCString &, const SourceLinkInfo &, const SourceLinkInfo &) override
void writeLineNumber(const QCString &extRef, const QCString &compId, const QCString &anchorId, int l, bool writeLineAnchor) override
QCString m_sourceFileName
Definition docbookgen.h:97
void startCodeFragment(const QCString &style) override
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 exceptionEntry(const QCString &, bool) override
void startMemberHeader(const QCString &anchor, int typ) override
void endDescTableRow() override
void lineBreak(const QCString &) override
void startDescTableData() override
void startIndexSection(IndexSection) override
void writeNonBreakableSpace(int) override
std::unique_ptr< OutputCodeList > m_codeList
Definition docbookgen.h:329
void startGroupCollaboration() override
void endMemberGroup(bool) override
void startParagraph(const QCString &) override
void startFile(const QCString &name, bool isSource, const QCString &manName, const QCString &title, int id, int hierarchyLevel) override
void cleanup() override
void endClassDiagram(const ClassDiagram &, const QCString &, const QCString &) override
void startParameterExtra() override
void endMemberItem(MemberItemType) override
void endLabels() override
void endPlainFile() override
Definition docbookgen.h:321
void endTypewriter() override
void endMemberGroupHeader() override
void endConstraintType() override
void writeLabel(const QCString &, bool) override
DocbookCodeGenerator * m_codeGen
Definition docbookgen.h:330
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 endDotGraph(DotClassGraph &g) override
void endConstraintDocs() override
void endDescTableTitle() override
void startConstraintParam() override
void writePageLink(const QCString &, bool) override
void endCompoundTemplateParams() override
void startConstraintList(const QCString &) override
void startTypewriter() override
void startMemberTemplateParams() override
TocState m_tocState
Definition docbookgen.h:349
void endGroupCollaboration(DotGroupCollaboration &g) override
void endTextBlock(bool) override
void endInlineMemberDoc() override
void endMemberHeader() override
void startMemberDocList() override
void endLocalToc() override
OutputType type() const override
Definition docbookgen.h:120
void writeObjectLink(const QCString &, const QCString &, const QCString &, const QCString &) override
void startLabels() override
void endMemberDocPrefixItem() override
void startMemberItem(const QCString &, MemberItemType, const QCString &) override
void startParameterName(bool) override
void endParameterDefVal() override
std::array< bool, 20 > m_inSimpleSect
Definition docbookgen.h:335
void startMemberDoc(const QCString &, const QCString &, const QCString &, const QCString &, int, int, bool) override
void startTitleHead(const QCString &) override
void startMemberDocName(bool) override
void endDescTableData() override
void openSection(const QCString &attr=QCString())
void startDirDepGraph() override
void endIndexSection(IndexSection) override
void startCompoundTemplateParams() override
void startMemberGroup() override
void endParagraph() override
void startClassDiagram() override
void startSection(const QCString &, const QCString &, SectionType) override
void endParameterName() override
void endMemberTemplateParams(const QCString &, const QCString &) override
void startMemberDocPrefixItem() override
void startDescTableInit() override
void startMemberList() override
void endDirDepGraph(DotDirDeps &g) override
void addIndexItem(const QCString &, const QCString &) override
void startExamples() override
void endCallGraph(DotCallGraph &g) override
void endDoxyAnchor(const QCString &fileName, const QCString &anchor) override
void writeString(const QCString &) override
void startDoxyAnchor(const QCString &fName, const QCString &manName, const QCString &anchor, const QCString &name, const QCString &args) override
void endMemberDoc(bool) override
void startDescTableRow() override
void startInclDepGraph() override
void startDotGraph() override
DocbookGenerator & operator=(const DocbookGenerator &)
void addLabel(const QCString &, const QCString &) override
void endSection(const QCString &, SectionType) override
void endBold() override
void startGroupHeader(const QCString &, int) override
void startInlineMemberType() override
void startBold() override
void endTitleHead(const QCString &fileName, const QCString &name) override
void endMemberDocList() override
void startDescTableTitle() override
void endGroupHeader(int) override
void startInlineMemberDoc() override
void startConstraintDocs() override
std::array< bool, 20 > m_inListItem
Definition docbookgen.h:334
void endMemberList() override
void endParameterList() override
void endParameterExtra(bool, bool, bool) override
void docify(const QCString &text) 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 startPlainFile(const QCString &name) override
Definition docbookgen.h:320
static void init()
void writeInheritedSectionTitle(const QCString &, const QCString &, const QCString &, const QCString &, const QCString &, const QCString &) override
void startInlineMemberName() override
void endInclDepGraph(DotInclDepGraph &g) override
void startDescTable(const QCString &title, const bool hasInits) override
void writeChar(char) override
void endExamples() override
void startMemberGroupHeader(const QCString &, bool) override
void endConstraintList() override
QCString m_pageLinks
Definition docbookgen.h:341
Representation of an call graph.
QCString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)
Representation of a class inheritance or dependency graph.
QCString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool TBRank=TRUE, bool imageMap=TRUE, int graphId=-1)
Representation of an directory dependency graph.
Definition dotdirdeps.h:26
QCString writeGraph(TextStream &out, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1, bool linkRelations=TRUE)
Representation of a group collaboration graph.
QCString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)
Representation of an include dependency graph.
QCString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)
static NamespaceLinkedMap * namespaceLinkedMap
Definition doxygen.h:114
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:128
static GroupLinkedMap * groupLinkedMap
Definition doxygen.h:113
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.
SymType name2sym(const QCString &symName) const
Give code of the requested HTML entity name.
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
QCString dir() const
Definition outputgen.cpp:52
QCString m_dir
Definition outputgen.h:117
TextStream m_t
Definition outputgen.h:116
QCString fileName() const
Definition outputgen.cpp:57
This is an alternative implementation of QCString.
Definition qcstring.h:101
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
const std::string & str() const
Definition qcstring.h:552
void reserve(size_t size)
Reserve space for size bytes without changing the string contents.
Definition qcstring.h:185
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:172
class that provide information about a section.
Definition section.h:57
QCString label() const
Definition section.h:68
SectionType type() const
Definition section.h:70
Text streaming class that buffers data.
Definition textstream.h:36
#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
static QCString objectLinkToString(const QCString &, const QCString &f, const QCString &anchor, const QCString &text)
void writeDocbookCodeString(bool hide, TextStream &t, const QCString &str, size_t &col, size_t stripIndentAmount)
void writeDocbookString(TextStream &t, const QCString &s)
#define Docbook_DB(x)
void writeDocbookLink(TextStream &t, const QCString &, const QCString &compoundId, const QCString &anchorId, const QCString &text, const QCString &)
QCString convertToDocBook(const QCString &s, const bool retainNewline)
#define DB_GEN_C
#define DB_GEN_C1(x)
static void addIndexTerm(TextStream &t, QCString prim, QCString sec="")
#define DB_GEN_C2(y)
QCString convertToDocBook(const QCString &s, const bool retainNewline=false)
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
OutputCodeDefer< DocbookCodeGenerator > DocbookCodeGeneratorDefer
Definition outputlist.h:106
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
CodeSymbolType
Definition types.h:481
size_t updateColumnCount(const char *s, size_t col)
Definition util.cpp:6830
QCString stripPath(const QCString &s)
Definition util.cpp:4890
QCString relativePathToRoot(const QCString &name)
Definition util.cpp:3521
void clearSubDirs(const Dir &d)
Definition util.cpp:3609
QCString stripExtensionGeneral(const QCString &fName, const QCString &ext)
Definition util.cpp:4875
void createSubDirs(const Dir &d)
Definition util.cpp:3582
A bunch of utility functions.