qdoc: No longer creates empty subdirectories

qdoc was creating the scripts and used-in-examples subdirectories
whether or not there were any scripts or images used in examples.
Now qdoc creates these subdirectories only if there is something
to put in them.

Change-Id: Ied0e1b38ee28973313c68754c821b34edfd5f505
Task-number: QTBUG-44655
Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
This commit is contained in:
Martin Smith 2015-04-01 11:31:21 +02:00
parent 7064bf2b9b
commit 0d4232f531

View File

@ -892,16 +892,10 @@ void Generator::generateFileList(const DocumentNode* dn,
exampleImgExts,
userFriendlyFilePath);
userFriendlyFilePath.truncate(userFriendlyFilePath.lastIndexOf('/'));
QString imgOutDir = outDir_ + "/images/used-in-examples/" + userFriendlyFilePath;
if (!dirInfo.mkpath(imgOutDir))
dn->location().fatal(tr("Cannot create output directory '%1'")
.arg(imgOutDir));
QString imgOutName = Config::copyFile(dn->location(),
srcPath,
file,
imgOutDir);
dn->location().fatal(tr("Cannot create output directory '%1'").arg(imgOutDir));
Config::copyFile(dn->location(), srcPath, file, imgOutDir);
}
}
@ -1556,12 +1550,6 @@ void Generator::initialize(const Config &config)
if (!dirInfo.exists(outDir_ + "/images") && !dirInfo.mkdir(outDir_ + "/images"))
config.lastLocation().fatal(tr("Cannot create images directory '%1'").arg(outDir_ + "/images"));
if (!dirInfo.exists(outDir_ + "/images/used-in-examples") && !dirInfo.mkdir(outDir_ + "/images/used-in-examples"))
config.lastLocation().fatal(tr("Cannot create images used in examples directory '%1'").arg(outDir_ + "/images/used-in-examples"));
if (!dirInfo.exists(outDir_ + "/scripts") && !dirInfo.mkdir(outDir_ + "/scripts"))
config.lastLocation().fatal(tr("Cannot create scripts directory '%1'").arg(outDir_ + "/scripts"));
if (!dirInfo.exists(outDir_ + "/style") && !dirInfo.mkdir(outDir_ + "/style"))
config.lastLocation().fatal(tr("Cannot create style directory '%1'").arg(outDir_ + "/style"));
}
imageFiles = config.getCanonicalPathList(CONFIG_IMAGES);
@ -1600,23 +1588,41 @@ void Generator::initialize(const Config &config)
// Documentation template handling
QStringList scripts = config.getCanonicalPathList((*g)->format()+Config::dot+CONFIG_SCRIPTS, true);
e = scripts.constBegin();
while (e != scripts.constEnd()) {
QString filePath = *e;
if (!filePath.isEmpty())
Config::copyFile(config.lastLocation(), filePath, filePath,
(*g)->outputDir() + "/scripts");
++e;
if (!scripts.isEmpty()) {
QDir dirInfo;
if (!dirInfo.exists(outDir_ + "/scripts") && !dirInfo.mkdir(outDir_ + "/scripts")) {
config.lastLocation().fatal(tr("Cannot create scripts directory '%1'")
.arg(outDir_ + "/scripts"));
}
else {
e = scripts.constBegin();
while (e != scripts.constEnd()) {
QString filePath = *e;
if (!filePath.isEmpty())
Config::copyFile(config.lastLocation(), filePath, filePath,
(*g)->outputDir() + "/scripts");
++e;
}
}
}
QStringList styles = config.getCanonicalPathList((*g)->format()+Config::dot+CONFIG_STYLESHEETS, true);
e = styles.constBegin();
while (e != styles.constEnd()) {
QString filePath = *e;
if (!filePath.isEmpty())
Config::copyFile(config.lastLocation(), filePath, filePath,
(*g)->outputDir() + "/style");
++e;
if (!styles.isEmpty()) {
QDir dirInfo;
if (!dirInfo.exists(outDir_ + "/style") && !dirInfo.mkdir(outDir_ + "/style")) {
config.lastLocation().fatal(tr("Cannot create style directory '%1'")
.arg(outDir_ + "/style"));
}
else {
e = styles.constBegin();
while (e != styles.constEnd()) {
QString filePath = *e;
if (!filePath.isEmpty())
Config::copyFile(config.lastLocation(), filePath, filePath,
(*g)->outputDir() + "/style");
++e;
}
}
}
}
++g;