QDoc: Support -indexdir on CLI and depends in qdocconf.
authorCasper van Donderen <casper.vandonderen@nokia.com>
Fri, 20 Apr 2012 11:56:50 +0000 (13:56 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 23 Apr 2012 07:45:24 +0000 (09:45 +0200)
You can now specify a list of modules in the "depends" qdocconf
variable. This stringlist is then used by the -indexdir option to
specify in which directory to search for [depends entry]/[depends entry].index

Change-Id: Icab6dd0133e180ac04365da9605743def6fb754d
Reviewed-by: Martin Smith <martin.smith@nokia.com>
src/corelib/corelib.pro
src/corelib/doc/doc.pri [new file with mode: 0644]
src/tools/qdoc/config.h
src/tools/qdoc/main.cpp

index 4d1dc1b..d98cebb 100644 (file)
@@ -30,6 +30,7 @@ include(codecs/codecs.pri)
 include(statemachine/statemachine.pri)
 include(mimetypes/mimetypes.pri)
 include(xml/xml.pri)
+include(doc/doc.pri)
 
 mac|darwin {
     !ios {
diff --git a/src/corelib/doc/doc.pri b/src/corelib/doc/doc.pri
new file mode 100644 (file)
index 0000000..8f69c5d
--- /dev/null
@@ -0,0 +1,2 @@
+docs.commands += $$QT.core.bins/qdoc $$QT.core.sources/doc/qtcore.qdocconf
+QMAKE_EXTRA_TARGETS += docs
index f36389e..8ae0bc1 100644 (file)
@@ -135,6 +135,7 @@ private:
 #define CONFIG_BASEDIR                  "basedir"
 #define CONFIG_CODEINDENT               "codeindent"
 #define CONFIG_DEFINES                  "defines"
+#define CONFIG_DEPENDS                  "depends"
 #define CONFIG_DESCRIPTION              "description"
 #define CONFIG_EDITION                  "edition"
 #define CONFIG_ENDHEADER                "endheader"
index f7985bd..9524f7e 100644 (file)
@@ -64,6 +64,7 @@
 #include "qmlcodeparser.h"
 #endif
 
+#include <qdatetime.h>
 #include <qdebug.h>
 
 #include "qtranslator.h"
@@ -99,6 +100,7 @@ static bool highlighting = false;
 static bool showInternal = false;
 static bool obsoleteLinks = false;
 static QStringList defines;
+static QStringList indexDirs;
 static QHash<QString, Tree *> trees;
 
 /*!
@@ -116,6 +118,8 @@ static void printHelp()
                              "Turn on syntax highlighting (makes qdoc run slower)\n"
                              "    -no-examples   "
                              "Do not generate documentation for examples\n"
+                             "    -indexdir      "
+                             "Specify a directory where QDoc should search for indices to link to\n"
                              "    -obsoletelinks "
                              "Report links from obsolete items to non-obsolete items\n"
                              "    -outputdir     "
@@ -245,6 +249,48 @@ static void processQdocconfFile(const QString &fileName)
       Read some XML indexes containing definitions from other documentation sets.
      */
     QStringList indexFiles = config.getStringList(CONFIG_INDEXES);
+
+    QStringList dependModules = config.getStringList(CONFIG_DEPENDS);
+
+    if (dependModules.size() > 0) {
+        if (indexDirs.size() > 0) {
+            for (int i = 0; i < dependModules.size(); i++) {
+                QMultiMap<uint, QFileInfo> foundIndices;
+                for (int j = 0; j < indexDirs.size(); j++) {
+                    QString fileToLookFor = indexDirs[j] + "/" + dependModules[i] +
+                            "/" + dependModules[i] + ".index";
+                    if (QFile::exists(fileToLookFor)) {
+                        QFileInfo tempFileInfo(fileToLookFor);
+                        foundIndices.insert(tempFileInfo.lastModified().toTime_t(), tempFileInfo);
+                    }
+                }
+                if (foundIndices.size() > 1) {
+                    /*
+                        QDoc should always use the last entry in the multimap when there are
+                        multiple index files for a module, since the last modified file has the
+                        highest UNIX timestamp.
+                    */
+                    qDebug() << "Multiple indices found for dependency:" << dependModules[i];
+                    qDebug() << "Using" << foundIndices.value(
+                                    foundIndices.keys()[foundIndices.size() - 1]).absoluteFilePath()
+                            << "as index for" << dependModules[i];
+                    indexFiles << foundIndices.value(
+                                      foundIndices.keys()[foundIndices.size() - 1]).absoluteFilePath();
+                }
+                else if (foundIndices.size() == 1) {
+                    indexFiles << foundIndices.value(foundIndices.keys()[0]).absoluteFilePath();
+                }
+                else {
+                    qDebug() << "No indices for" << dependModules[i] <<
+                                "could be found in the specified index directories.";
+                }
+            }
+        }
+        else {
+            qDebug() << "Dependant modules specified, but not index directories were set."
+                     << "There will probably be errors for missing links.";
+        }
+    }
     tree->readIndexes(indexFiles);
 
     QSet<QString> excludedDirs;
@@ -432,6 +478,16 @@ int main(int argc, char **argv)
         else if (opt == "-no-examples") {
             Config::generateExamples = false;
         }
+        else if (opt == "-indexdir") {
+            if (QFile::exists(argv[i])) {
+                indexDirs += argv[i];
+            }
+            else {
+                qDebug() << "Cannot find index directory" << argv[i];
+                return EXIT_FAILURE;
+            }
+            i++;
+        }
         else if (opt == "-obsoletelinks") {
             obsoleteLinks = true;
         }