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 "growbuf.h"
54#include "outputlist.h"
55#include "moduledef.h"
56
57// no debug info
58#define Docbook_DB(x) do {} while(0)
59// debug to stdout
60//#define Docbook_DB(x) printf x
61// debug inside output
62//#define Docbook_DB(x) QCString __t;__t.sprintf x;m_t << __t
63
64#if 0
65#define DB_GEN_C DB_GEN_C1(m_t)
66#define DB_GEN_C1(x) x << "<!-- DB_GEN_C " << __LINE__ << " -->\n";
67#define DB_GEN_C2(y) DB_GEN_C2a(m_t,y)
68#define DB_GEN_C2a(x,y) x << "<!-- DB_GEN_C " << __LINE__ << " " << y << " -->\n";
69#else
70#define DB_GEN_C
71#define DB_GEN_C1(x)
72#define DB_GEN_C2(y)
73#define DB_GEN_C2a(x,y)
74#endif
75
76//------------------
77
78inline void writeDocbookString(TextStream &t,const QCString &s)
79{
80 t << convertToDocBook(s);
81}
82
83inline void writeDocbookCodeString(bool hide,TextStream &t,const QCString &str, size_t &col, size_t stripIndentAmount)
84{
85 if (str.isEmpty()) return;
86 const int tabSize = Config_getInt(TAB_SIZE);
87 const char *s = str.data();
88 char c=0;
89 if (hide)
90 {
91 col = updateColumnCount(s,col);
92 }
93 else
94 {
95 while ((c=*s++))
96 {
97 switch(c)
98 {
99 case '\t':
100 {
101 int spacesToNextTabStop = tabSize - (col%tabSize);
102 while (spacesToNextTabStop--)
103 {
104 if (col>=stripIndentAmount) t << "&#32;";
105 col++;
106 }
107 break;
108 }
109 case ' ':
110 if (col>=stripIndentAmount) t << "&#32;";
111 col++;
112 break;
113 case '<': t << "&lt;"; col++; break;
114 case '>': t << "&gt;"; col++; break;
115 case '&': t << "&amp;"; col++; break;
116 case '\'': t << "&apos;"; col++; break;
117 case '"': t << "&quot;"; col++; break;
118 default:
119 {
120 uint8_t uc = static_cast<uint8_t>(c);
121 static const char *hex="0123456789ABCDEF";
122 if (uc<32)
123 {
124 t << "&#x24" << hex[uc>>4] << hex[uc&0xF] << ";";
125 }
126 else
127 {
128 t << c;
129 }
130 col++;
131 }
132 break;
133 }
134 }
135 }
136}
137
138static void addIndexTerm(TextStream &t, QCString prim, QCString sec = "")
139{
140 t << "<indexterm><primary>";
141 t << convertToDocBook(prim);
142 t << "</primary>";
143 if (!sec.isEmpty())
144 {
145 t << "<secondary>";
146 t << convertToDocBook(sec);
147 t << "</secondary>";
148 }
149 t << "</indexterm>\n";
150}
151void writeDocbookLink(TextStream &t,const QCString & /*extRef*/,const QCString &compoundId,
152 const QCString &anchorId,const QCString & text,const QCString & /*tooltip*/)
153{
154 t << "<link linkend=\"_" << stripPath(compoundId);
155 if (!anchorId.isEmpty()) t << "_1" << anchorId;
156 t << "\"";
157 t << ">";
158 writeDocbookString(t,text);
159 t << "</link>";
160}
161
165
167{
168 Docbook_DB(("(codify \"%s\")\n",text));
169 writeDocbookCodeString(m_hide,*m_t,text,m_col,static_cast<size_t>(m_stripIndentAmount));
170}
171
176
181
186
188{
189 m_stripIndentAmount = amount;
190}
191
193 const QCString &ref,const QCString &file,
194 const QCString &anchor,const QCString &name,
195 const QCString &tooltip)
196{
197 if (m_hide) return;
198 Docbook_DB(("(writeCodeLink)\n"));
199 writeDocbookLink(*m_t,ref,file,anchor,name,tooltip);
200 m_col+=name.length();
201}
202
204 const QCString &,const QCString &file,
205 const QCString &,const QCString &name,
206 const QCString &,bool writeLineAnchor)
207{
208 if (m_hide) return;
209 Docbook_DB(("(writeCodeLinkLine)\n"));
210 if (!writeLineAnchor) return;
211 *m_t << "<anchor xml:id=\"_" << stripExtensionGeneral(stripPath(file),".xml");
212 *m_t << "_1l";
213 writeDocbookString(*m_t,name);
214 *m_t << "\"/>";
215 m_col+=name.length();
216}
217
219 const QCString &, const SourceLinkInfo &, const SourceLinkInfo &
220 )
221{
222 Docbook_DB(("(writeToolTip)\n"));
223}
224
226{
227 if (m_hide) return;
228 Docbook_DB(("(startCodeLine)\n"));
230 m_col=0;
231}
232
234{
235 if (m_hide) return;
236 if (m_insideCodeLine) *m_t << "\n";
237 Docbook_DB(("(endCodeLine)\n"));
238 m_lineNumber = -1;
239 m_refId.clear();
240 m_external.clear();
242}
243
245{
246 if (m_hide) return;
247 Docbook_DB(("(startFontClass)\n"));
248 *m_t << "<emphasis role=\"" << colorClass << "\">";
250}
251
253{
254 if (m_hide) return;
255 Docbook_DB(("(endFontClass)\n"));
256 *m_t << "</emphasis>"; // non DocBook
258}
259
261{
262 Docbook_DB(("(writeCodeAnchor)\n"));
263}
264
266 const QCString &anchor,int l,bool writeLineAnchor)
267{
268 if (m_hide) return;
269 Docbook_DB(("(writeLineNumber)\n"));
271 if (Config_getBool(SOURCE_BROWSER))
272 {
273 QCString lineNumber;
274 lineNumber.sprintf("%05d",l);
275
276 if (!m_sourceFileName.isEmpty())
277 {
278 writeCodeLinkLine(CodeSymbolType::Default,ref,m_sourceFileName,anchor,lineNumber,QCString(),writeLineAnchor);
279 }
280 if (!fileName.isEmpty())
281 {
282 writeCodeLink(CodeSymbolType::Default,ref,fileName,anchor,lineNumber,QCString());
283 }
284 else
285 {
286 codify(lineNumber);
287 }
288 *m_t << " ";
289 }
290 else
291 {
292 *m_t << l << " ";
293 }
294 m_col=0;
295}
296
301
303{
305 *m_t << "<programlisting linenumbering=\"unnumbered\">";
306}
307
309{
311 bool wasHidden = m_hide;
312 m_hide = false;
313 //endCodeLine checks is there is still an open code line, if so closes it.
314 endCodeLine();
315 m_hide = wasHidden;
316
317 *m_t << "</programlisting>";
318}
319
320//-------------------------------------------------------------------------------
321
329
346
348{
349 if (this!=&og)
350 {
351 m_dir = og.m_dir;
352 m_codeList = std::make_unique<OutputCodeList>(*og.m_codeList);
354 m_codeGen->setTextStream(&m_t);
356 m_inGroup = og.m_inGroup;
362 m_inLevel = og.m_inLevel;
365 }
366 return *this;
367}
368
370
375
377{
378 QCString dir=Config_getString(DOCBOOK_OUTPUT);
379 Dir d(dir.str());
380 if (!d.exists() && !d.mkdir(dir.str()))
381 {
382 term("Could not create output directory {}\n",dir);
383 }
384
385 createSubDirs(d);
386}
388{
389 QCString dname = Config_getString(DOCBOOK_OUTPUT);
390 Dir d(dname.str());
391 clearSubDirs(d);
392}
393
394
395void DocbookGenerator::startFile(const QCString &name,const QCString &,const QCString &,int,int)
396{
398 QCString fileName=name;
399 QCString pageName;
400 QCString fileType="section";
401 if (fileName == "refman")
402 {
403 fileName="index";
404 fileType="book";
405 }
406 else if (fileName == "index")
407 {
408 fileName="mainpage";
409 fileType="chapter";
410 }
411 pageName = fileName;
413 if (!fileName.endsWith(".xml")) fileName+=".xml";
415 m_codeGen->setRelativePath(relPath);
416 m_codeGen->setSourceFileName(stripPath(fileName));
418
419 m_t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n";
420 m_t << "<" << fileType << " xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"";
421 if (!pageName.isEmpty()) m_t << " xml:id=\"_" << stripPath(pageName) << "\"";
422 m_t << " xml:lang=\"" << theTranslator->trISOLang() << "\"";
423 m_t << ">\n";
424}
425
427{
430 m_inLevel = -1;
432
433 // Write page links only after all sections have been closed to avoid bugs
434 m_t << m_pageLinks;
435
436 QCString fileType="section";
437 QCString fileName= m_codeGen->sourceFileName();
438 if (fileName == "index.xml")
439 {
440 fileType="book";
441 }
442 else if (fileName == "mainpage.xml")
443 {
444 fileType="chapter";
445 }
446 m_t << "</" << fileType << ">\n";
447 endPlainFile();
448 m_codeGen->setSourceFileName("");
449}
450
452{
453DB_GEN_C2("IndexSection " << is)
454 switch (is)
455 {
457 {
458 QCString dbk_projectName = Config_getString(PROJECT_NAME);
459 m_t << " <info>\n";
460 m_t << " <title>" << convertToDocBook(dbk_projectName) << "</title>\n";
461 m_t << " </info>\n";
462 }
463 break;
465 break;
467 break;
469 //Module Index\n"
470 break;
472 //Module Index\n"
473 break;
475 //Directory Index\n"
476 break;
478 //Namespace Index\n"
479 break;
481 //Concept Index\n"
482 break;
484 //Hierarchical Index\n"
485 break;
487 //m_t << "{"; //Class Index}\n"
488 break;
490 //Annotated File Index\n"
491 break;
493 //Annotated Page Index\n"
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 m_t << "<chapter>\n";
521 m_t << " <title>";
522 break;
524 m_t << "<chapter>\n";
525 m_t << " <title>";
526 break;
528 break;
530 break;
532 break;
533 }
534}
535
537{
538DB_GEN_C2("IndexSection " << is)
539 switch (is)
540 {
542 break;
544 break;
546 {
548 {
549 writePageLink(QCString("mainpage"), TRUE);
550 }
551 }
552 break;
554 //m_t << "</chapter>\n";
555 break;
557 //m_t << "</chapter>\n";
558 break;
560 //m_t << "<xi:include href=\"dirs.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
561 //m_t << "</chapter>\n";
562 break;
564 //m_t << "<xi:include href=\"namespaces.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
565 //m_t << "</chapter>\n";
566 break;
568 //m_t << "<xi:include href=\"concepts.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
569 //m_t << "</chapter>\n";
570 break;
572 //m_t << "<xi:include href=\"hierarchy.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
573 //m_t << "</chapter>\n";
574 break;
576 //m_t << "</chapter>\n";
577 break;
579 //m_t << "<xi:include href=\"files.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
580 //m_t << "</chapter>\n";
581 break;
583 //m_t << "<xi:include href=\"pages.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
584 //m_t << "</chapter>\n";
585 break;
587 {
588 m_t << "</title>\n";
589 for (const auto &gd : *Doxygen::groupLinkedMap)
590 {
591 if (!gd->isReference() && !gd->isASubGroup())
592 {
593 writePageLink(gd->getOutputFileBase(), TRUE);
594 }
595 }
596 }
597 m_t << "</chapter>\n";
598 break;
600 {
601 m_t << "</title>\n";
602 for (const auto &mod : ModuleManager::instance().modules())
603 {
604 if (!mod->isReference() && mod->isPrimaryInterface())
605 {
606 writePageLink(mod->getOutputFileBase(), TRUE);
607 }
608 }
609 }
610 m_t << "</chapter>\n";
611 break;
612 break;
614 {
615 m_t << "</title>\n";
616 for (const auto &dd : *Doxygen::dirLinkedMap)
617 {
618 if (dd->isLinkableInProject())
619 {
620 m_t << " <xi:include href=\"" << dd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
621 }
622 }
623 }
624 m_t << "</chapter>\n";
625 break;
627 {
628 m_t << "</title>\n";
629 for (const auto &nd : *Doxygen::namespaceLinkedMap)
630 {
631 if (nd->isLinkableInProject() && !nd->isAlias())
632 {
633 m_t << " <xi:include href=\"" << nd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
634 }
635 }
636 }
637 m_t << "</chapter>\n";
638 break;
640 {
641 m_t << "</title>\n";
642 for (const auto &cd : *Doxygen::conceptLinkedMap)
643 {
644 if (cd->isLinkableInProject() && !cd->isAlias())
645 {
646 m_t << " <xi:include href=\"" << cd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
647 }
648 }
649 }
650 m_t << "</chapter>\n";
651 break;
653 {
654 m_t << "</title>\n";
655 for (const auto &cd : *Doxygen::classLinkedMap)
656 {
657 if (cd->isLinkableInProject() &&
658 !cd->isImplicitTemplateInstance() &&
659 !cd->isEmbeddedInOuterScope() &&
660 !cd->isAlias()
661 )
662 {
663 m_t << " <xi:include href=\"" << cd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
664 }
665 }
666 }
667 m_t << "</chapter>\n";
668 break;
670 {
671 m_t << "</title>\n";
672 for (const auto &fn : *Doxygen::inputNameLinkedMap)
673 {
674 for (const auto &fd : *fn)
675 {
676 if (fd->isLinkableInProject())
677 {
678 m_t << " <xi:include href=\"" << fd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
679 }
680 if (fd->generateSourceFile())
681 {
682 m_t << " <xi:include href=\"" << fd->getSourceFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
683 }
684 }
685 }
686 }
687 m_t << "</chapter>\n";
688 break;
690 {
691 m_t << "</title>\n";
692 for (const auto &pd : *Doxygen::exampleLinkedMap)
693 {
694 m_t << " <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
695 }
696 }
697 m_t << "</chapter>\n";
698 break;
700 for (const auto &pd : *Doxygen::pageLinkedMap)
701 {
702 if (!pd->getGroupDef() && !pd->isReference() && !pd->hasParentPage()
703 && Doxygen::mainPage.get() != pd.get())
704 {
705 writePageLink(pd->getOutputFileBase(), TRUE);
706 }
707 }
708 break;
710 break;
712 m_t << "<index/>\n";
713 break;
714 }
715}
716void DocbookGenerator::writePageLink(const QCString &name, bool first)
717{
719 QCString link;
720 link.sprintf(" <xi:include href=\"%s.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n",
721 name.data());
722 if (first)
723 m_t << link;
724 else
725 // Buffer page links and write them after all sections are closed
726 m_pageLinks += link;
727}
728
729void DocbookGenerator::writeDoc(const IDocNodeAST *ast,const Definition *ctx,const MemberDef *,int)
730{
732 auto astImpl = dynamic_cast<const DocNodeAST*>(ast);
733 if (astImpl)
734 {
736 std::visit(visitor,astImpl->root);
737 }
738}
739
741{
743 m_t << "<para>\n";
744}
745
747{
749 m_t << "</para>\n";
750}
752{
754 m_t << text;
755}
757{
759 m_t << "<simplesect>\n";
761 m_t << " <title>";
762}
763
765{
767 m_t << " </title>\n";
768}
770{
772 m_t << convertToDocBook(str);
773}
775 const QCString &anchor, const QCString &text)
776{
778 QCString result;
779 if (!anchor.isEmpty())
780 {
781 if (!f.isEmpty()) result += "<link linkend=\"_" + stripPath(f) + "_1" + anchor + "\">";
782 else result += "<link linkend=\"_" + anchor + "\">";
783 }
784 else
785 {
786 result += "<link linkend=\"_" + stripPath(f) + "\">";
787 }
788 result += convertToDocBook(text);
789 result += "</link>";
790 return result;
791}
793 const QCString &anchor, const QCString &text)
794{
796 m_t << objectLinkToString(ref,f,anchor,text);
797}
799{
801 m_t << " <itemizedlist>\n";
803}
805{
807 if (m_inListItem[m_levelListItem]) m_t << "</listitem>\n";
809 m_t << " </itemizedlist>\n";
811 if (m_inSimpleSect[m_levelListItem]) m_t << "</simplesect>\n";
813}
815{
817 if (m_inListItem[m_levelListItem]) m_t << "</listitem>\n";
818 m_t << " <listitem><para>";
820}
822{
824 m_t << "</para>\n";
825}
827{
829 m_t << "<emphasis role=\"strong\">";
830}
832{
834 m_t << "</emphasis>";
835}
836void DocbookGenerator::startGroupHeader(const QCString &,int extraIndentLevel)
837{
838DB_GEN_C2("m_inLevel " << m_inLevel)
839DB_GEN_C2("extraIndentLevel " << extraIndentLevel)
841 if (m_inSimpleSect[m_levelListItem]) m_t << "</simplesect>\n";
843 if (m_inLevel != -1) m_inGroup = TRUE;
844 if (m_inLevel == extraIndentLevel) closeSection();
845 m_inLevel = extraIndentLevel;
846 openSection();
847 m_t << "<title>";
848}
850{
851DB_GEN_C2("m_inLevel " << m_inLevel)
852DB_GEN_C2("m_inGroup " << m_inGroup)
853 if (m_inGroup) closeSection();
855}
856
858{
860 m_t << "</title>\n";
861}
862
864{
866 if (openBracket) m_t << "(";
867}
873{
875 for (int i=0;i<n;i++) m_t << "&#160;";
876}
878{
880 m_t << "<?linebreak?>";
881}
883{
885 if (!m_denseText) m_t << "<computeroutput>";
886}
888{
890 if (!m_denseText) m_t << "</computeroutput>\n";
891}
893{
895 if (dense)
896 {
898 m_t << "<programlisting linenumbering=\"unnumbered\">";
899 }
900}
902{
904 if (m_denseText)
905 {
907 m_t << "</programlisting>";
908 }
909}
910void DocbookGenerator::startMemberDoc(const QCString &clname, const QCString &memname, const QCString &, const QCString &title,
911 int memCount, int memTotal, bool)
912{
913DB_GEN_C2("m_inLevel " << m_inLevel)
914 openSection();
915 m_t << " <title>" << convertToDocBook(title);
916 if (memTotal>1)
917 {
918 m_t << "<computeroutput>[" << memCount << "/" << memTotal << "]</computeroutput>";
919 }
920 m_t << "</title>\n";
921 if (!memname.isEmpty() && memname[0]!='@')
922 {
923 addIndexTerm(m_t,memname,clname);
924 addIndexTerm(m_t,clname,memname);
925 }
926}
928{
930 m_t << "</computeroutput></para>";
931}
933{
935 m_t << "<title>";
936}
938{
940 m_t << "</title>\n";
941 if (!name.isEmpty()) addIndexTerm(m_t, name);
942}
944 const QCString &anchor,const QCString &,
945 const QCString &)
946{
949 {
952 }
953 if (!anchor.isEmpty())
954 {
955 m_t << "<anchor xml:id=\"_" << stripPath(fName) << "_1" << anchor << "\"/>";
956 }
957}
963{
965}
967{
969 m_t << "<para><computeroutput>";
970}
976{
978 m_t << "<simplesect><title>";
979}
981{
983 m_t << "</title>\n";
984}
990{
992 m_t << "</simplesect>\n";
993}
995{
997 m_t << "<para>";
998}
999
1001{
1003 m_t << " <informalfigure>\n";
1004 m_t << " <mediaobject>\n";
1005 m_t << " <imageobject>\n";
1006 m_t << " <imagedata width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\""
1007 << relPath << fileName << ".png\">" << "</imagedata>\n";
1008 m_t << " </imageobject>\n";
1010 m_t << " </mediaobject>\n";
1011 m_t << " </informalfigure>\n";
1012 m_t << "</para>\n";
1013}
1018
1019void DocbookGenerator::writeLabel(const QCString &l,bool isLast)
1020{
1022 m_t << "<computeroutput>[" << l << "]</computeroutput>";
1023 if (!isLast) m_t << ", ";
1024}
1025
1031{
1033 m_t << "<simplesect><title>";
1034 docify(theTranslator->trExamples());
1035 m_t << "</title>";
1036}
1037
1039{
1041 m_t << "</simplesect>\n";
1042}
1044{
1046 m_t << "<simplesect><title>";
1047}
1049{
1051 m_t << "</title></simplesect>\n";
1052}
1054{
1056 char cs[2];
1057 cs[0]=c;
1058 cs[1]=0;
1059 docify(cs);
1060}
1062{
1064 m_t << "<computeroutput>";
1065}
1067{
1069 m_t << "</computeroutput>";
1070}
1072{
1074 if (!prefix.isEmpty())
1075 {
1076 m_t << " " << prefix << "(";
1077 }
1078 else if (closeBracket)
1079 {
1080 m_t << ")";
1081 }
1082 m_t << " ";
1083}
1084
1086{
1088 m_t << " ";
1089}
1090
1095
1100
1101void DocbookGenerator::endParameterExtra(bool last,bool /*emptyList*/,bool closeBracket)
1102{
1104 if (last && closeBracket)
1105 {
1106 m_t << ")";
1107 }
1108}
1109
1110
1112{
1114 m_t << sep;
1115 if (!m_denseText) m_t << "<computeroutput>";
1116}
1117
1119{
1121 if (!m_denseText) m_t << "</computeroutput>\n";
1122}
1123
1128
1130{
1132 m_t << "</para>";
1133 m_t << "<para>";
1134}
1136{
1138 openSection("xml:id=\"_" + stripPath(lab) + "\"");
1139 m_t << "<title>";
1140}
1142{
1144 m_t << "</title>";
1145 closeSection();
1146}
1148{
1150 addIndexTerm(m_t, prim, sec);
1151}
1152
1154{
1156 int ncols=0;
1157 QCString title;
1158 if (isEnum)
1159 {
1160 ncols = 2;
1161 title = theTranslator->trEnumerationValues();
1162 }
1163 else
1164 {
1165 ncols = 3;
1166 title = theTranslator->trCompoundMembers();
1167 }
1168 m_t << "<table frame=\"all\">\n";
1169 if (!title.isEmpty()) m_t << "<title>" << convertToDocBook(title) << "</title>\n";
1170 m_t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n";
1171 for (int i = 0; i < ncols; i++)
1172 {
1173 m_t << " <colspec colname='c" << i+1 << "'/>\n";
1174 }
1175 m_t << "<tbody>\n";
1176 m_simpleTable = true;
1177}
1178
1180{
1182 m_t << " </tbody>\n";
1183 m_t << " </tgroup>\n";
1184 m_t << "</table>\n";
1185 m_simpleTable = false;
1186}
1187
1189{
1191 m_t << "<row><entry>";
1192}
1193
1195{
1197 m_t << "</entry>";
1198}
1199
1201{
1203 m_t << "<entry>";
1204}
1205
1207{
1209 m_t << "</entry>";
1210}
1211
1213{
1215 m_t << "<entry>";
1216}
1217
1219{
1221 m_t << "</entry></row>\n";
1222}
1223
1224void DocbookGenerator::startDescTable(const QCString &title,const bool hasInits)
1225{
1227 int ncols = (hasInits?3:2);
1228 m_t << "<informaltable frame=\"all\">\n";
1229 if (!title.isEmpty()) m_t << "<title>" << convertToDocBook(title) << "</title>\n";
1230 m_t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n";
1231 int i = 1;
1232 m_t << " <colspec colname='c" << i++ << "'/>\n";
1233 if (hasInits) m_t << " <colspec colname='c" << i++ << "' align='right'/>\n";
1234 m_t << " <colspec colname='c" << i++ << "'/>\n";
1235 m_t << "<tbody>\n";
1236 m_descTable = TRUE;
1237}
1238
1240{
1242 m_t << " </tbody>\n";
1243 m_t << " </tgroup>\n";
1244 m_t << "</informaltable>\n";
1246}
1247
1249{
1251 m_t << "<row>";
1252 m_t << "<entry>";
1253}
1254
1256{
1258 m_t << "</row>";
1259}
1260
1265
1270
1272{
1274 m_t << "</entry><entry>";
1275}
1276
1281
1283{
1285 m_t << "</entry><entry>";
1286}
1287
1289{
1291 m_t << "</entry>";
1292}
1348{
1350 m_t << "<simplesect><title>";
1351 docify(header);
1352 m_t << "</title>\n";
1353}
1355{
1357 m_t << "<para><emphasis role=\"strong\">";
1358}
1364{
1366 m_t << ":";
1367}
1369{
1371 m_t << "</emphasis></para>\n";
1372}
1382{
1384 m_t << "</simplesect>\n";
1385}
1386
1388{
1389 m_t << "<section";
1390 if (!attr.isEmpty()) m_t << " " << attr;
1391 m_t << ">\n";
1393}
1394
1396{
1397 m_t << "</section>\n";
1399}
1400
1402{
1403 while (m_openSectionCount>0)
1404 {
1405 closeSection();
1406 }
1407}
1408
1410 const QCString &/*id*/,const QCString &ref,
1411 const QCString &file, const QCString &anchor,
1412 const QCString &title, const QCString &name)
1413{
1415 m_t << theTranslator->trInheritedFrom(convertToDocBook(title), objectLinkToString(ref, file, anchor, name));
1416}
1417
1419{
1420 m_tocState.level=1;
1421 m_tocState.maxLevel=level;
1422 m_tocState.inLi = BoolVector(level+1,false);
1423 m_t << " <toc>\n";
1424 m_t << " <title>" << theTranslator->trRTFTableOfContents() << "</title>\n";
1425}
1426
1428{
1429 if (m_tocState.level > m_tocState.maxLevel) m_tocState.level = m_tocState.maxLevel;
1430 while (m_tocState.level>1 && m_tocState.level <= m_tocState.maxLevel)
1431 {
1432 m_t << "</tocdiv>\n";
1433 m_tocState.level--;
1434 }
1435 m_t << " </toc>\n";
1436}
1437
1439{
1440 SectionType type = si->type();
1441 if (type.isSection())
1442 {
1443 //printf(" level=%d title=%s\n",level,qPrint(si->title));
1444 int nextLevel = type.level();
1445 if (nextLevel>m_tocState.level)
1446 {
1447 for (int l=m_tocState.level;l<nextLevel;l++)
1448 {
1449 if (l < m_tocState.maxLevel) m_t << " <tocdiv>\n";
1450 }
1451 }
1452 else if (nextLevel<m_tocState.level)
1453 {
1454 for (int l=m_tocState.level;l>nextLevel;l--)
1455 {
1456 m_tocState.inLi[l]=false;
1457 if (l <= m_tocState.maxLevel) m_t << " </tocdiv>\n";
1458 }
1459 }
1460 if (nextLevel <= m_tocState.maxLevel)
1461 {
1462 QCString label = convertToDocBook(si->label());
1463 m_t << " <tocentry>";
1464 }
1465 }
1466}
1467
1469{
1470 SectionType type = si->type();
1471 int nextLevel = type.level();
1472 if (type.isSection() && nextLevel <= m_tocState.maxLevel)
1473 {
1474 m_t << "</tocentry>\n";
1475 m_tocState.inLi[nextLevel]=true;
1476 m_tocState.level = nextLevel;
1477 }
1478}
1479
1480//-------------------------------------------------------------------------------------------------
1481
1482static constexpr auto hex="0123456789ABCDEF";
1483
1484/*! Converts a string to an DocBook-encoded string */
1485QCString convertToDocBook(const QCString &s, const bool retainNewline)
1486{
1487 if (s.isEmpty()) return s;
1488 GrowBuf growBuf;
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': if (retainNewline) growBuf.addStr("<literallayout>&#160;&#xa;</literallayout>"); growBuf.addChar(c); break;
1498 case '<': growBuf.addStr("&lt;"); break;
1499 case '>': growBuf.addStr("&gt;"); break;
1500 case '&': // possibility to have a special symbol
1501 q = p;
1502 cnt = 2; // we have to count & and ; as well
1503 while ((*q >= 'a' && *q <= 'z') || (*q >= 'A' && *q <= 'Z') || (*q >= '0' && *q <= '9'))
1504 {
1505 cnt++;
1506 q++;
1507 }
1508 if (*q == ';')
1509 {
1510 --p; // we need & as well
1513 {
1514 p++;
1515 growBuf.addStr("&amp;");
1516 }
1517 else
1518 {
1519 growBuf.addStr(HtmlEntityMapper::instance().docbook(res));
1520 q++;
1521 p = q;
1522 }
1523 }
1524 else
1525 {
1526 growBuf.addStr("&amp;");
1527 }
1528 break;
1529 case '\'': growBuf.addStr("&apos;"); break;
1530 case '"': growBuf.addStr("&quot;"); break;
1531 case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
1532 case 11: case 12: case 14: case 15: case 16: case 17: case 18:
1533 case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26:
1534 case 27: case 28: case 29: case 30: case 31:
1535 growBuf.addStr("&#x24");
1536 growBuf.addChar(hex[static_cast<uint8_t>(c)>>4]);
1537 growBuf.addChar(hex[static_cast<uint8_t>(c)&0xF]);
1538 growBuf.addChar(';');
1539 break;
1540 default:
1541 growBuf.addChar(c);
1542 break;
1543 }
1544 }
1545 growBuf.addChar(0);
1546 return growBuf.get();
1547}
1548
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:1369
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 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 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 writeDoc(const IDocNodeAST *node, const Definition *ctx, const MemberDef *md, int id) 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 startFile(const QCString &name, const QCString &manName, const QCString &title, int id, int hierarchyLevel) override
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:115
static ConceptLinkedMap * conceptLinkedMap
Definition doxygen.h:98
static std::unique_ptr< PageDef > mainPage
Definition doxygen.h:101
static FileNameLinkedMap * inputNameLinkedMap
Definition doxygen.h:105
static ClassLinkedMap * classLinkedMap
Definition doxygen.h:96
static PageLinkedMap * exampleLinkedMap
Definition doxygen.h:99
static PageLinkedMap * pageLinkedMap
Definition doxygen.h:100
static DirLinkedMap * dirLinkedMap
Definition doxygen.h:129
static GroupLinkedMap * groupLinkedMap
Definition doxygen.h:114
Class representing a string buffer optimized for growing.
Definition growbuf.h:28
void addChar(char c)
Definition growbuf.h:69
void addStr(const QCString &s)
Definition growbuf.h:72
char * get()
Definition growbuf.h:114
static HtmlEntityMapper & instance()
Returns the one and only instance of the HTML entity mapper.
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:164
void add(OutputCodeIntfPtr &&p)
Definition outputlist.h:194
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:153
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
const std::string & str() const
Definition qcstring.h:537
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:159
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:105
#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:7391
QCString stripPath(const QCString &s)
Definition util.cpp:5461
QCString relativePathToRoot(const QCString &name)
Definition util.cpp:4092
void clearSubDirs(const Dir &d)
Definition util.cpp:4180
QCString stripExtensionGeneral(const QCString &fName, const QCString &ext)
Definition util.cpp:5424
void createSubDirs(const Dir &d)
Definition util.cpp:4153
A bunch of utility functions.