From 3a78aabf3f76abf403556d56d0a6bbf1294b3967 Mon Sep 17 00:00:00 2001 From: Casper van Donderen Date: Fri, 20 Apr 2012 13:56:50 +0200 Subject: [PATCH] QDoc: Support -indexdir on CLI and depends in qdocconf. 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 --- src/corelib/corelib.pro | 1 + src/corelib/doc/doc.pri | 2 ++ src/tools/qdoc/config.h | 1 + src/tools/qdoc/main.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 src/corelib/doc/doc.pri diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 4d1dc1b..d98cebb 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -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 index 0000000..8f69c5d --- /dev/null +++ b/src/corelib/doc/doc.pri @@ -0,0 +1,2 @@ +docs.commands += $$QT.core.bins/qdoc $$QT.core.sources/doc/qtcore.qdocconf +QMAKE_EXTRA_TARGETS += docs diff --git a/src/tools/qdoc/config.h b/src/tools/qdoc/config.h index f36389e..8ae0bc1 100644 --- a/src/tools/qdoc/config.h +++ b/src/tools/qdoc/config.h @@ -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" diff --git a/src/tools/qdoc/main.cpp b/src/tools/qdoc/main.cpp index f7985bd..9524f7e 100644 --- a/src/tools/qdoc/main.cpp +++ b/src/tools/qdoc/main.cpp @@ -64,6 +64,7 @@ #include "qmlcodeparser.h" #endif +#include #include #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 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 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 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; } -- 2.7.4