diff options
author | Paul Wicking <paul.wicking@qt.io> | 2023-03-23 06:46:13 +0100 |
---|---|---|
committer | Paul Wicking <paul.wicking@qt.io> | 2023-03-23 13:41:59 +0100 |
commit | 7017f3d4438d6e0deeba6898c367e7d472e6a26a (patch) | |
tree | 7f68fe6109ed51255495f1c99201f128ae96728f | |
parent | 5ce297ca105a1be033d276c8f46690f1d256308d (diff) | |
download | qttools-7017f3d4438d6e0deeba6898c367e7d472e6a26a.tar.gz |
QDoc: Extract helper function in main.cpp
Recent changes have extracted helper functions for running QDoc in
single or dual execution mode, respectively. Both functions do minor
setup, including getting a list of .qdocconf-files from `Config`. The
setup and list of .qdocconf-files differ in these two execution modes.
Both functions then loops over their list of .qdocconf-files. This loop
calls clear() on Config's list of module dependencies before dispatching
the qdocconf file to processQdocconfFile() for further processing. This
loop is identical to both modes of execution; in single execution mode,
this particular loop is performed twice.
This patch extracts this loop as a separate function that accepts a list
of .qdocconf-files it will iterate over. As this loop makes out the bulk
of code in the two functions for execution modes, this implementation
detail obscures the material difference of the work performed in the two
callers of this new function. By extracting it, code readability is
improved by letting the interesting parts take center stage.
Task-number: QTBUG-71176
Change-Id: Ie7f63bde17d9b676f9755874537af6c5bb1f9c7e
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r-- | src/qdoc/main.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/qdoc/main.cpp b/src/qdoc/main.cpp index 31af65e0a..397db03e1 100644 --- a/src/qdoc/main.cpp +++ b/src/qdoc/main.cpp @@ -613,6 +613,21 @@ static void processQdocconfFile(const QString &fileName) /*! \internal + For each file in \a qdocFiles, first clear the configured module + dependencies and then pass the file to processQdocconfFile(). + + \sa processQdocconfFile(), singleExecutionMode(), dualExecutionMode() +*/ +static void clearModuleDependenciesAndProcessQdocconfFile(const QStringList &qdocFiles) +{ + for (const auto &file : std::as_const(qdocFiles)) { + Config::instance().dependModules().clear(); + processQdocconfFile(file); + } +} + +/*! + \internal A single QDoc process for prepare and generate phases. The purpose is to first generate all index files for all documentation @@ -626,17 +641,11 @@ static void singleExecutionMode() const QStringList qdocFiles = Config::loadMaster(Config::instance().qdocFiles().at(0)); Config::instance().setQDocPass(Config::Prepare); - for (const auto &file : std::as_const(qdocFiles)) { - Config::instance().dependModules().clear(); - processQdocconfFile(file); - } + clearModuleDependenciesAndProcessQdocconfFile(qdocFiles); Config::instance().setQDocPass(Config::Generate); QDocDatabase::qdocDB()->processForest(); - for (const auto &file : std::as_const(qdocFiles)) { - Config::instance().dependModules().clear(); - processQdocconfFile(file); - } + clearModuleDependenciesAndProcessQdocconfFile(qdocFiles); } /*! @@ -647,10 +656,7 @@ static void singleExecutionMode() static void dualExecutionMode() { const QStringList qdocFiles = Config::instance().qdocFiles(); - for (const auto &file : std::as_const(qdocFiles)) { - Config::instance().dependModules().clear(); - processQdocconfFile(file); - } + clearModuleDependenciesAndProcessQdocconfFile(qdocFiles); } QT_END_NAMESPACE |