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 //endCodeLine checks is there is still an open code line, if so closes it.
312 endCodeLine();
313
314 *m_t << "</programlisting>";
315}
316
317//-------------------------------------------------------------------------------
318
320 : OutputGenerator(Config_getString(DOCBOOK_OUTPUT))
321 , m_codeList(std::make_unique<OutputCodeList>())
322{
324 m_codeGen = m_codeList->add<DocbookCodeGenerator>(&m_t);
325}
326
343
345{
346 if (this!=&og)
347 {
348 m_dir = og.m_dir;
349 m_codeList = std::make_unique<OutputCodeList>(*og.m_codeList);
350 m_codeGen = m_codeList->get<DocbookCodeGenerator>(OutputType::Docbook);
351 m_codeGen->setTextStream(&m_t);
353 m_inGroup = og.m_inGroup;
359 m_inLevel = og.m_inLevel;
362 }
363 return *this;
364}
365
367
372
374{
375 QCString dir=Config_getString(DOCBOOK_OUTPUT);
376 Dir d(dir.str());
377 if (!d.exists() && !d.mkdir(dir.str()))
378 {
379 term("Could not create output directory %s\n",qPrint(dir));
380 }
381
382 createSubDirs(d);
383}
385{
386 QCString dname = Config_getString(DOCBOOK_OUTPUT);
387 Dir d(dname.str());
388 clearSubDirs(d);
389}
390
391
392void DocbookGenerator::startFile(const QCString &name,const QCString &,const QCString &,int,int)
393{
395 QCString fileName=name;
396 QCString pageName;
397 QCString fileType="section";
398 if (fileName == "refman")
399 {
400 fileName="index";
401 fileType="book";
402 }
403 else if (fileName == "index")
404 {
405 fileName="mainpage";
406 fileType="chapter";
407 }
408 pageName = fileName;
410 if (!fileName.endsWith(".xml")) fileName+=".xml";
412 m_codeGen->setRelativePath(relPath);
413 m_codeGen->setSourceFileName(stripPath(fileName));
414 m_pageLinks = QCString();
415
416 m_t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n";
417 m_t << "<" << fileType << " xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"";
418 if (!pageName.isEmpty()) m_t << " xml:id=\"_" << stripPath(pageName) << "\"";
419 m_t << " xml:lang=\"" << theTranslator->trISOLang() << "\"";
420 m_t << ">\n";
421}
422
424{
427 m_inLevel = -1;
429
430 // Write page links only after all sections have been closed to avoid bugs
431 m_t << m_pageLinks;
432
433 QCString fileType="section";
434 QCString fileName= m_codeGen->sourceFileName();
435 if (fileName == "index.xml")
436 {
437 fileType="book";
438 }
439 else if (fileName == "mainpage.xml")
440 {
441 fileType="chapter";
442 }
443 m_t << "</" << fileType << ">\n";
444 endPlainFile();
445 m_codeGen->setSourceFileName("");
446}
447
449{
450DB_GEN_C2("IndexSection " << is)
451 switch (is)
452 {
454 {
455 QCString dbk_projectName = Config_getString(PROJECT_NAME);
456 m_t << " <info>\n";
457 m_t << " <title>" << convertToDocBook(dbk_projectName) << "</title>\n";
458 m_t << " </info>\n";
459 }
460 break;
462 break;
464 break;
466 //Module Index\n"
467 break;
469 //Module Index\n"
470 break;
472 //Directory Index\n"
473 break;
475 //Namespace Index\n"
476 break;
478 //Concept Index\n"
479 break;
481 //Hierarchical Index\n"
482 break;
484 //m_t << "{"; //Class Index}\n"
485 break;
487 //Annotated File Index\n"
488 break;
490 //Annotated Page Index\n"
491 break;
493 m_t << "<chapter>\n";
494 m_t << " <title>";
495 break;
497 m_t << "<chapter>\n";
498 m_t << " <title>";
499 break;
501 m_t << "<chapter>\n";
502 m_t << " <title>";
503 break;
505 m_t << "<chapter>\n";
506 m_t << " <title>";
507 break;
509 m_t << "<chapter>\n";
510 m_t << " <title>";
511 break;
513 m_t << "<chapter>\n";
514 m_t << " <title>";
515 break;
517 m_t << "<chapter>\n";
518 m_t << " <title>";
519 break;
521 m_t << "<chapter>\n";
522 m_t << " <title>";
523 break;
525 break;
527 break;
529 break;
530 }
531}
532
534{
535DB_GEN_C2("IndexSection " << is)
536 switch (is)
537 {
539 break;
541 break;
543 {
545 {
546 writePageLink(QCString("mainpage"), TRUE);
547 }
548 }
549 break;
551 //m_t << "</chapter>\n";
552 break;
554 //m_t << "</chapter>\n";
555 break;
557 //m_t << "<xi:include href=\"dirs.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
558 //m_t << "</chapter>\n";
559 break;
561 //m_t << "<xi:include href=\"namespaces.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
562 //m_t << "</chapter>\n";
563 break;
565 //m_t << "<xi:include href=\"concepts.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
566 //m_t << "</chapter>\n";
567 break;
569 //m_t << "<xi:include href=\"hierarchy.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
570 //m_t << "</chapter>\n";
571 break;
573 //m_t << "</chapter>\n";
574 break;
576 //m_t << "<xi:include href=\"files.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
577 //m_t << "</chapter>\n";
578 break;
580 //m_t << "<xi:include href=\"pages.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>";
581 //m_t << "</chapter>\n";
582 break;
584 {
585 m_t << "</title>\n";
586 for (const auto &gd : *Doxygen::groupLinkedMap)
587 {
588 if (!gd->isReference() && !gd->isASubGroup())
589 {
590 writePageLink(gd->getOutputFileBase(), TRUE);
591 }
592 }
593 }
594 m_t << "</chapter>\n";
595 break;
597 {
598 m_t << "</title>\n";
599 for (const auto &mod : ModuleManager::instance().modules())
600 {
601 if (!mod->isReference() && mod->isPrimaryInterface())
602 {
603 writePageLink(mod->getOutputFileBase(), TRUE);
604 }
605 }
606 }
607 m_t << "</chapter>\n";
608 break;
609 break;
611 {
612 m_t << "</title>\n";
613 for (const auto &dd : *Doxygen::dirLinkedMap)
614 {
615 if (dd->isLinkableInProject())
616 {
617 m_t << "< xi:include href=\"" << dd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
618 }
619 }
620 }
621 m_t << "</chapter>\n";
622 break;
624 {
625 m_t << "</title>\n";
626 for (const auto &nd : *Doxygen::namespaceLinkedMap)
627 {
628 if (nd->isLinkableInProject() && !nd->isAlias())
629 {
630 m_t << "<xi:include href=\"" << nd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
631 }
632 }
633 }
634 m_t << "</chapter>\n";
635 break;
637 {
638 m_t << "</title>\n";
639 for (const auto &cd : *Doxygen::conceptLinkedMap)
640 {
641 if (cd->isLinkableInProject() && !cd->isAlias())
642 {
643 m_t << "<xi:include href=\"" << cd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
644 }
645 }
646 }
647 m_t << "</chapter>\n";
648 break;
650 {
651 m_t << "</title>\n";
652 for (const auto &cd : *Doxygen::classLinkedMap)
653 {
654 if (cd->isLinkableInProject() &&
655 cd->templateMaster()==nullptr &&
656 !cd->isEmbeddedInOuterScope() &&
657 !cd->isAlias()
658 )
659 {
660 m_t << " <xi:include href=\"" << cd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
661 }
662 }
663 }
664 m_t << "</chapter>\n";
665 break;
667 {
668 m_t << "</title>\n";
669 for (const auto &fn : *Doxygen::inputNameLinkedMap)
670 {
671 for (const auto &fd : *fn)
672 {
673 if (fd->isLinkableInProject())
674 {
675 m_t << " <xi:include href=\"" << fd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
676 }
677 if (fd->generateSourceFile())
678 {
679 m_t << " <xi:include href=\"" << fd->getSourceFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
680 }
681 }
682 }
683 }
684 m_t << "</chapter>\n";
685 break;
687 {
688 m_t << "</title>\n";
689 for (const auto &pd : *Doxygen::exampleLinkedMap)
690 {
691 m_t << " <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n";
692 }
693 }
694 m_t << "</chapter>\n";
695 break;
697 for (const auto &pd : *Doxygen::pageLinkedMap)
698 {
699 if (!pd->getGroupDef() && !pd->isReference() && !pd->hasParentPage()
700 && Doxygen::mainPage.get() != pd.get())
701 {
702 writePageLink(pd->getOutputFileBase(), TRUE);
703 }
704 }
705 break;
707 break;
709 m_t << "<index/>\n";
710 break;
711 }
712}
713void DocbookGenerator::writePageLink(const QCString &name, bool first)
714{
716 QCString link;
717 link.sprintf(" <xi:include href=\"%s.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n",
718 name.data());
719 if (first)
720 m_t << link;
721 else
722 // Buffer page links and write them after all sections are closed
723 m_pageLinks += link;
724}
725
726void DocbookGenerator::writeDoc(const IDocNodeAST *ast,const Definition *ctx,const MemberDef *,int)
727{
729 auto astImpl = dynamic_cast<const DocNodeAST*>(ast);
730 if (astImpl)
731 {
732 DocbookDocVisitor visitor(m_t,*m_codeList,ctx?ctx->getDefFileExtension():QCString());
733 std::visit(visitor,astImpl->root);
734 }
735}
736
738{
740 m_t << "<para>\n";
741}
742
744{
746 m_t << "</para>\n";
747}
749{
751 m_t << text;
752}
754{
756 m_t << "<simplesect>\n";
758 m_t << " <title>";
759}
760
762{
764 m_t << " </title>\n";
765}
767{
769 m_t << convertToDocBook(str);
770}
772 const QCString &anchor, const QCString &text)
773{
775 QCString result;
776 if (!anchor.isEmpty())
777 {
778 if (!f.isEmpty()) result += "<link linkend=\"_" + stripPath(f) + "_1" + anchor + "\">";
779 else result += "<link linkend=\"_" + anchor + "\">";
780 }
781 else
782 {
783 result += "<link linkend=\"_" + stripPath(f) + "\">";
784 }
785 result += convertToDocBook(text);
786 result += "</link>";
787 return result;
788}
790 const QCString &anchor, const QCString &text)
791{
793 m_t << objectLinkToString(ref,f,anchor,text);
794}
796{
798 m_t << " <itemizedlist>\n";
800}
802{
804 if (m_inListItem[m_levelListItem]) m_t << "</listitem>\n";
806 m_t << " </itemizedlist>\n";
808 if (m_inSimpleSect[m_levelListItem]) m_t << "</simplesect>\n";
810}
812{
814 if (m_inListItem[m_levelListItem]) m_t << "</listitem>\n";
815 m_t << " <listitem><para>";
817}
819{
821 m_t << "</para>\n";
822}
824{
826 m_t << "<emphasis role=\"strong\">";
827}
829{
831 m_t << "</emphasis>";
832}
833void DocbookGenerator::startGroupHeader(int extraIndentLevel)
834{
835DB_GEN_C2("m_inLevel " << m_inLevel)
836DB_GEN_C2("extraIndentLevel " << extraIndentLevel)
838 if (m_inSimpleSect[m_levelListItem]) m_t << "</simplesect>\n";
840 if (m_inLevel != -1) m_inGroup = TRUE;
841 if (m_inLevel == extraIndentLevel) closeSection();
842 m_inLevel = extraIndentLevel;
843 openSection();
844 m_t << "<title>";
845}
847{
848DB_GEN_C2("m_inLevel " << m_inLevel)
849DB_GEN_C2("m_inGroup " << m_inGroup)
850 if (m_inGroup) closeSection();
852}
853
855{
857 m_t << "</title>\n";
858}
859
861{
863 if (openBracket) m_t << "(";
864}
870{
872 for (int i=0;i<n;i++) m_t << "&#160;";
873}
875{
877 m_t << "<?linebreak?>";
878}
880{
882 if (!m_denseText) m_t << "<computeroutput>";
883}
885{
887 if (!m_denseText) m_t << "</computeroutput>\n";
888}
890{
892 if (dense)
893 {
895 m_t << "<programlisting linenumbering=\"unnumbered\">";
896 }
897}
899{
901 if (m_denseText)
902 {
904 m_t << "</programlisting>";
905 }
906}
907void DocbookGenerator::startMemberDoc(const QCString &clname, const QCString &memname, const QCString &, const QCString &title,
908 int memCount, int memTotal, bool)
909{
910DB_GEN_C2("m_inLevel " << m_inLevel)
911 openSection();
912 m_t << " <title>" << convertToDocBook(title);
913 if (memTotal>1)
914 {
915 m_t << "<computeroutput>[" << memCount << "/" << memTotal << "]</computeroutput>";
916 }
917 m_t << "</title>\n";
918 if (!memname.isEmpty() && memname[0]!='@')
919 {
920 addIndexTerm(m_t,memname,clname);
921 addIndexTerm(m_t,clname,memname);
922 }
923}
925{
927 m_t << "</computeroutput></para>";
928}
930{
932 m_t << "<title>";
933}
935{
937 m_t << "</title>\n";
938 if (!name.isEmpty()) addIndexTerm(m_t, name);
939}
941 const QCString &anchor,const QCString &,
942 const QCString &)
943{
946 {
949 }
950 if (!anchor.isEmpty())
951 {
952 m_t << "<anchor xml:id=\"_" << stripPath(fName) << "_1" << anchor << "\"/>";
953 }
954}
960{
962}
964{
966 m_t << "<para><computeroutput>";
967}
973{
975 m_t << "<simplesect><title>";
976}
978{
980 m_t << "</title>\n";
981}
987{
989 m_t << "</simplesect>\n";
990}
992{
994 m_t << "<para>";
995}
996
998{
1000 m_t << " <informalfigure>\n";
1001 m_t << " <mediaobject>\n";
1002 m_t << " <imageobject>\n";
1003 m_t << " <imagedata width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\""
1004 << relPath << fileName << ".png\">" << "</imagedata>\n";
1005 m_t << " </imageobject>\n";
1007 m_t << " </mediaobject>\n";
1008 m_t << " </informalfigure>\n";
1009 m_t << "</para>\n";
1010}
1015
1016void DocbookGenerator::writeLabel(const QCString &l,bool isLast)
1017{
1019 m_t << "<computeroutput>[" << l << "]</computeroutput>";
1020 if (!isLast) m_t << ", ";
1021}
1022
1028{
1030 m_t << "<simplesect><title>";
1032 m_t << "</title>";
1033}
1034
1036{
1038 m_t << "</simplesect>\n";
1039}
1041{
1043 m_t << "<simplesect><title>";
1044}
1046{
1048 m_t << "</title></simplesect>\n";
1049}
1051{
1053 char cs[2];
1054 cs[0]=c;
1055 cs[1]=0;
1056 docify(cs);
1057}
1059{
1061 m_t << "<computeroutput>";
1062}
1064{
1066 m_t << "</computeroutput>";
1067}
1069{
1071 if (!prefix.isEmpty())
1072 {
1073 m_t << " " << prefix << "(";
1074 }
1075 else if (closeBracket)
1076 {
1077 m_t << ")";
1078 }
1079 m_t << " ";
1080}
1081
1083{
1085 m_t << " ";
1086}
1087
1092
1097
1098void DocbookGenerator::endParameterExtra(bool last,bool /*emptyList*/,bool closeBracket)
1099{
1101 if (last && closeBracket)
1102 {
1103 m_t << ")";
1104 }
1105}
1106
1107
1109{
1111 m_t << sep;
1112 if (!m_denseText) m_t << "<computeroutput>";
1113}
1114
1116{
1118 if (!m_denseText) m_t << "</computeroutput>\n";
1119}
1120
1125
1127{
1129 m_t << "</para>";
1130 m_t << "<para>";
1131}
1133{
1135 openSection("xml:id=\"_" + stripPath(lab) + "\"");
1136 m_t << "<title>";
1137}
1139{
1141 m_t << "</title>";
1142 closeSection();
1143}
1145{
1147 addIndexTerm(m_t, prim, sec);
1148}
1149
1151{
1153 int ncols=0;
1154 QCString title;
1155 if (isEnum)
1156 {
1157 ncols = 2;
1159 }
1160 else
1161 {
1162 ncols = 3;
1164 }
1165 m_t << "<table frame=\"all\">\n";
1166 if (!title.isEmpty()) m_t << "<title>" << convertToDocBook(title) << "</title>\n";
1167 m_t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n";
1168 for (int i = 0; i < ncols; i++)
1169 {
1170 m_t << " <colspec colname='c" << i+1 << "'/>\n";
1171 }
1172 m_t << "<tbody>\n";
1173 m_simpleTable = true;
1174}
1175
1177{
1179 m_t << " </tbody>\n";
1180 m_t << " </tgroup>\n";
1181 m_t << "</table>\n";
1182 m_simpleTable = false;
1183}
1184
1186{
1188 m_t << "<row><entry>";
1189}
1190
1192{
1194 m_t << "</entry>";
1195}
1196
1198{
1200 m_t << "<entry>";
1201}
1202
1204{
1206 m_t << "</entry>";
1207}
1208
1210{
1212 m_t << "<entry>";
1213}
1214
1216{
1218 m_t << "</entry></row>\n";
1219}
1220
1221void DocbookGenerator::startDescTable(const QCString &title,const bool hasInits)
1222{
1224 int ncols = (hasInits?3:2);
1225 m_t << "<informaltable frame=\"all\">\n";
1226 if (!title.isEmpty()) m_t << "<title>" << convertToDocBook(title) << "</title>\n";
1227 m_t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n";
1228 int i = 1;
1229 m_t << " <colspec colname='c" << i++ << "'/>\n";
1230 if (hasInits) m_t << " <colspec colname='c" << i++ << "' align='right'/>\n";
1231 m_t << " <colspec colname='c" << i++ << "'/>\n";
1232 m_t << "<tbody>\n";
1233 m_descTable = TRUE;
1234}
1235
1237{
1239 m_t << " </tbody>\n";
1240 m_t << " </tgroup>\n";
1241 m_t << "</informaltable>\n";
1243}
1244
1246{
1248 m_t << "<row>";
1249 m_t << "<entry>";
1250}
1251
1253{
1255 m_t << "</row>";
1256}
1257
1262
1267
1269{
1271 m_t << "</entry><entry>";
1272}
1273
1278
1280{
1282 m_t << "</entry><entry>";
1283}
1284
1286{
1288 m_t << "</entry>";
1289}
1345{
1347 m_t << "<simplesect><title>";
1348 docify(header);
1349 m_t << "</title>\n";
1350}
1352{
1354 m_t << "<para><emphasis role=\"strong\">";
1355}
1361{
1363 m_t << ":";
1364}
1366{
1368 m_t << "</emphasis></para>\n";
1369}
1379{
1381 m_t << "</simplesect>\n";
1382}
1383
1385{
1386 m_t << "<section";
1387 if (!attr.isEmpty()) m_t << " " << attr;
1388 m_t << ">\n";
1390}
1391
1393{
1394 m_t << "</section>\n";
1396}
1397
1399{
1400 while (m_openSectionCount>0)
1401 {
1402 closeSection();
1403 }
1404}
1405
1407 const QCString &/*id*/,const QCString &ref,
1408 const QCString &file, const QCString &anchor,
1409 const QCString &title, const QCString &name)
1410{
1412 m_t << theTranslator->trInheritedFrom(convertToDocBook(title), objectLinkToString(ref, file, anchor, name));
1413}
1414
1415void DocbookGenerator::writeLocalToc(const SectionRefs &sectionRefs,const LocalToc &localToc)
1416{
1417 if (localToc.isDocbookEnabled())
1418 {
1419 m_t << " <toc>\n";
1420 m_t << " <title>" << theTranslator->trRTFTableOfContents() << "</title>\n";
1421 int level=1;
1422 int maxLevel = localToc.docbookLevel();
1423 BoolVector inLi(maxLevel+1,false);
1424 for (const SectionInfo *si : sectionRefs)
1425 {
1426 SectionType type = si->type();
1427 if (type.isSection())
1428 {
1429 //printf(" level=%d title=%s\n",level,qPrint(si->title));
1430 int nextLevel = type.level();
1431 if (nextLevel>level)
1432 {
1433 for (int l=level;l<nextLevel;l++)
1434 {
1435 if (l < maxLevel) m_t << " <tocdiv>\n";
1436 }
1437 }
1438 else if (nextLevel<level)
1439 {
1440 for (int l=level;l>nextLevel;l--)
1441 {
1442 inLi[l]=FALSE;
1443 if (l <= maxLevel) m_t << " </tocdiv>\n";
1444 }
1445 }
1446 if (nextLevel <= maxLevel)
1447 {
1448 QCString titleDoc = convertToDocBook(si->title());
1449 QCString label = convertToDocBook(si->label());
1450 if (titleDoc.isEmpty()) titleDoc = label;
1451 m_t << " <tocentry>" << titleDoc << "</tocentry>\n";
1452 }
1453 inLi[nextLevel]=TRUE;
1454 level = nextLevel;
1455 }
1456 }
1457 if (level > maxLevel) level = maxLevel;
1458 while (level>1 && level <= maxLevel)
1459 {
1460 inLi[level]=FALSE;
1461 m_t << "</tocdiv>\n";
1462 level--;
1463 }
1464 m_t << " </toc>\n";
1465 }
1466}
1467
1468//-------------------------------------------------------------------------------------------------
1469
1470static constexpr auto hex="0123456789ABCDEF";
1471
1472/*! Converts a string to an DocBook-encoded string */
1473QCString convertToDocBook(const QCString &s, const bool retainNewline)
1474{
1475 if (s.isEmpty()) return s;
1476 GrowBuf growBuf;
1477 const char *p = s.data();
1478 const char *q = nullptr;
1479 int cnt = 0;
1480 char c = 0;
1481 while ((c=*p++))
1482 {
1483 switch (c)
1484 {
1485 case '\n': if (retainNewline) growBuf.addStr("<literallayout>&#160;&#xa;</literallayout>"); growBuf.addChar(c); break;
1486 case '<': growBuf.addStr("&lt;"); break;
1487 case '>': growBuf.addStr("&gt;"); break;
1488 case '&': // possibility to have a special symbol
1489 q = p;
1490 cnt = 2; // we have to count & and ; as well
1491 while ((*q >= 'a' && *q <= 'z') || (*q >= 'A' && *q <= 'Z') || (*q >= '0' && *q <= '9'))
1492 {
1493 cnt++;
1494 q++;
1495 }
1496 if (*q == ';')
1497 {
1498 --p; // we need & as well
1501 {
1502 p++;
1503 growBuf.addStr("&amp;");
1504 }
1505 else
1506 {
1507 growBuf.addStr(HtmlEntityMapper::instance().docbook(res));
1508 q++;
1509 p = q;
1510 }
1511 }
1512 else
1513 {
1514 growBuf.addStr("&amp;");
1515 }
1516 break;
1517 case '\'': growBuf.addStr("&apos;"); break;
1518 case '"': growBuf.addStr("&quot;"); break;
1519 case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
1520 case 11: case 12: case 14: case 15: case 16: case 17: case 18:
1521 case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26:
1522 case 27: case 28: case 29: case 30: case 31:
1523 growBuf.addStr("&#x24");
1524 growBuf.addChar(hex[static_cast<uint8_t>(c)>>4]);
1525 growBuf.addChar(hex[static_cast<uint8_t>(c)&0xF]);
1526 growBuf.addChar(';');
1527 break;
1528 default:
1529 growBuf.addChar(c);
1530 break;
1531 }
1532 }
1533 growBuf.addChar(0);
1534 return growBuf.get();
1535}
1536
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
bool mkdir(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:295
bool exists() const
Definition dir.cpp:257
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
void endInlineMemberName() override
void writeRuler() override
void startParameterList(bool) 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:325
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:317
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:326
void startMemberGroupHeader(bool) override
void startConstraintType() 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
void endGroupCollaboration(DotGroupCollaboration &g) override
void endTextBlock(bool) override
void endInlineMemberDoc() override
void endMemberHeader() override
void startMemberDocList() 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:331
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 startGroupHeader(int) 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 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:330
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 writeLocalToc(const SectionRefs &sr, const LocalToc &lt) override
void endDescTable() override
void endFile() override
void endConstraintParam() override
void endInlineMemberType() override
void startPlainFile(const QCString &name) override
Definition docbookgen.h:316
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 endConstraintList() override
QCString m_pageLinks
Definition docbookgen.h:337
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:49
int docbookLevel() const
Definition types.h:461
bool isDocbookEnabled() const
Definition types.h:456
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:526
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 represents a list of constant references to sections.
Definition section.h:102
Text streaming class that buffers data.
Definition textstream.h:36
virtual QCString trInheritedFrom(const QCString &members, const QCString &what)=0
virtual QCString trISOLang()=0
virtual QCString trEnumerationValues()=0
virtual QCString trRTFTableOfContents()=0
virtual QCString trCompoundMembers()=0
virtual QCString 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
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:94
OutputCodeDefer< DocbookCodeGenerator > DocbookCodeGeneratorDefer
Definition outputlist.h:105
const char * qPrint(const char *s)
Definition qcstring.h:661
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
CodeSymbolType
Definition types.h:319
size_t updateColumnCount(const char *s, size_t col)
Definition util.cpp:7207
QCString stripPath(const QCString &s)
Definition util.cpp:5292
QCString relativePathToRoot(const QCString &name)
Definition util.cpp:3933
void clearSubDirs(const Dir &d)
Definition util.cpp:4021
QCString stripExtensionGeneral(const QCString &fName, const QCString &ext)
Definition util.cpp:5255
void createSubDirs(const Dir &d)
Definition util.cpp:3994
A bunch of utility functions.