From 82fcbe9d7d7505bb2e3fc53789e14405e73d5302 Mon Sep 17 00:00:00 2001 From: Casper van Donderen Date: Mon, 23 Apr 2012 16:47:43 +0200 Subject: [PATCH] QDoc: Implement -installdir CLI option for module cross-linking. QDoc needs to know the final location of the installed documentation to generate correct relative links between the modules. Normally you can use QLibraryInfo::DocumentationPath for this, but since QDoc gets compiled during Qt bootstrapping QLibraryInfo is not available yet. The -installdir option still allows us to specify QLibraryInfo::DocumentationPath on the command line. Change-Id: Ic4729f4daad112f0d175931467cf09cfcf5145a3 Reviewed-by: Martin Smith --- src/tools/qdoc/config.cpp | 1 + src/tools/qdoc/config.h | 1 + src/tools/qdoc/main.cpp | 10 ++++++++-- src/tools/qdoc/tree.cpp | 13 ++++++++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/tools/qdoc/config.cpp b/src/tools/qdoc/config.cpp index 8b356d1536..e715ea1112 100644 --- a/src/tools/qdoc/config.cpp +++ b/src/tools/qdoc/config.cpp @@ -150,6 +150,7 @@ QStringList MetaStack::getExpanded(const Location& location) QT_STATIC_CONST_IMPL QString Config::dot = QLatin1String("."); bool Config::generateExamples = true; QString Config::overrideOutputDir; +QString Config::installDir; QSet Config::overrideOutputFormats; QMap Config::extractedDirs; int Config::numInstances; diff --git a/src/tools/qdoc/config.h b/src/tools/qdoc/config.h index 8ae0bc1213..6ed37fce03 100644 --- a/src/tools/qdoc/config.h +++ b/src/tools/qdoc/config.h @@ -111,6 +111,7 @@ public: QT_STATIC_CONST QString dot; static bool generateExamples; + static QString installDir; static QString overrideOutputDir; static QSet overrideOutputFormats; diff --git a/src/tools/qdoc/main.cpp b/src/tools/qdoc/main.cpp index 9524f7e5a0..f230f92f06 100644 --- a/src/tools/qdoc/main.cpp +++ b/src/tools/qdoc/main.cpp @@ -116,10 +116,12 @@ static void printHelp() "Display this information and exit\n" " -highlighting " "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" + " -installdir " + "Specify the directory where the output will be after running \"make install\"\n" + " -no-examples " + "Do not generate documentation for examples\n" " -obsoletelinks " "Report links from obsolete items to non-obsolete items\n" " -outputdir " @@ -488,6 +490,10 @@ int main(int argc, char **argv) } i++; } + else if (opt == "-installdir") { + Config::installDir = argv[i]; + i++; + } else if (opt == "-obsoletelinks") { obsoleteLinks = true; } diff --git a/src/tools/qdoc/tree.cpp b/src/tools/qdoc/tree.cpp index 98c269dccc..a81f80f106 100644 --- a/src/tools/qdoc/tree.cpp +++ b/src/tools/qdoc/tree.cpp @@ -967,7 +967,18 @@ void Tree::readIndexFile(const QString& path) file.close(); QDomElement indexElement = document.documentElement(); - QString indexUrl = indexElement.attribute("url", ""); + + // Generate a relative URL between the install dir and the index file + // when the -installdir command line option is set. + QString indexUrl; + if (Config::installDir.isEmpty()) { + indexUrl = indexElement.attribute("url", ""); + } + else { + QDir installDir(Config::installDir); + indexUrl = installDir.relativeFilePath(path).section('/', 0, -2); + } + priv->basesList.clear(); priv->relatedList.clear();