QDoc: Add support for 'all subfolders' in dependant modules.
authorCasper van Donderen <casper.vandonderen@nokia.com>
Wed, 30 May 2012 08:44:04 +0000 (10:44 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 30 May 2012 09:13:55 +0000 (11:13 +0200)
It is now possible to use '*' when specifying the 'depends' qdocconf
variable, this will automatically load all index files found in
subdirectories of the index dirs.

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

index 34ef213..f33b95c 100644 (file)
@@ -254,12 +254,29 @@ static void processQdocconfFile(const QString &fileName)
 
     if (dependModules.size() > 0) {
         if (indexDirs.size() > 0) {
-            for (int j = 0; j < indexDirs.size(); j++) {
-                if (indexDirs[j].startsWith("..")) {
-                    indexDirs[j].prepend(QDir(dir).relativeFilePath(prevCurrentDir));
+            for (int i = 0; i < indexDirs.size(); i++) {
+                if (indexDirs[i].startsWith("..")) {
+                    indexDirs[i].prepend(QDir(dir).relativeFilePath(prevCurrentDir));
+                }
+            }
+            /*
+                Add all subdirectories of the indexdirs as dependModules when an asterisk is used in
+                the 'depends' list.
+            */
+            if (dependModules.contains("*")) {
+                dependModules.removeOne("*");
+                for (int i = 0; i < indexDirs.size(); i++) {
+                    QDir scanDir = QDir(indexDirs[i]);
+                    scanDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
+                    QFileInfoList dirList = scanDir.entryInfoList();
+                    for (int j = 0; j < dirList.size(); j++) {
+                        if (dirList[j].fileName().toLower() != config.getString(CONFIG_PROJECT).toLower())
+                            dependModules.append(dirList[j].fileName());
+                    }
                 }
             }
             for (int i = 0; i < dependModules.size(); i++) {
+                QString indexToAdd;
                 QMultiMap<uint, QFileInfo> foundIndices;
                 for (int j = 0; j < indexDirs.size(); j++) {
                     QString fileToLookFor = indexDirs[j] + QLatin1Char('/') + dependModules[i] +
@@ -279,16 +296,18 @@ static void processQdocconfFile(const QString &fileName)
                     qDebug() << "Using" << foundIndices.value(
                                     foundIndices.keys()[foundIndices.size() - 1]).absoluteFilePath()
                             << "as index for" << dependModules[i];
-                    indexFiles << foundIndices.value(
+                    indexToAdd = foundIndices.value(
                                       foundIndices.keys()[foundIndices.size() - 1]).absoluteFilePath();
                 }
                 else if (foundIndices.size() == 1) {
-                    indexFiles << foundIndices.value(foundIndices.keys()[0]).absoluteFilePath();
+                    indexToAdd = foundIndices.value(foundIndices.keys()[0]).absoluteFilePath();
                 }
                 else {
                     qDebug() << "No indices for" << dependModules[i] <<
                                 "could be found in the specified index directories.";
                 }
+                if (!indexToAdd.isEmpty() && !indexFiles.contains(indexToAdd))
+                    indexFiles << indexToAdd;
             }
         }
         else {