22 #include <qtextstream.h>
51 #define Docbook_DB(x) do {} while(0)
120 int spacesToNextTabStop = tabSize - (col%tabSize);
121 col+=spacesToNextTabStop;
122 while (spacesToNextTabStop--) t <<
" ";
125 case ' ': t <<
" "; col++;
break;
126 case '<': t <<
"<"; col++;
break;
127 case '>': t <<
">"; col++;
break;
128 case '&': t <<
"&"; col++;
break;
129 case '\'': t <<
"'"; col++;
break;
130 case '"': t <<
"""; col++;
break;
131 default: t << c; col++;
break;
138 t <<
"<?xml version='1.0' encoding='UTF-8' standalone='no'?>" <<
endl;;
139 t <<
"<chapter xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" <<
endl;
144 t <<
"<?xml version='1.0' encoding='UTF-8' standalone='no'?>" <<
endl;;
145 t <<
"<section xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:id=\"" <<
id <<
"\">" <<
endl;
149 const char *anchorId,
const char * text,
const char * )
151 t <<
"<link linkend=\"" << compoundId;
152 if (anchorId) t <<
"_1" << anchorId;
169 const char *anchor,
const char *text
191 const char *anchor,
const char *name,
211 m_t <<
"<link linkend=\"" <<
m_refId <<
"\">";
234 m_t <<
"<emphasis class=\"" << colorClass <<
"\">";
240 m_t <<
"</emphasis>";
248 const char *anchorId,
int l)
257 if (anchorId)
m_refId+=(QCString)
"_1"+anchorId;
290 indentStr.fill(
' ',indent);
293 t << indentStr <<
"<templateparamlist>" <<
endl;
296 for (ali.toFirst();(a=ali.current());++ali)
298 t << indentStr <<
" <param>" <<
endl;
299 if (!a->
type.isEmpty())
301 t << indentStr <<
" <type>";
303 t <<
"</type>" <<
endl;
305 if (!a->
name.isEmpty())
307 t << indentStr <<
" <declname>" << a->
name <<
"</declname>" <<
endl;
308 t << indentStr <<
" <defname>" << a->
name <<
"</defname>" <<
endl;
312 t << indentStr <<
" <defval>";
314 t <<
"</defval>" <<
endl;
316 t << indentStr <<
" </param>" <<
endl;
318 t << indentStr <<
"</templateparamlist>" <<
endl;
328 const QCString &fileName,
332 const QCString &text)
334 QCString stext = text.stripWhiteSpace();
335 if (stext.isEmpty())
return;
346 delete docbookCodeGen;
446 t <<
" <para>" <<
endl;
447 t <<
" <itemizedlist>" <<
endl;
448 t <<
" <listitem>" <<
endl;
454 t <<
" <para><literallayout>" << memType <<
" <link linkend=\"";
470 for (emli.toFirst();(emd=emli.current());++emli)
487 t <<
"</literallayout>" <<
endl;
490 t <<
"<para><emphasis>";
492 t <<
"</emphasis></para>" <<
endl;
497 t <<
" <para>" <<
"#" << memType <<
" <link linkend=\"";
514 t <<
"<para><emphasis>";
516 t <<
"</emphasis></para>" <<
endl;
526 t <<
"<para><emphasis>";
528 t <<
"</emphasis></para>";
535 t <<
" <link linkend=\"";
547 t <<
"<para><emphasis>";
549 t <<
"</emphasis></para>" <<
endl;
555 t <<
" <para>" << memType;
559 t <<
" <link linkend=\"";
571 t <<
"<para><emphasis>";
573 t <<
"</emphasis></para>" <<
endl;
580 t <<
" <link linkend=\"";
592 if (declAl && declAl->count()>0)
597 for (declAli.toFirst();(a=declAli.current());++declAli)
603 if (!a->
type.isEmpty())
608 if (!a->
name.isEmpty())
618 t <<
"<para><emphasis>";
620 t <<
"</emphasis></para>" <<
endl;
627 if (closePara) t <<
"</para>" <<
endl;
628 t <<
" </listitem>" <<
endl;
629 t <<
" </itemizedlist>" <<
endl;
630 t <<
" </para>" <<
endl;
637 t <<
" <section xml:id=\"";
655 t <<
" <formalpara>" <<
endl;
657 t <<
" <variablelist>" <<
endl;
658 for (emli.toFirst();(emd=emli.current());++emli)
660 t <<
" <varlistentry xml:id=\"";
664 t <<
"</term>" <<
endl;
665 t <<
" <listitem>" <<
endl;
670 t <<
"</para>" <<
endl;
672 t <<
" </listitem>" <<
endl;
673 t <<
" </varlistentry>" <<
endl;
675 t <<
" </variablelist>" <<
endl;
676 t <<
" </formalpara>" <<
endl;
679 t <<
" <computeroutput><literallayout>" <<
endl;
681 for (emli.toFirst();(emd=emli.current());++emli)
691 t <<
" </literallayout></computeroutput>" <<
endl;
692 t <<
" </para>" <<
endl;
693 t <<
" </section>" <<
endl;
698 t <<
" <section xml:id=\"";
713 t <<
"</emphasis>" <<
endl;
718 t <<
" </section>" <<
endl;
722 t <<
" <section xml:id=\"";
737 t <<
"</emphasis>" <<
endl;
742 t <<
" </section>" <<
endl;
748 t <<
" <section xml:id=\"";
763 t <<
" <para>The Documentation for this define was generated from the following file: </para>" <<
endl;
764 t <<
" <para><itemizedlist><listitem><para>" <<
stripPath(md->
getDefFileName()) <<
"</para></listitem></itemizedlist></para>" << endl;
765 t <<
" </section>" <<
endl;
774 t <<
" <simplesect>" <<
endl;
780 t <<
" <para>The Documentation for this struct was generated from the following file: </para>" <<
endl;
781 t <<
" <para><itemizedlist><listitem><para>" <<
stripPath(md->
getDefFileName()) <<
"</para></listitem></itemizedlist></para>" << endl;
782 t <<
" </simplesect>" <<
endl;
787 t <<
" <section xml:id=\"";
802 t <<
"</emphasis>" <<
endl;
807 t <<
" </section>" <<
endl;
814 bool detailed=0,
const char *header=0,
const char *documentation=0)
821 QCString title, desctitle;
823 for (mli.toFirst();(md=mli.current());++mli)
833 if (count==0)
return;
845 default: title=
""; desctitle=
"";
break;
850 for (mli.toFirst();(md=mli.current());++mli)
867 t <<
" <section>" <<
endl;
868 t <<
" <title>" << desctitle <<
"</title>" <<
endl;
872 t <<
" <section>" <<
endl;
879 t <<
" <title>" << title <<
"</title>" <<
endl;
885 t <<
" <description>";
887 t <<
"</description>" <<
endl;
889 for (mli.toFirst();(md=mli.current());++mli)
907 t <<
" </section>" <<
endl;
912 t <<
" </section>" <<
endl;
926 t <<
" <section>" <<
endl;
927 t <<
" <title> " << title <<
" </title>" <<
endl;
929 for (cli.toFirst();(cd=cli.current());++cli)
933 t <<
" <para>" <<
endl;
934 t <<
" <itemizedlist>" <<
endl;
935 t <<
" <listitem>" <<
endl;
937 t <<
"</para>" <<
endl;
940 t <<
"<para><emphasis>";
942 t <<
"</emphasis></para>" <<
endl;
944 t <<
" </listitem>" <<
endl;
945 t <<
" </itemizedlist>" <<
endl;
946 t <<
" </para>" <<
endl;
951 t <<
" </section>" <<
endl;
966 t <<
" <simplesect>" <<
endl;
967 t <<
" <title> " << title <<
" </title>" <<
endl;
969 for (nli.toFirst();(nd=nli.current());++nli)
973 t <<
" <para>" <<
endl;
974 t <<
" <itemizedlist>" <<
endl;
975 t <<
" <listitem>" <<
endl;
977 t <<
"</para>" <<
endl;
978 t <<
" </listitem>" <<
endl;
979 t <<
" </itemizedlist>" <<
endl;
980 t <<
" </para>" <<
endl;
985 t <<
" </simplesect>" <<
endl;
994 QListIterator<FileDef> fli(*fl);
1000 t <<
" <simplesect>" <<
endl;
1001 t <<
" <title> " << title <<
" </title>" <<
endl;
1003 for (fli.toFirst();(fd=fli.current());++fli)
1005 t <<
" <para>" <<
endl;
1006 t <<
" <itemizedlist>" <<
endl;
1007 t <<
" <listitem>" <<
endl;
1009 t <<
"</para>" <<
endl;
1010 t <<
" </listitem>" <<
endl;
1011 t <<
" </itemizedlist>" <<
endl;
1012 t <<
" </para>" <<
endl;
1016 t <<
" </simplesect>" <<
endl;
1028 for (pli.toFirst();(pd=pli.current());++pli)
1030 t <<
"<xi:include href=\"" << pd->
getOutputFileBase() <<
".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" <<
endl;
1045 t <<
" <simplesect>" <<
endl;
1047 t <<
" </simplesect>" <<
endl;
1048 t <<
" <para>" <<
endl;
1049 t <<
" <itemizedlist>" <<
endl;
1052 for (gli.toFirst();(sgd=gli.current());++gli)
1060 t <<
" </itemizedlist>" <<
endl;
1061 t <<
" </para>" <<
endl;
1071 QListIterator<DirDef> subdirs(*dl);
1074 if (subdirs.toFirst())
1076 t <<
" <simplesect>" <<
endl;
1077 t <<
" <title> " << title <<
" </title>" <<
endl;
1079 for (subdirs.toFirst();(subdir=subdirs.current());++subdirs)
1081 t <<
" <para>" <<
endl;
1082 t <<
" <itemizedlist>" <<
endl;
1083 t <<
" <listitem>" <<
endl;
1085 t <<
"</para>" <<
endl;
1086 t <<
" </listitem>" <<
endl;
1087 t <<
" </itemizedlist>" <<
endl;
1088 t <<
" </para>" <<
endl;
1090 if (subdirs.toFirst())
1092 t <<
" </simplesect>" <<
endl;
1104 for (gli.toFirst();(sgd=gli.current());++gli)
1106 t <<
"<xi:include href=\"" << sgd->
getOutputFileBase() <<
".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" <<
endl;
1131 if (cd->
name().find(
'@')!=-1)
return;
1134 msg(
"Generating Docbook output for class %s\n",cd->
name().data());
1138 ti <<
" <xi:include href=\"" << fileDocbook <<
"\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" <<
endl;
1144 if (!f.open(IO_WriteOnly))
1146 err(
"Cannot open file %s for writing!\n",fileName.data());
1156 t <<
"</title>" <<
endl;
1165 t <<
"<para>" <<
endl;
1166 t <<
" <programlisting>#include ";
1192 t <<
"</programlisting>" <<
endl;
1193 t <<
"</para>" <<
endl;
1199 t <<
"<para>Inheritance diagram for " <<
convertToXML(cd->
name()) <<
"</para>" << endl;
1206 t <<
"<para>Collaboration diagram for " <<
convertToXML(cd->
name()) <<
"</para>" << endl;
1218 for (;(mg=mgli.current());++mgli)
1221 mg->documentation());
1228 for (mli.toFirst();(ml=mli.current());++mli)
1240 t <<
" <simplesect>" <<
endl;
1244 t <<
" </simplesect>" <<
endl;
1250 t <<
" <simplesect>" <<
endl;
1254 t <<
" <para>The Documentation for this struct was generated from the following file: </para>" <<
endl;
1255 t <<
" <para><itemizedlist><listitem><para>" <<
stripPath(cd->
getDefFileName()) <<
"</para></listitem></itemizedlist></para>" << endl;
1256 t <<
" </simplesect>" <<
endl;
1258 for (mli.toFirst();(ml=mli.current());++mli)
1298 t <<
"</section>" <<
endl;
1317 ti <<
" <xi:include href=\"" << fileDocbook <<
"\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" <<
endl;
1322 if (!f.open(IO_WriteOnly))
1324 err(
"Cannot open file %s for writing!\n",fileName.data());
1333 t <<
"</title>" <<
endl;
1342 for (;(mg=mgli.current());++mgli)
1351 for (mli.toFirst();(ml=mli.current());++mli)
1363 t <<
" <simplesect>" <<
endl;
1366 t <<
" </simplesect>" <<
endl;
1372 t <<
" <simplesect>" <<
endl;
1376 t <<
" <para>The Documentation for this struct was generated from the following file: </para>" <<
endl;
1377 t <<
" <para><itemizedlist><listitem><para>" <<
stripPath(nd->
getDefFileName()) <<
"</para></listitem></itemizedlist></para>" << endl;
1378 t <<
" </simplesect>" <<
endl;
1380 t <<
"</section>" <<
endl;
1403 ti <<
" <xi:include href=\"" << fileDocbook <<
"\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" <<
endl;
1410 if (!f.open(IO_WriteOnly))
1412 err(
"Cannot open file %s for writing!\n",fileName.data());
1421 t <<
" File Reference";
1422 t <<
"</title>" <<
endl;
1429 for (ili1.toFirst();(inc=ili1.current());++ili1)
1431 t <<
" <programlisting>#include ";
1449 t <<
"</programlisting>" <<
endl;
1456 t <<
"<para>Include dependency diagram for " <<
convertToXML(fd->
name()) <<
"</para>" << endl;
1462 t <<
"<para>Included by dependency diagram for " <<
convertToXML(fd->
name()) <<
"</para>" << endl;
1481 for (;(mg=mgli.current());++mgli)
1490 for (mli.toFirst();(ml=mli.current());++mli)
1498 t <<
" <simplesect>" <<
endl;
1510 t <<
" </simplesect>" <<
endl;
1514 t <<
" <literallayout><computeroutput>" <<
endl;
1516 t <<
" </computeroutput></literallayout>" <<
endl;
1519 t <<
"</section>" <<
endl;
1542 ti <<
" <xi:include href=\"" << fileDocbook <<
"\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" <<
endl;
1550 if (!f.open(IO_WriteOnly))
1552 err(
"Cannot open file %s for writing!\n",fileName.data());
1579 t <<
" <section>" <<
endl;
1582 t <<
" </section>" <<
endl;
1595 for (;(mg=mgli.current());++mgli)
1598 mg->documentation());
1604 for (mli.toFirst();(ml=mli.current());++mli)
1611 for (mli.toFirst();(ml=mli.current());++mli)
1621 t <<
"</section>" <<
endl;
1631 ti <<
" <xi:include href=\"" << fileDocbook <<
"\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" <<
endl;
1638 if (!f.open(IO_WriteOnly))
1640 err(
"Cannot open file %s for writing!\n",fileName.data());
1650 t <<
"</title>" <<
endl;
1661 t <<
" <simplesect>" <<
endl;
1665 t <<
" <para>Directory location is " << dd->
name() <<
"</para>" <<
endl;
1666 t <<
" </simplesect>" <<
endl;
1668 t <<
"</section>" <<
endl;
1682 pageName+=(QCString)
"_"+pd->
name();
1684 if (pageName==
"index")
1686 pageName=
"mainpage";
1690 QCString fileName=outputDirectory+
"/"+pageName+
".xml";
1692 if (!f.open(IO_WriteOnly))
1694 err(
"Cannot open file %s for writing!\n",fileName.data());
1703 QCString fileDocbook=pageName+
".xml";
1704 ti <<
" <xi:include href=\"" << fileDocbook <<
"\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" <<
endl;
1709 QCString fileDocbook=pageName+
".xml";
1711 ti <<
" <xi:include href=\"" << fileDocbook <<
"\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" <<
endl;
1723 pid = pageName+
"_1"+pageName;
1771 if (outputDirectory.isEmpty())
1773 outputDirectory=QDir::currentDirPath().utf8();
1777 QDir dir(outputDirectory);
1780 dir.setPath(QDir::currentDirPath());
1781 if (!dir.mkdir(outputDirectory))
1783 err(
"tag DOCBOOK_OUTPUT: Output directory `%s' does not "
1784 "exist and cannot be created\n",outputDirectory.data());
1789 msg(
"Notice: Output directory `%s' does not exist. "
1790 "I have created it for you.\n", outputDirectory.data());
1792 dir.cd(outputDirectory);
1794 outputDirectory=dir.absPath().utf8();
1797 QDir dir(outputDirectory);
1800 dir.setPath(QDir::currentDirPath());
1801 if (!dir.mkdir(outputDirectory))
1803 err(
"Cannot create directory %s\n",outputDirectory.data());
1807 QDir docbookDir(outputDirectory);
1810 QCString fileName=outputDirectory+
"/index.xml";
1814 f.setName(fileName);
1815 if (!f.open(IO_WriteOnly))
1817 err(
"Cannot open file %s for writing!\n",fileName.data());
1824 t <<
"<?xml version='1.0' encoding='UTF-8' standalone='no'?>" <<
endl;;
1825 t <<
"<book xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" <<
endl;
1826 t <<
" <info>" <<
endl;
1827 t <<
" <title>" << dbk_projectName <<
"</title>" <<
endl;
1828 t <<
" </info>" <<
endl;
1837 t <<
" <chapter>" <<
endl;
1838 t <<
" <title>Namespace Documentation</title>" <<
endl;
1841 for (nli.toFirst();(nd=nli.current());++nli)
1843 msg(
"Generating Docbook output for namespace %s\n",nd->
name().data());
1850 t <<
" </chapter>" <<
endl;
1857 msg(
"Generating Docbook output for the main page\n");
1866 for (pdi.toFirst();(pd=pdi.current());++pdi)
1868 msg(
"Generating Docbook output for page %s\n",pd->
name().data());
1881 t <<
" <chapter>" <<
endl;
1885 for (;(gd=gli.current());++gli)
1887 msg(
"Generating Docbook output for group %s\n",gd->
name().data());
1894 t <<
" </chapter>" <<
endl;
1906 t <<
" <chapter>" <<
endl;
1910 for (cli.toFirst();(cd=cli.current());++cli)
1918 t <<
" </chapter>" <<
endl;
1933 t <<
" <chapter>" <<
endl;
1937 for (;(fn=fnli.current());++fnli)
1941 for (;(fd=fni.current());++fni)
1943 msg(
"Generating Docbook output for file %s\n",fd->
name().data());
1951 t <<
" </chapter>" <<
endl;
1964 t <<
" <chapter>" <<
endl;
1968 for (sdi.toFirst();(dir=sdi.current());++sdi)
1970 msg(
"Generate Docbook output for dir %s\n",dir->
name().data());
1977 t <<
" </chapter>" <<
endl;
1990 t <<
" <chapter>" <<
endl;
1994 for (pdi.toFirst();(pd=pdi.current());++pdi)
1996 msg(
"Generating Docbook output for example %s\n",pd->
name().data());
2003 t <<
" </chapter>" <<
endl;
2007 t <<
"</book>" <<
endl;