QDoc: search for example projectPath for manifest.
authorCasper van Donderen <casper.vandonderen@nokia.com>
Mon, 4 Jun 2012 15:29:53 +0000 (17:29 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 5 Jun 2012 07:25:07 +0000 (09:25 +0200)
Previously qdoc would automatically use the first .pro/.qmlproject file
found, now it explicitly searches for a .pro/.qmlproject file with the
name of the example.

Change-Id: I2552e529bd3d1b724d3b4286d98d664edbbabcf2
Reviewed-by: Martin Smith <martin.smith@nokia.com>
src/tools/qdoc/htmlgenerator.cpp

index 83f3c4a..b5fec5d 100644 (file)
@@ -4388,15 +4388,35 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element)
         writer.writeAttribute("name", en->title());
         QString docUrl = manifestDir + en->fileBase() + ".html";
         writer.writeAttribute("docUrl", docUrl);
+        QStringList proFiles;
         foreach (const Node* child, en->childNodes()) {
             if (child->subType() == Node::File) {
                 QString file = child->name();
                 if (file.endsWith(".pro") || file.endsWith(".qmlproject")) {
                     if (file.startsWith("demos/"))
                         file = file.mid(6);
-                    writer.writeAttribute("projectPath", file);
-                    break;
+                    proFiles << file;
+                }
+            }
+        }
+        if (!proFiles.isEmpty()) {
+            if (proFiles.size() == 1) {
+                writer.writeAttribute("projectPath", proFiles[0]);
+            }
+            else {
+                QString exampleName = en->name().split('/').last();
+                bool proWithExampleNameFound = false;
+                for (int j = 0; j < proFiles.size(); j++)
+                {
+                    if (proFiles[j].endsWith(QStringLiteral("%1/%1.pro").arg(exampleName))
+                            || proFiles[j].endsWith(QStringLiteral("%1/%1.qmlproject").arg(exampleName))) {
+                        writer.writeAttribute("projectPath", proFiles[j]);
+                        proWithExampleNameFound = true;
+                        break;
+                    }
                 }
+                if (!proWithExampleNameFound)
+                    writer.writeAttribute("projectPath", proFiles[0]);
             }
         }
         if (!en->imageFileName().isEmpty())