From 2e3c07357f208033b502bb6cc5ae015ff76668de Mon Sep 17 00:00:00 2001 From: albert-github Date: Fri, 23 Nov 2018 18:35:29 +0100 Subject: Doxygen creates empty image titles for Docbook output The title of an image needs to be at a specific place in docbook. The current place was incorrect (based on https://stackoverflow.com/questions/53448764/doxygen-creates-empty-image-titles-for-docbook-output) --- src/docbookgen.cpp | 3 ++- src/docbookvisitor.cpp | 54 ++++++++++++++++++++++++++++---------------------- src/docbookvisitor.h | 17 +++++++++------- 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp index 48b5d9e..6464701 100644 --- a/src/docbookgen.cpp +++ b/src/docbookgen.cpp @@ -904,7 +904,8 @@ DB_GEN_C void DocbookGenerator::endClassDiagram(const ClassDiagram &d, const char *fileName,const char *) { DB_GEN_C - visitPreStart(t, FALSE, relPath + fileName + ".png", NULL, NULL); + QList dummy; + visitPreStart(t, FALSE, NULL, dummy, relPath + fileName + ".png", NULL, NULL); d.writeImage(t,dir,relPath,fileName,FALSE); visitPostEnd(t, FALSE); t << "" << endl; diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index 7a948ec..debb7d7 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -49,12 +49,22 @@ #define DB_VIS_C2a(x,y) #endif -void visitPreStart(FTextStream &t, bool hasCaption, QCString name, QCString width, QCString height, bool inlineImage) +static void visitCaption(DocbookDocVisitor *parent, QList children) +{ + QListIterator cli(children); + DocNode *n; + for (cli.toFirst();(n=cli.current());++cli) n->accept(parent); +} + +void visitPreStart(FTextStream &t, bool hasCaption, DocbookDocVisitor *parent, QList children, QCString name, QCString width, QCString height, bool inlineImage) { QCString tmpStr; if (hasCaption) { t << "
" << endl; + t << " " << endl; + visitCaption(parent, children); + t << " " << endl; } else { @@ -80,7 +90,7 @@ void visitPreStart(FTextStream &t, bool hasCaption, QCString name, QCString wid t << " " << endl; if (hasCaption) { - t << " " << endl; + t << " <!--" << endl; // Needed for general formatting with title for other formats } } @@ -89,7 +99,7 @@ void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage) t << endl; if (hasCaption) { - t << " " << endl; + t << " -->" << endl; // Needed for general formatting with title for other formats } t << " " << endl; if (hasCaption) @@ -102,13 +112,6 @@ void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage) } } -static void visitCaption(DocbookDocVisitor *parent, QList children) -{ - QListIterator cli(children); - DocNode *n; - for (cli.toFirst();(n=cli.current());++cli) n->accept(parent); -} - DocbookDocVisitor::DocbookDocVisitor(FTextStream &t,CodeOutputInterface &ci) : DocVisitor(DocVisitor_Docbook), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) { @@ -1165,7 +1168,7 @@ DB_VIS_C { baseName=baseName.right(baseName.length()-i-1); } - visitPreStart(m_t, img -> hasCaption(), img->relPath() + baseName, img -> width(), img -> height(),img -> isInlineImage()); + visitPreStart(m_t, img -> hasCaption(), this, img->children(), img->relPath() + baseName, img -> width(), img -> height(),img -> isInlineImage()); } else { @@ -1219,7 +1222,7 @@ void DocbookDocVisitor::visitPre(DocDotFile *df) { DB_VIS_C if (m_hide) return; - startDotFile(df->file(),df->width(),df->height(),df->hasCaption()); + startDotFile(df->file(),df->width(),df->height(),df->hasCaption(),df->children()); } void DocbookDocVisitor::visitPost(DocDotFile *df) @@ -1233,7 +1236,7 @@ void DocbookDocVisitor::visitPre(DocMscFile *df) { DB_VIS_C if (m_hide) return; - startMscFile(df->file(),df->width(),df->height(),df->hasCaption()); + startMscFile(df->file(),df->width(),df->height(),df->hasCaption(),df->children()); } void DocbookDocVisitor::visitPost(DocMscFile *df) @@ -1246,7 +1249,7 @@ void DocbookDocVisitor::visitPre(DocDiaFile *df) { DB_VIS_C if (m_hide) return; - startDiaFile(df->file(),df->width(),df->height(),df->hasCaption()); + startDiaFile(df->file(),df->width(),df->height(),df->hasCaption(),df->children()); } void DocbookDocVisitor::visitPost(DocDiaFile *df) @@ -1619,7 +1622,7 @@ DB_VIS_C } QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeMscGraphFromFile(baseName+".msc",outDir,shortName,MSC_BITMAP); - visitPreStart(m_t, s->hasCaption(), s->relPath() + shortName + ".png", s->width(),s->height()); + visitPreStart(m_t, s->hasCaption(), this, s->children(), s->relPath() + shortName + ".png", s->width(),s->height()); visitCaption(this, s->children()); visitPostEnd(m_t, s->hasCaption()); } @@ -1635,7 +1638,7 @@ DB_VIS_C } QCString outDir = Config_getString(DOCBOOK_OUTPUT); generatePlantUMLOutput(baseName,outDir,PUML_BITMAP); - visitPreStart(m_t, s->hasCaption(), s->relPath() + shortName + ".png", s->width(),s->height()); + visitPreStart(m_t, s->hasCaption(), this, s->children(), s->relPath() + shortName + ".png", s->width(),s->height()); visitCaption(this, s->children()); visitPostEnd(m_t, s->hasCaption()); } @@ -1643,7 +1646,8 @@ DB_VIS_C void DocbookDocVisitor::startMscFile(const QCString &fileName, const QCString &width, const QCString &height, - bool hasCaption + bool hasCaption, + QList childs ) { DB_VIS_C @@ -1661,7 +1665,7 @@ DB_VIS_C QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeMscGraphFromFile(fileName,outDir,baseName,MSC_BITMAP); m_t << "" << endl; - visitPreStart(m_t, hasCaption, baseName + ".png", width, height); + visitPreStart(m_t, hasCaption,this, childs, baseName + ".png", width, height); } void DocbookDocVisitor::endMscFile(bool hasCaption) @@ -1683,7 +1687,7 @@ DB_VIS_C } QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDiaGraphFromFile(baseName+".dia",outDir,shortName,DIA_BITMAP); - visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height()); + visitPreStart(m_t, s->hasCaption(), this, s->children(), shortName, s->width(),s->height()); visitCaption(this, s->children()); visitPostEnd(m_t, s->hasCaption()); } @@ -1691,7 +1695,8 @@ DB_VIS_C void DocbookDocVisitor::startDiaFile(const QCString &fileName, const QCString &width, const QCString &height, - bool hasCaption + bool hasCaption, + QList childs ) { DB_VIS_C @@ -1709,7 +1714,7 @@ DB_VIS_C QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP); m_t << "" << endl; - visitPreStart(m_t, hasCaption, baseName + ".png", width, height); + visitPreStart(m_t, hasCaption, this, childs, baseName + ".png", width, height); } void DocbookDocVisitor::endDiaFile(bool hasCaption) @@ -1731,7 +1736,7 @@ DB_VIS_C } QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDotGraphFromFile(baseName+".dot",outDir,shortName,GOF_BITMAP); - visitPreStart(m_t, s->hasCaption(), s->relPath() + shortName + "." + getDotImageExtension(), s->width(),s->height()); + visitPreStart(m_t, s->hasCaption(), this, s->children(), s->relPath() + shortName + "." + getDotImageExtension(), s->width(),s->height()); visitCaption(this, s->children()); visitPostEnd(m_t, s->hasCaption()); } @@ -1739,7 +1744,8 @@ DB_VIS_C void DocbookDocVisitor::startDotFile(const QCString &fileName, const QCString &width, const QCString &height, - bool hasCaption + bool hasCaption, + QList childs ) { DB_VIS_C @@ -1758,7 +1764,7 @@ DB_VIS_C QCString imgExt = getDotImageExtension(); writeDotGraphFromFile(fileName,outDir,baseName,GOF_BITMAP); m_t << "" << endl; - visitPreStart(m_t, hasCaption, baseName + "." + imgExt, width, height); + visitPreStart(m_t, hasCaption, this, childs, baseName + "." + imgExt, width, height); } void DocbookDocVisitor::endDotFile(bool hasCaption) diff --git a/src/docbookvisitor.h b/src/docbookvisitor.h index 714b679..87035f8 100644 --- a/src/docbookvisitor.h +++ b/src/docbookvisitor.h @@ -20,16 +20,14 @@ #include "docvisitor.h" #include +#include #include +#include class FTextStream; class CodeOutputInterface; class QCString; -void visitPreStart(FTextStream &t, bool hasCaption, QCString name, QCString width, QCString height, bool inlineImage=FALSE); -void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage = FALSE); - -/*! @brief Concrete visitor implementation for Docbook output. */ class DocbookDocVisitor : public DocVisitor { public: @@ -150,15 +148,15 @@ class DocbookDocVisitor : public DocVisitor void pushEnabled(); void popEnabled(); void startMscFile(const QCString &fileName,const QCString &width, - const QCString &height, bool hasCaption); + const QCString &height, bool hasCaption,QList childs); void endMscFile(bool hasCaption); void writeMscFile(const QCString &fileName, DocVerbatim *s); void startDiaFile(const QCString &fileName,const QCString &width, - const QCString &height, bool hasCaption); + const QCString &height, bool hasCaption,QList childs); void endDiaFile(bool hasCaption); void writeDiaFile(const QCString &fileName, DocVerbatim *s); void startDotFile(const QCString &fileName,const QCString &width, - const QCString &height, bool hasCaption); + const QCString &height, bool hasCaption,QList childs); void endDotFile(bool hasCaption); void writeDotFile(const QCString &fileName, DocVerbatim *s); void writePlantUMLFile(const QCString &fileName, DocVerbatim *s); @@ -173,4 +171,9 @@ class DocbookDocVisitor : public DocVisitor QCString m_langExt; }; +void visitPreStart(FTextStream &t, bool hasCaption, DocbookDocVisitor *parent, QList children, QCString name, QCString width, QCString height, bool inlineImage=FALSE); +void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage = FALSE); + +/*! @brief Concrete visitor implementation for Docbook output. */ + #endif -- cgit v0.12 From 3820f6a841115bd66ed409221c73824ec41ae6ab Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sat, 24 Nov 2018 19:57:34 +0100 Subject: Refactored code a bit (use const references and made global functions members) --- src/docbookgen.cpp | 11 ++++++++--- src/docbookvisitor.cpp | 49 +++++++++++++++++++++++++++---------------------- src/docbookvisitor.h | 21 +++++++++++++-------- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp index 6464701..97c602d 100644 --- a/src/docbookgen.cpp +++ b/src/docbookgen.cpp @@ -904,10 +904,15 @@ DB_GEN_C void DocbookGenerator::endClassDiagram(const ClassDiagram &d, const char *fileName,const char *) { DB_GEN_C - QList dummy; - visitPreStart(t, FALSE, NULL, dummy, relPath + fileName + ".png", NULL, NULL); + t << " " << endl; + t << " " << endl; + t << " " << endl; + t << " " << "" << endl; + t << " " << endl; d.writeImage(t,dir,relPath,fileName,FALSE); - visitPostEnd(t, FALSE); + t << " " << endl; + t << " " << endl; t << "" << endl; } void DocbookGenerator::startLabels() diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index debb7d7..51d1755 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -49,21 +49,26 @@ #define DB_VIS_C2a(x,y) #endif -static void visitCaption(DocbookDocVisitor *parent, QList children) +void DocbookDocVisitor::visitCaption(const QList &children) { QListIterator cli(children); DocNode *n; - for (cli.toFirst();(n=cli.current());++cli) n->accept(parent); + for (cli.toFirst();(n=cli.current());++cli) n->accept(this); } -void visitPreStart(FTextStream &t, bool hasCaption, DocbookDocVisitor *parent, QList children, QCString name, QCString width, QCString height, bool inlineImage) +void DocbookDocVisitor::visitPreStart(FTextStream &t, + const QList &children, + bool hasCaption, + const QCString &name, + const QCString &width, + const QCString &height, + bool inlineImage) { - QCString tmpStr; if (hasCaption) { t << "
" << endl; t << " " << endl; - visitCaption(parent, children); + visitCaption(children); t << " " << endl; } else @@ -83,7 +88,7 @@ void visitPreStart(FTextStream &t, bool hasCaption, DocbookDocVisitor *parent, Q } if (!height.isEmpty()) { - t << " depth=\"" << convertToDocBook(tmpStr) << "\""; + t << " depth=\"" << convertToDocBook(height) << "\""; } t << " align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" << name << "\">"; t << "" << endl; @@ -94,7 +99,7 @@ void visitPreStart(FTextStream &t, bool hasCaption, DocbookDocVisitor *parent, Q } } -void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage) +void DocbookDocVisitor::visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage) { t << endl; if (hasCaption) @@ -1168,7 +1173,7 @@ DB_VIS_C { baseName=baseName.right(baseName.length()-i-1); } - visitPreStart(m_t, img -> hasCaption(), this, img->children(), img->relPath() + baseName, img -> width(), img -> height(),img -> isInlineImage()); + visitPreStart(m_t, img->children(), img->hasCaption(), img->relPath() + baseName, img->width(), img->height(), img->isInlineImage()); } else { @@ -1622,8 +1627,8 @@ DB_VIS_C } QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeMscGraphFromFile(baseName+".msc",outDir,shortName,MSC_BITMAP); - visitPreStart(m_t, s->hasCaption(), this, s->children(), s->relPath() + shortName + ".png", s->width(),s->height()); - visitCaption(this, s->children()); + visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + ".png", s->width(), s->height()); + visitCaption(s->children()); visitPostEnd(m_t, s->hasCaption()); } @@ -1638,8 +1643,8 @@ DB_VIS_C } QCString outDir = Config_getString(DOCBOOK_OUTPUT); generatePlantUMLOutput(baseName,outDir,PUML_BITMAP); - visitPreStart(m_t, s->hasCaption(), this, s->children(), s->relPath() + shortName + ".png", s->width(),s->height()); - visitCaption(this, s->children()); + visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + ".png", s->width(),s->height()); + visitCaption(s->children()); visitPostEnd(m_t, s->hasCaption()); } @@ -1647,7 +1652,7 @@ void DocbookDocVisitor::startMscFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, - QList childs + const QList &children ) { DB_VIS_C @@ -1665,7 +1670,7 @@ DB_VIS_C QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeMscGraphFromFile(fileName,outDir,baseName,MSC_BITMAP); m_t << "" << endl; - visitPreStart(m_t, hasCaption,this, childs, baseName + ".png", width, height); + visitPreStart(m_t, children, hasCaption, baseName + ".png", width, height); } void DocbookDocVisitor::endMscFile(bool hasCaption) @@ -1687,8 +1692,8 @@ DB_VIS_C } QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDiaGraphFromFile(baseName+".dia",outDir,shortName,DIA_BITMAP); - visitPreStart(m_t, s->hasCaption(), this, s->children(), shortName, s->width(),s->height()); - visitCaption(this, s->children()); + visitPreStart(m_t, s->children(), s->hasCaption(), shortName, s->width(),s->height()); + visitCaption(s->children()); visitPostEnd(m_t, s->hasCaption()); } @@ -1696,7 +1701,7 @@ void DocbookDocVisitor::startDiaFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, - QList childs + const QList &children ) { DB_VIS_C @@ -1714,7 +1719,7 @@ DB_VIS_C QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP); m_t << "" << endl; - visitPreStart(m_t, hasCaption, this, childs, baseName + ".png", width, height); + visitPreStart(m_t, children, hasCaption, baseName + ".png", width, height); } void DocbookDocVisitor::endDiaFile(bool hasCaption) @@ -1736,8 +1741,8 @@ DB_VIS_C } QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDotGraphFromFile(baseName+".dot",outDir,shortName,GOF_BITMAP); - visitPreStart(m_t, s->hasCaption(), this, s->children(), s->relPath() + shortName + "." + getDotImageExtension(), s->width(),s->height()); - visitCaption(this, s->children()); + visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + "." + getDotImageExtension(), s->width(),s->height()); + visitCaption(s->children()); visitPostEnd(m_t, s->hasCaption()); } @@ -1745,7 +1750,7 @@ void DocbookDocVisitor::startDotFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, - QList childs + const QList &children ) { DB_VIS_C @@ -1764,7 +1769,7 @@ DB_VIS_C QCString imgExt = getDotImageExtension(); writeDotGraphFromFile(fileName,outDir,baseName,GOF_BITMAP); m_t << "" << endl; - visitPreStart(m_t, hasCaption, this, childs, baseName + "." + imgExt, width, height); + visitPreStart(m_t, children, hasCaption, baseName + "." + imgExt, width, height); } void DocbookDocVisitor::endDotFile(bool hasCaption) diff --git a/src/docbookvisitor.h b/src/docbookvisitor.h index 87035f8..24b1fbb 100644 --- a/src/docbookvisitor.h +++ b/src/docbookvisitor.h @@ -28,6 +28,7 @@ class FTextStream; class CodeOutputInterface; class QCString; +/*! @brief Concrete visitor implementation for Docbook output. */ class DocbookDocVisitor : public DocVisitor { public: @@ -148,18 +149,27 @@ class DocbookDocVisitor : public DocVisitor void pushEnabled(); void popEnabled(); void startMscFile(const QCString &fileName,const QCString &width, - const QCString &height, bool hasCaption,QList childs); + const QCString &height, bool hasCaption,const QList &children); void endMscFile(bool hasCaption); void writeMscFile(const QCString &fileName, DocVerbatim *s); void startDiaFile(const QCString &fileName,const QCString &width, - const QCString &height, bool hasCaption,QList childs); + const QCString &height, bool hasCaption,const QList &children); void endDiaFile(bool hasCaption); void writeDiaFile(const QCString &fileName, DocVerbatim *s); void startDotFile(const QCString &fileName,const QCString &width, - const QCString &height, bool hasCaption,QList childs); + const QCString &height, bool hasCaption,const QList &children); void endDotFile(bool hasCaption); void writeDotFile(const QCString &fileName, DocVerbatim *s); void writePlantUMLFile(const QCString &fileName, DocVerbatim *s); + void visitPreStart(FTextStream &t, + const QList &children, + bool hasCaption, + const QCString &name, + const QCString &width, + const QCString &height, + bool inlineImage = FALSE); + void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage = FALSE); + void visitCaption(const QList &children); //-------------------------------------- // state variables //-------------------------------------- @@ -171,9 +181,4 @@ class DocbookDocVisitor : public DocVisitor QCString m_langExt; }; -void visitPreStart(FTextStream &t, bool hasCaption, DocbookDocVisitor *parent, QList children, QCString name, QCString width, QCString height, bool inlineImage=FALSE); -void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage = FALSE); - -/*! @brief Concrete visitor implementation for Docbook output. */ - #endif -- cgit v0.12