Skip to content

Commit 43150a1

Browse files
authored
Merge pull request doxygen#11912 from albert-github/feature/bug_742707
Bug 742707 Doxygen gets confused when two copies of dot file exist
2 parents be7f132 + 4693687 commit 43150a1

File tree

8 files changed

+224
-101
lines changed

8 files changed

+224
-101
lines changed

src/docbookvisitor.cpp

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,30 +1220,63 @@ void DocbookDocVisitor::operator()(const DocDotFile &df)
12201220
{
12211221
DB_VIS_C
12221222
if (m_hide) return;
1223-
if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(DOCBOOK_OUTPUT)+"/"+stripPath(df.file()));
1224-
startDotFile(df.file(),df.relPath(),df.width(),df.height(),df.hasCaption(),df.children(),df.srcFile(),df.srcLine());
1225-
visitChildren(df);
1226-
endDotFile(df.hasCaption());
1223+
bool exists = false;
1224+
std::string inBuf;
1225+
if (readInputFile(df.file(),inBuf))
1226+
{
1227+
auto fileName = writeFileContents(Config_getString(DOCBOOK_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1228+
".dot", // extension
1229+
inBuf, // contents
1230+
exists);
1231+
if (!fileName.isEmpty())
1232+
{
1233+
startDotFile(fileName,df.relPath(),df.width(),df.height(),df.hasCaption(),df.children(),df.srcFile(),df.srcLine(),!exists);
1234+
visitChildren(df);
1235+
endDotFile(df.hasCaption());
1236+
}
1237+
}
12271238
}
12281239

12291240
void DocbookDocVisitor::operator()(const DocMscFile &df)
12301241
{
12311242
DB_VIS_C
12321243
if (m_hide) return;
1233-
if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(DOCBOOK_OUTPUT)+"/"+stripPath(df.file()));
1234-
startMscFile(df.file(),df.relPath(),df.width(),df.height(),df.hasCaption(),df.children(),df.srcFile(),df.srcLine());
1235-
visitChildren(df);
1236-
endMscFile(df.hasCaption());
1244+
bool exists = false;
1245+
std::string inBuf;
1246+
if (readInputFile(df.file(),inBuf))
1247+
{
1248+
auto fileName = writeFileContents(Config_getString(DOCBOOK_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1249+
".msc", // extension
1250+
inBuf, // contents
1251+
exists);
1252+
if (!fileName.isEmpty())
1253+
{
1254+
startMscFile(fileName,df.relPath(),df.width(),df.height(),df.hasCaption(),df.children(),df.srcFile(),df.srcLine(),!exists);
1255+
visitChildren(df);
1256+
endMscFile(df.hasCaption());
1257+
}
1258+
}
12371259
}
12381260

12391261
void DocbookDocVisitor::operator()(const DocDiaFile &df)
12401262
{
12411263
DB_VIS_C
12421264
if (m_hide) return;
1243-
if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(DOCBOOK_OUTPUT)+"/"+stripPath(df.file()));
1244-
startDiaFile(df.file(),df.relPath(),df.width(),df.height(),df.hasCaption(),df.children(),df.srcFile(),df.srcLine());
1245-
visitChildren(df);
1246-
endDiaFile(df.hasCaption());
1265+
bool exists = false;
1266+
std::string inBuf;
1267+
if (readInputFile(df.file(),inBuf))
1268+
{
1269+
auto fileName = writeFileContents(Config_getString(DOCBOOK_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1270+
".dia", // extension
1271+
inBuf, // contents
1272+
exists);
1273+
if (!fileName.isEmpty())
1274+
{
1275+
startDiaFile(fileName,df.relPath(),df.width(),df.height(),df.hasCaption(),df.children(),df.srcFile(),df.srcLine(),!exists);
1276+
visitChildren(df);
1277+
endDiaFile(df.hasCaption());
1278+
}
1279+
}
12471280
}
12481281

