summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2019-08-01 14:59:58 +0200
committerPaul Wicking <paul.wicking@qt.io>2019-08-14 21:12:05 +0200
commit7498554557c0ead8421cdabbc6d99e2342934041 (patch)
treeb4e1594d47fcc646491d0be36a3bcedd7e479d3c
parent411e75b05eb391bd39d642838bf9bc7914f13f77 (diff)
QDoc: Further detangle QDocCommandLineParser::process()
This change removes QDocCommandLineParser's dependency on Generator and Location. The calls to their static methods are moved to a new helper function in main.cpp, postProcess(). Thus, QDocCommandLineParser no longer sets values in Generator or Location. QDir was included via Generator, and is therefore added as an include in QDocCommandLineParser. This change further clears up QDocCommandLineParser's external dependencies, to make it easier to test the class separately. Task-number: QTBUG-71165 Task-number: QTBUG-71176 Change-Id: I2a024d57d50f84f9271672b6a753e677b748f1b6 Reviewed-by: Martin Smith <martin.smith@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rw-r--r--src/qdoc/config.cpp2
-rw-r--r--src/qdoc/config.h3
-rw-r--r--src/qdoc/main.cpp26
-rw-r--r--src/qdoc/qdoccommandlineparser.cpp22
4 files changed, 32 insertions, 21 deletions
diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp
index 6a27df185..d4596f571 100644
--- a/src/qdoc/config.cpp
+++ b/src/qdoc/config.cpp
@@ -340,6 +340,8 @@ void Config::setOptions(const QDocCommandLineParser &parser)
const auto outputFormats = parser.values(parser.outputFormatOption);
for (const auto &format : outputFormats)
overrideOutputFormats.insert(format);
+
+ debug_ = parser.isSet(parser.debugOption);
}
/*!
diff --git a/src/qdoc/config.h b/src/qdoc/config.h
index 3586451d9..52ce3d946 100644
--- a/src/qdoc/config.h
+++ b/src/qdoc/config.h
@@ -77,7 +77,7 @@ public:
Config(const QString &programName);
~Config();
- static bool debug_;
+ bool getDebug() const { return debug_; }
void load(const QString &fileName);
void setStringList(const QString &var, const QStringList &values);
@@ -142,6 +142,7 @@ public:
static QSet<QString> overrideOutputFormats;
private:
+ static bool debug_;
static bool isMetaKeyChar(QChar ch);
void load(Location location, const QString &fileName);
diff --git a/src/qdoc/main.cpp b/src/qdoc/main.cpp
index fc555f0bd..be9f84488 100644
--- a/src/qdoc/main.cpp
+++ b/src/qdoc/main.cpp
@@ -258,7 +258,10 @@ static void processQdocconfFile(const QString &fileName, Config &config)
QString msg = "Start qdoc for " + config.getString(CONFIG_PROJECT) + phase;
Location::logToStdErrAlways(msg);
-
+ if (config.getDebug()) {
+ Utilities::startDebugging(QString("command line"));
+ qCDebug(lcQdoc).noquote() << "Arguments:" << QCoreApplication::arguments();
+ }
/*
Initialize all the classes and data structures with the
qdoc configuration. This is safe to do for each qdocconf
@@ -517,6 +520,26 @@ static void processQdocconfFile(const QString &fileName, Config &config)
qCDebug(lcQdoc, "qdoc classes terminated");
}
+/* This method is an extremely ugly hack;
+ some or all of these settings must be set before the call to
+ various initialize() methods in main's processQdocconfFile().
+*/
+void postProcess(const QDocCommandLineParser &parser)
+{
+ if (parser.isSet(parser.prepareOption))
+ Generator::setQDocPass(Generator::Prepare);
+ if (parser.isSet(parser.generateOption))
+ Generator::setQDocPass(Generator::Generate);
+ if (parser.isSet(parser.singleExecOption))
+ Generator::setSingleExec();
+ if (parser.isSet(parser.writeQaPagesOption))
+ Generator::setWriteQaPages();
+ if (parser.isSet(parser.logProgressOption))
+ Location::startLoggingProgress();
+ if (parser.isSet(parser.timestampsOption))
+ Generator::setUseTimestamps();
+}
+
QT_END_NAMESPACE
int main(int argc, char **argv)
@@ -564,6 +587,7 @@ int main(int argc, char **argv)
QDocCommandLineParser parser;
parser.process(app.arguments(), qdocGlobals);
config.setOptions(parser);
+ postProcess(parser);
// Get the list of files to act on:
QStringList qdocFiles = parser.positionalArguments();
diff --git a/src/qdoc/qdoccommandlineparser.cpp b/src/qdoc/qdoccommandlineparser.cpp
index 3da581ac9..be8513e4b 100644
--- a/src/qdoc/qdoccommandlineparser.cpp
+++ b/src/qdoc/qdoccommandlineparser.cpp
@@ -29,11 +29,11 @@
#include "qdoccommandlineparser.h"
#include "config.h"
-#include "generator.h"
#include "loggingcategory.h"
#include "utilities.h"
#include <QtCore/qdebug.h>
+#include <QtCore/qdir.h>
#include <QtCore/qfile.h>
QDocCommandLineParser::QDocCommandLineParser()
@@ -203,24 +203,8 @@ void QDocCommandLineParser::process(const QStringList &arguments, QDocGlobals &q
qdocGlobals.setNoLinkErrors(isSet(noLinkErrorsOption) || qEnvironmentVariableIsSet("QDOC_NOLINKERRORS"));
qdocGlobals.setAutolinkErrors(isSet(autoLinkErrorsOption));
- if (isSet(debugOption))
- Utilities::startDebugging(QString("command line"));
- qCDebug(lcQdoc).noquote() << "Arguments :" << QCoreApplication::arguments();
- if (isSet(prepareOption))
- Generator::setQDocPass(Generator::Prepare);
- if (isSet(generateOption))
- Generator::setQDocPass(Generator::Generate);
- if (isSet(singleExecOption)) {
- Generator::setSingleExec();
- if (isSet(indexDirOption))
- qDebug() << "WARNING: -indexdir option ignored: Index files are not used in -single-exec mode.";
- }
- if (isSet(writeQaPagesOption))
- Generator::setWriteQaPages();
- if (isSet(logProgressOption))
- Location::startLoggingProgress();
- if (isSet(timestampsOption))
- Generator::setUseTimestamps();
+ if (isSet(singleExecOption) && isSet(indexDirOption))
+ qDebug("WARNING: -indexdir option ignored: Index files are not used in single-exec mode.");
QDir currentDir = QDir::current();
const auto paths = values(includePathOption);