From 7498554557c0ead8421cdabbc6d99e2342934041 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Thu, 1 Aug 2019 14:59:58 +0200 Subject: 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 Reviewed-by: Edward Welbourne --- src/qdoc/config.cpp | 2 ++ src/qdoc/config.h | 3 ++- src/qdoc/main.cpp | 26 +++++++++++++++++++++++++- src/qdoc/qdoccommandlineparser.cpp | 22 +++------------------- 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 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 +#include #include 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); -- cgit v1.2.3