12491282
void DocbookDocVisitor::operator()(const DocPlantUmlFile &df)
@@ -1564,14 +1597,14 @@ void DocbookDocVisitor::startMscFile(const QCString &fileName,
15641597
bool hasCaption,
15651598
const DocNodeList &children,
15661599
const QCString &srcFile,
1567-
int srcLine
1600+
int srcLine, bool newFile
15681601
)
15691602
{
15701603
DB_VIS_C
15711604
QCString baseName=makeBaseName(fileName,".msc");
15721605
baseName.prepend("msc_");
15731606
QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1574-
writeMscGraphFromFile(fileName,outDir,baseName,MscOutputFormat::BITMAP,srcFile,srcLine);
1607+
if (newFile) writeMscGraphFromFile(fileName,outDir,baseName,MscOutputFormat::BITMAP,srcFile,srcLine);
15751608
m_t << "<para>\n";
15761609
visitPreStart(m_t, children, hasCaption, relPath + baseName + ".png", width, height);
15771610
}
@@ -1602,14 +1635,14 @@ void DocbookDocVisitor::startDiaFile(const QCString &fileName,
16021635
bool hasCaption,
16031636
const DocNodeList &children,
16041637
const QCString &srcFile,
1605-
int srcLine
1638+
int srcLine, bool newFile
16061639
)
16071640
{
16081641
DB_VIS_C
16091642
QCString baseName=makeBaseName(fileName,".dia");
16101643
baseName.prepend("dia_");
16111644
QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1612-
writeDiaGraphFromFile(fileName,outDir,baseName,DiaOutputFormat::BITMAP,srcFile,srcLine);
1645+
if (newFile) writeDiaGraphFromFile(fileName,outDir,baseName,DiaOutputFormat::BITMAP,srcFile,srcLine);
16131646
m_t << "<para>\n";
16141647
visitPreStart(m_t, children, hasCaption, relPath + baseName + ".png", width, height);
16151648
}
@@ -1640,15 +1673,15 @@ void DocbookDocVisitor::startDotFile(const QCString &fileName,
16401673
bool hasCaption,
16411674
const DocNodeList &children,
16421675
const QCString &srcFile,
1643-
int srcLine
1676+
int srcLine, bool newFile
16441677
)
16451678
{
16461679
DB_VIS_C
16471680
QCString baseName=makeBaseName(fileName,".dot");
16481681
baseName.prepend("dot_");
16491682
QCString outDir = Config_getString(DOCBOOK_OUTPUT);
16501683
QCString imgExt = getDotImageExtension();
1651-
writeDotGraphFromFile(fileName,outDir,baseName,GraphOutputFormat::BITMAP,srcFile,srcLine);
1684+
if (newFile) writeDotGraphFromFile(fileName,outDir,baseName,GraphOutputFormat::BITMAP,srcFile,srcLine);
16521685
m_t << "<para>\n";
16531686
visitPreStart(m_t, children, hasCaption, relPath + baseName + "." + imgExt, width, height);
16541687
}

src/docbookvisitor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,17 @@ class DocbookDocVisitor : public DocVisitor
116116
void endLink();
117117
void startMscFile(const QCString &fileName,const QCString &relPath, const QCString &width,
118118
const QCString &height, bool hasCaption,const DocNodeList &children,
119-
const QCString &srcFile, int srcLine);
119+
const QCString &srcFile, int srcLine, bool newFile = true);
120120
void endMscFile(bool hasCaption);
121121
void writeMscFile(const QCString &fileName, const DocVerbatim &s, bool newFile = true);
122122
void startDiaFile(const QCString &fileName,const QCString &relPath, const QCString &width,
123123
const QCString &height, bool hasCaption,const DocNodeList &children,
124-
const QCString &srcFile, int srcLine);
124+
const QCString &srcFile, int srcLine, bool newFile = true);
125125
void endDiaFile(bool hasCaption);
126126
void writeDiaFile(const QCString &fileName, const DocVerbatim &s);
127127
void startDotFile(const QCString &fileName,const QCString &relPath, const QCString &width,
128128
const QCString &height, bool hasCaption,const DocNodeList &children,
129-
const QCString &srcFile, int srcLine);
129+
const QCString &srcFile, int srcLine, bool newFile = true);
130130
void endDotFile(bool hasCaption);
131131
void writeDotFile(const QCString &fileName, const DocVerbatim &s, bool newFile = true);
132132
void writePlantUMLFile(const QCString &fileName, const DocVerbatim &s);

src/htmldocvisitor.cpp

