summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralbert-github <albert.tests@gmail.com>2021-06-12 12:40:44 (GMT)
committeralbert-github <albert.tests@gmail.com>2021-06-12 12:40:44 (GMT)
commitf366804a95c02d0883a3a1598a0f93b4ee0c982c (patch)
tree6367a57fc90302d6b3dcfd68ed7e4d1ac7d83d72
parent8c8a0343662f69ce65ced20dc8c6025e7fc022cd (diff)
downloadDoxygen-f366804a95c02d0883a3a1598a0f93b4ee0c982c.zip
Doxygen-f366804a95c02d0883a3a1598a0f93b4ee0c982c.tar.gz
Doxygen-f366804a95c02d0883a3a1598a0f93b4ee0c982c.tar.bz2
bug_674442 CREATE_FOLDERS should not create unused folders
Also known as issue #4672 The folders are still created but in case the folders are empty after the doxygen run the directories are removed.
-rw-r--r--src/dir.cpp7
-rw-r--r--src/dir.h1
-rw-r--r--src/docbookgen.cpp7
-rw-r--r--src/docbookgen.h1
-rw-r--r--src/doxygen.cpp2
-rw-r--r--src/htmlgen.cpp8
-rw-r--r--src/htmlgen.h1
-rw-r--r--src/latexgen.cpp7
-rw-r--r--src/latexgen.h1
-rw-r--r--src/mangen.cpp7
-rw-r--r--src/mangen.h1
-rw-r--r--src/outputgen.h2
-rw-r--r--src/outputlist.h3
-rw-r--r--src/rtfgen.cpp7
-rw-r--r--src/rtfgen.h1
-rw-r--r--src/util.cpp26
-rw-r--r--src/util.h1
-rw-r--r--src/xmlgen.cpp1
18 files changed, 84 insertions, 0 deletions
diff --git a/src/dir.cpp b/src/dir.cpp
index 327bc72..8a30f31 100644
--- a/src/dir.cpp
+++ b/src/dir.cpp
@@ -200,6 +200,13 @@ bool Dir::exists() const
return fi.exists() && fi.isDir();
}
+bool Dir::isEmpty(const std::string subdir) const
+{
+ fs::path pth = path();
+ pth /= subdir;
+ return fs::is_empty(pth);
+}
+
bool Dir::isRelative() const
{
return isRelativePath(p->path.string());
diff --git a/src/dir.h b/src/dir.h
index 0a1cc12..c322669 100644
--- a/src/dir.h
+++ b/src/dir.h
@@ -78,6 +78,7 @@ class Dir final
DirIterator iterator() const;
+ bool Dir::isEmpty(const std::string subdir) const;
bool exists() const;
std::string filePath(const std::string &path,bool acceptsAbsPath=true) const;
bool exists(const std::string &path,bool acceptsAbsPath=true) const;
diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp
index ab2fb84..38d1141 100644
--- a/src/docbookgen.cpp
+++ b/src/docbookgen.cpp
@@ -313,6 +313,13 @@ void DocbookGenerator::init()
createSubDirs(d);
}
+void DocbookGenerator::cleanup()
+{
+ QCString dname = Config_getString(DOCBOOK_OUTPUT);
+ Dir d(dname.str());
+ clearSubDirs(d);
+}
+
void DocbookGenerator::startFile(const QCString &name,const QCString &,const QCString &,int)
{
diff --git a/src/docbookgen.h b/src/docbookgen.h
index aba1527..f2c00bf 100644
--- a/src/docbookgen.h
+++ b/src/docbookgen.h
@@ -99,6 +99,7 @@ class DocbookGenerator : public OutputGenerator
virtual std::unique_ptr<OutputGenerator> clone() const;
static void init();
+ void cleanup();
OutputType type() const { return Docbook; }
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index a54be26..1287f9b 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -12144,6 +12144,8 @@ void generateOutput()
g_s.end();
}
+ g_outputList->cleanup();
+
int cacheParam;
msg("lookup cache used %zu/%zu hits=%" PRIu64 " misses=%" PRIu64 "\n",
Doxygen::lookupCache->size(),
diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp
index e1547af..484d6a7 100644
--- a/src/htmlgen.cpp
+++ b/src/htmlgen.cpp
@@ -971,6 +971,7 @@ void HtmlGenerator::init()
{
mgr.copyResource("svgpan.js",dname);
}
+
if (!Config_getBool(DISABLE_INDEX) && Config_getBool(HTML_DYNAMIC_MENUS))
{
mgr.copyResource("menu.js",dname);
@@ -990,6 +991,13 @@ void HtmlGenerator::init()
}
}
+void HtmlGenerator::cleanup()
+{
+ QCString dname = Config_getString(HTML_OUTPUT);
+ Dir d(dname.str());
+ clearSubDirs(d);
+}
+
/// Additional initialization after indices have been created
void HtmlGenerator::writeTabData()
{
diff --git a/src/htmlgen.h b/src/htmlgen.h
index c66e622..5665e8a 100644
--- a/src/htmlgen.h
+++ b/src/htmlgen.h
@@ -73,6 +73,7 @@ class HtmlGenerator : public OutputGenerator
virtual OutputType type() const { return Html; }
static void init();
+ void cleanup();
static void writeStyleSheetFile(TextStream &t);
static void writeHeaderFile(TextStream &t, const QCString &cssname);
static void writeFooterFile(TextStream &t);
diff --git a/src/latexgen.cpp b/src/latexgen.cpp
index fdcb993..0e86fb0 100644
--- a/src/latexgen.cpp
+++ b/src/latexgen.cpp
@@ -494,6 +494,13 @@ void LatexGenerator::init()
createSubDirs(d);
}
+void LatexGenerator::cleanup()
+{
+ QCString dname = Config_getString(LATEX_OUTPUT);
+ Dir d(dname.str());
+ clearSubDirs(d);
+}
+
static void writeDefaultStyleSheet(TextStream &t)
{
t << ResourceMgr::instance().getAsString("doxygen.sty");
diff --git a/src/latexgen.h b/src/latexgen.h
index f457d79..f3c1ab4 100644
--- a/src/latexgen.h
+++ b/src/latexgen.h
@@ -86,6 +86,7 @@ class LatexGenerator : public OutputGenerator
virtual std::unique_ptr<OutputGenerator> clone() const;
static void init();
+ void cleanup();
static void writeStyleSheetFile(TextStream &t);
static void writeHeaderFile(TextStream &t);
static void writeFooterFile(TextStream &t);
diff --git a/src/mangen.cpp b/src/mangen.cpp
index 05c5e77..50ba608 100644
--- a/src/mangen.cpp
+++ b/src/mangen.cpp
@@ -115,6 +115,13 @@ void ManGenerator::init()
createSubDirs(d);
}
+void ManGenerator::cleanup()
+{
+ QCString dname = Config_getString(MAN_OUTPUT);
+ Dir d(dname.str());
+ clearSubDirs(d);
+}
+
static QCString buildFileName(const QCString &name)
{
QCString fileName;
diff --git a/src/mangen.h b/src/mangen.h
index c552580..67b3356 100644
--- a/src/mangen.h
+++ b/src/mangen.h
@@ -35,6 +35,7 @@ class ManGenerator : public OutputGenerator
void writeDoc(DocNode *,const Definition *,const MemberDef *,int);
static void init();
+ void cleanup();
void startFile(const QCString &name,const QCString &manName,const QCString &title,int);
void writeSearchInfo() {}
void writeFooter(const QCString &) {}
diff --git a/src/outputgen.h b/src/outputgen.h
index 53972d4..74df36b 100644
--- a/src/outputgen.h
+++ b/src/outputgen.h
@@ -497,6 +497,8 @@ class OutputGenerator : public BaseOutputDocInterface
virtual void writeLabel(const QCString &,bool) = 0;
virtual void endLabels() = 0;
+ virtual void cleanup() = 0;
+
protected:
TextStream m_t;
private:
diff --git a/src/outputlist.h b/src/outputlist.h
index eadf85f..1c66921 100644
--- a/src/outputlist.h
+++ b/src/outputlist.h
@@ -475,6 +475,9 @@ class OutputList : public OutputDocInterface
void endLabels()
{ forall(&OutputGenerator::endLabels); }
+ void cleanup()
+ { forall(&OutputGenerator::cleanup); }
+
void startFontClass(const QCString &c)
{ forall(&OutputGenerator::startFontClass,c); }
void endFontClass()
diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp
index 0fac0b4..d500f27 100644
--- a/src/rtfgen.cpp
+++ b/src/rtfgen.cpp
@@ -207,6 +207,13 @@ void RTFGenerator::init()
createSubDirs(d);
}
+void RTFGenerator::cleanup()
+{
+ QCString dname = Config_getString(RTF_OUTPUT);
+ Dir d(dname.str());
+ clearSubDirs(d);
+}
+
static QCString makeIndexName(const QCString &s,int i)
{
QCString result=s;
diff --git a/src/rtfgen.h b/src/rtfgen.h
index c9a069e..7411023 100644
--- a/src/rtfgen.h
+++ b/src/rtfgen.h
@@ -32,6 +32,7 @@ class RTFGenerator : public OutputGenerator
virtual std::unique_ptr<OutputGenerator> clone() const;
static void init();
+ void cleanup();
static void writeStyleSheetFile(TextStream &t);
static void writeExtensionsFile(TextStream &t);
OutputType type() const { return RTF; }
diff --git a/src/util.cpp b/src/util.cpp
index 37c5e62..7c469ab 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -3702,6 +3702,32 @@ void createSubDirs(const Dir &d)
}
}
+void clearSubDirs(const Dir &d)
+{
+ if (Config_getBool(CREATE_SUBDIRS))
+ {
+ // remove empty subdirectories
+ for (int l1=0;l1<16;l1++)
+ {
+ QCString subdir;
+ subdir.sprintf("d%x",l1);
+ for (int l2=0;l2<256;l2++)
+ {
+ QCString subsubdir;
+ subsubdir.sprintf("d%x/d%02x",l1,l2);
+ if (d.exists(subsubdir.str()) && d.isEmpty(subsubdir.str()))
+ {
+ d.rmdir(subsubdir.str());
+ }
+ }
+ if (d.exists(subdir.str()) && d.isEmpty(subdir.str()))
+ {
+ d.rmdir(subdir.str());
+ }
+ }
+ }
+}
+
/*! Input is a scopeName, output is the scopename split into a
* namespace part (as large as possible) and a classname part.
*/
diff --git a/src/util.h b/src/util.h
index 4dc02d0..a166a21 100644
--- a/src/util.h
+++ b/src/util.h
@@ -321,6 +321,7 @@ void addDirPrefix(QCString &fileName);
QCString relativePathToRoot(const QCString &name);
void createSubDirs(const Dir &d);
+void clearSubDirs(const Dir &d);
QCString stripPath(const QCString &s);
diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp
index 46b0084..7fd7c6b 100644
--- a/src/xmlgen.cpp
+++ b/src/xmlgen.cpp
@@ -2021,6 +2021,7 @@ void generateXML()
}
writeCombineScript();
+ clearSubDirs(xmlDir);
}