summaryrefslogtreecommitdiffstats
path: root/tools/qdoc3/generator.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2009-12-17 09:40:52 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-12-17 09:40:52 (GMT)
commitdd678f7564955112b348a2fec56b29a8875e585e (patch)
treed2415d20cb5a27c312150cd6ee93bce8d5129895 /tools/qdoc3/generator.cpp
parent7d6af0213ab4f8797f98d0beb659fcf2f78a361b (diff)
parentbc01bb10da23d0d2308cf02a16947be836bc9a21 (diff)
downloadQt-dd678f7564955112b348a2fec56b29a8875e585e.zip
Qt-dd678f7564955112b348a2fec56b29a8875e585e.tar.gz
Qt-dd678f7564955112b348a2fec56b29a8875e585e.tar.bz2
Merge remote branch 'staging/4.6' into 4.6
Diffstat (limited to 'tools/qdoc3/generator.cpp')
-rw-r--r--tools/qdoc3/generator.cpp45
1 files changed, 41 insertions, 4 deletions
diff --git a/tools/qdoc3/generator.cpp b/tools/qdoc3/generator.cpp
index 9389268..56fca06 100644
--- a/tools/qdoc3/generator.cpp
+++ b/tools/qdoc3/generator.cpp
@@ -65,6 +65,8 @@ QMap<QString, QStringList> Generator::imgFileExts;
QSet<QString> Generator::outputFormats;
QStringList Generator::imageFiles;
QStringList Generator::imageDirs;
+QStringList Generator::exampleDirs;
+QStringList Generator::exampleImgExts;
QString Generator::outDir;
QString Generator::project;
@@ -120,12 +122,19 @@ void Generator::initialize(const Config &config)
if (!dirInfo.mkdir(outDir + "/images"))
config.lastLocation().fatal(tr("Cannot create output directory '%1'")
.arg(outDir + "/images"));
+ if (!dirInfo.mkdir(outDir + "/images/used-in-examples"))
+ config.lastLocation().fatal(tr("Cannot create output directory '%1'")
+ .arg(outDir + "/images/used-in-examples"));
}
imageFiles = config.getStringList(CONFIG_IMAGES);
imageDirs = config.getStringList(CONFIG_IMAGEDIRS);
+ exampleDirs = config.getStringList(CONFIG_EXAMPLEDIRS);
+ exampleImgExts = config.getStringList(CONFIG_EXAMPLES + Config::dot +
+ CONFIG_IMAGEEXTENSIONS);
- QString imagesDotFileExtensions = CONFIG_IMAGES + Config::dot + CONFIG_FILEEXTENSIONS;
+ QString imagesDotFileExtensions =
+ CONFIG_IMAGES + Config::dot + CONFIG_FILEEXTENSIONS;
QSet<QString> formats = config.subVars(imagesDotFileExtensions);
QSet<QString>::ConstIterator f = formats.begin();
while (f != formats.end()) {
@@ -323,7 +332,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
const FakeNode *fake = static_cast<const FakeNode *>(node);
if (fake->subType() == Node::Example)
generateExampleFiles(fake, marker);
- else if (fake->subType() == Node::File)
+ else if ((fake->subType() == Node::File) || (fake->subType() == Node::Image))
quiet = true;
}
@@ -530,6 +539,13 @@ void Generator::generateInheritedBy(const ClassNode *classe,
}
}
+/*!
+ This function is called when the documentation for an
+ example is being formatted. It outputs the list of source
+ files comprising the example, and the list of images used
+ by the example. The images are copied into a subtree of
+ \c{...doc/html/images/used-in-examples/...}
+ */
void Generator::generateFileList(const FakeNode* fake,
CodeMarker* marker,
Node::SubType subtype,
@@ -546,9 +562,30 @@ void Generator::generateFileList(const FakeNode* fake,
if (child->subType() == subtype) {
++count;
QString file = child->name();
+ if (subtype == Node::Image) {
+ if (!file.isEmpty()) {
+ QDir dirInfo;
+ QString userFriendlyFilePath;
+ QString srcPath = Config::findFile(fake->location(),
+ QStringList(),
+ exampleDirs,
+ file,
+ exampleImgExts,
+ userFriendlyFilePath);
+ userFriendlyFilePath.truncate(userFriendlyFilePath.lastIndexOf('/'));
+
+ QString imgOutDir = outDir + "/images/used-in-examples/" + userFriendlyFilePath;
+ if (!dirInfo.mkpath(imgOutDir))
+ fake->location().fatal(tr("Cannot create output directory '%1'")
+ .arg(imgOutDir));
+
+ QString imgOutName = Config::copyFile(fake->location(),
+ srcPath,
+ file,
+ imgOutDir);
+ }
- if (file == "network/qftp/images/dir.png")
- qDebug() << "FILE:" << file;
+ }
openedList.next();
text << Atom(Atom::ListItemNumber, openedList.numberString())