Lines changed: 67 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,60 +1715,93 @@ void HtmlDocVisitor::operator()(const DocImage &img)
17151715
void HtmlDocVisitor::operator()(const DocDotFile &df)
17161716
{
17171717
if (m_hide) return;
1718-
if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(HTML_OUTPUT)+"/"+stripPath(df.file()));
17191718
forceEndParagraph(df);
1720-
m_t << "<div class=\"dotgraph\">\n";
1721-
writeDotFile(df.file(),df.relPath(),df.context(),df.srcFile(),df.srcLine());
1722-
if (df.hasCaption())
1719+
bool exists = false;
1720+
std::string inBuf;
1721+
if (readInputFile(df.file(),inBuf))
17231722
{
1724-
m_t << "<div class=\"caption\">\n";
1723+
auto fileName = writeFileContents(Config_getString(HTML_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1724+
".dot", // extension
1725+
inBuf, // contents
1726+
exists);
1727+
if (!fileName.isEmpty())
1728+
{
1729+
m_t << "<div class=\"dotgraph\">\n";
1730+
writeDotFile(fileName,df.relPath(),df.context(),df.srcFile(),df.srcLine(),!exists);
1731+
if (df.hasCaption())
1732+
{
1733+
m_t << "<div class=\"caption\">\n";
1734+
}
1735+
visitChildren(df);
1736+
if (df.hasCaption())
1737+
{
1738+
m_t << "</div>\n";
1739+
}
1740+
m_t << "</div>\n";
17251741
}
1726-
visitChildren(df);
1727-
if (df.hasCaption())
1728-
{
1729-
m_t << "</div>\n";
17301742
}
1731-
m_t << "</div>\n";
17321743
forceStartParagraph(df);
17331744
}
17341745

17351746
void HtmlDocVisitor::operator()(const DocMscFile &df)
17361747
{
17371748
if (m_hide) return;
1738-
if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(HTML_OUTPUT)+"/"+stripPath(df.file()));
17391749
forceEndParagraph(df);
1740-
m_t << "<div class=\"mscgraph\">\n";
1741-
writeMscFile(df.file(),df.relPath(),df.context(),df.srcFile(),df.srcLine());
1742-
if (df.hasCaption())
1743-
{
1744-
m_t << "<div class=\"caption\">\n";
1745-
}
1746-
visitChildren(df);
1747-
if (df.hasCaption())
1750+
bool exists = false;
1751+
std::string inBuf;
1752+
if (readInputFile(df.file(),inBuf))
17481753
{
1749-
m_t << "</div>\n";
1754+
auto fileName = writeFileContents(Config_getString(HTML_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1755+
".msc", // extension
1756+
inBuf, // contents
1757+
exists);
1758+
if (!fileName.isEmpty())
1759+
{
1760+
m_t << "<div class=\"mscgraph\">\n";
1761+
writeMscFile(fileName,df.relPath(),df.context(),df.srcFile(),df.srcLine(),!exists);
1762+
if (df.hasCaption())
1763+
{
1764+
m_t << "<div class=\"caption\">\n";
1765+
}
1766+
visitChildren(df);
1767+
if (df.hasCaption())
1768+
{
1769+
m_t << "</div>\n";
1770+
}
1771+
m_t << "</div>\n";
1772+
}
17501773
}
1751-
m_t << "</div>\n";
17521774
forceStartParagraph(df);
17531775
}
17541776

17551777
void HtmlDocVisitor::operator()(const DocDiaFile &df)
17561778
{
17571779
if (m_hide) return;
1758-
if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(HTML_OUTPUT)+"/"+stripPath(df.file()));
17591780
forceEndParagraph(df);
1760-
m_t << "<div class=\"diagraph\">\n";
1761-
writeDiaFile(df.file(),df.relPath(),df.context(),df.srcFile(),df.srcLine());
1762-
if (df.hasCaption())
1763-
{
1764-
m_t << "<div class=\"caption\">\n";
1765-
}
1766-
visitChildren(df);
1767-
if (df.hasCaption())
1781+
bool exists = false;
1782+
std::string inBuf;
1783+
if (readInputFile(df.file(),inBuf))
17681784
{
1769-
m_t << "</div>\n";
1785+
auto fileName = writeFileContents(Config_getString(HTML_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1786+
".dia", // extension
1787+
inBuf, // contents
1788+
exists);
1789+
if (!fileName.isEmpty())
1790+
{
1791+
m_t << "<div class=\"diagraph\">\n";
1792+
writeDiaFile(fileName,df.relPath(),df.context(),df.srcFile(),df.srcLine(),!exists);
1793+
if (df.hasCaption())
1794+
{
1795+
m_t << "<div class=\"caption\">\n";
1796+
}
1797+
visitChildren(df);
1798+
if (df.hasCaption())
1799+
{
1800+
m_t << "</div>\n";
1801+
}
1802+
m_t << "</div>\n";
1803+
}
17701804
}
1771-
m_t << "</div>\n";
17721805
forceStartParagraph(df);
17731806
}
17741807

@@ -2179,12 +2212,12 @@ void HtmlDocVisitor::writeMscFile(const QCString &fileName,const QCString &relPa
21792212
}
21802213

21812214
void HtmlDocVisitor::writeDiaFile(const QCString &fileName, const QCString &relPath,
2182-
const QCString &,const QCString &srcFile,int srcLine)
2215+
const QCString &,const QCString &srcFile,int srcLine, bool newFile)
21832216
{
21842217
QCString baseName=makeBaseName(fileName,".dia");
21852218
baseName.prepend("dia_");
21862219
QCString outDir = Config_getString(HTML_OUTPUT);
2187-
writeDiaGraphFromFile(fileName,outDir,baseName,DiaOutputFormat::BITMAP,srcFile,srcLine);
2220+
if (newFile) writeDiaGraphFromFile(fileName,outDir,baseName,DiaOutputFormat::BITMAP,srcFile,srcLine);
21882221

21892222
m_t << "<img src=\"" << relPath << baseName << ".png" << "\" />\n";
21902223
}

src/htmldocvisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class HtmlDocVisitor : public DocVisitor
128128
void writeMscFile(const QCString &fileName,const QCString &relPath,const QCString &context,
129129
const QCString &srcFile,int srcLine, bool newFile = true);
130130
void writeDiaFile(const QCString &fileName,const QCString &relPath,const QCString &context,
131-
const QCString &srcFile,int srcLine);
131+
const QCString &srcFile,int srcLine, bool newFile = true);
132132
void writePlantUMLFile(const QCString &fileName,const QCString &relPath,const QCString &context,
133133
const QCString &srcFile,int srcLine);
134134

0 commit comments

Comments
 (0)