summaryrefslogtreecommitdiffstats
path: root/src/tools/qdoc/main.cpp
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@nokia.com>2012-09-13 11:38:45 +0200
committerQt by Nokia <qt-info@nokia.com>2012-09-14 15:23:15 +0200
commit14f7eb86ca2275d91f284279af5f77205d4ae3c0 (patch)
treeed4e91d6422dd814ac3e81739ad4a3b55bf050c7 /src/tools/qdoc/main.cpp
parent817a4474676b30a964de476d26bd70ddba3d379a (diff)
qdoc: Refactoring of qdoc data structures
This commit is the beginning of a significant overhaul of qdoc. A new class, QDocDatabase, is added, which will eventually encapsulate all the data structures used by qdoc. In this commit, the Tree class is made private and only accessible from QDocDatabase. Several maps structures are also moved into QDocDatabase from other classes. Much dead code and unused parameters were removed. Further simplification will follow. Change-Id: I237411c50f3ced0d2fc8d3b0fbfdf4e55880f8e9 Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Jerome Pasion <jerome.pasion@nokia.com>
Diffstat (limited to 'src/tools/qdoc/main.cpp')
-rw-r--r--src/tools/qdoc/main.cpp51
1 files changed, 19 insertions, 32 deletions
diff --git a/src/tools/qdoc/main.cpp b/src/tools/qdoc/main.cpp
index 0d668203e3..f7a4796292 100644
--- a/src/tools/qdoc/main.cpp
+++ b/src/tools/qdoc/main.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
- main.cpp
-*/
-
#include <qglobal.h>
#include <stdlib.h>
#include "codemarker.h"
@@ -57,14 +53,12 @@
#include "puredocparser.h"
#include "tokenizer.h"
#include "tree.h"
-
+#include "qdocdatabase.h"
#include "jscodemarker.h"
#include "qmlcodemarker.h"
#include "qmlcodeparser.h"
-
#include <qdatetime.h>
#include <qdebug.h>
-
#include "qtranslator.h"
#ifndef QT_BOOTSTRAPPED
# include "qcoreapplication.h"
@@ -105,7 +99,6 @@ static bool obsoleteLinks = false;
static QStringList defines;
static QStringList dependModules;
static QStringList indexDirs;
-static QHash<QString, Tree *> trees;
/*!
Print the help message to \c stdout.
@@ -240,12 +233,13 @@ static void processQdocconfFile(const QString &fileName)
Location langLocation = config.lastLocation();
/*
- Initialize the tree where all the parsed sources will be stored.
- The tree gets built as the source files are parsed, and then the
- documentation output is generated by traversing the tree.
+ Initialize the qdoc database, where all the parsed source files
+ will be stored. The database includes a tree of nodes, which gets
+ built as the source files are parsed. The documentation output is
+ generated by traversing that tree.
*/
- Tree *tree = new Tree;
- tree->setVersion(config.getString(CONFIG_VERSION));
+ QDocDatabase* qdb = QDocDatabase::qdocDB();
+ qdb->setVersion(config.getString(CONFIG_VERSION));
/*
By default, the only output format is HTML.
@@ -327,7 +321,7 @@ static void processQdocconfFile(const QString &fileName)
<< "There will probably be errors for missing links.";
}
}
- tree->readIndexes(indexFiles);
+ qdb->readIndexes(indexFiles);
QSet<QString> excludedDirs;
QSet<QString> excludedFiles;
@@ -390,14 +384,14 @@ static void processQdocconfFile(const QString &fileName)
CodeParser *codeParser = CodeParser::parserForHeaderFile(h.key());
if (codeParser) {
++parsed;
- codeParser->parseHeaderFile(config.location(), h.key(), tree);
+ codeParser->parseHeaderFile(config.location(), h.key());
usedParsers.insert(codeParser);
}
++h;
}
foreach (CodeParser *codeParser, usedParsers)
- codeParser->doneParsingHeaderFiles(tree);
+ codeParser->doneParsingHeaderFiles();
usedParsers.clear();
/*
@@ -410,24 +404,21 @@ static void processQdocconfFile(const QString &fileName)
CodeParser *codeParser = CodeParser::parserForSourceFile(s.key());
if (codeParser) {
++parsed;
- codeParser->parseSourceFile(config.location(), s.key(), tree);
+ codeParser->parseSourceFile(config.location(), s.key());
usedParsers.insert(codeParser);
}
++s;
}
foreach (CodeParser *codeParser, usedParsers)
- codeParser->doneParsingSourceFiles(tree);
+ codeParser->doneParsingSourceFiles();
/*
Now the big tree has been built from all the header and
source files. Resolve all the class names, function names,
targets, URLs, links, and other stuff that needs resolving.
*/
- tree->resolveGroups();
- tree->resolveTargets(tree->root());
- tree->resolveCppToQmlLinks();
- tree->resolveQmlInheritance();
+ qdb->resolveIssues();
/*
The tree is built and all the stuff that needed resolving
@@ -440,21 +431,18 @@ static void processQdocconfFile(const QString &fileName)
Generator* generator = Generator::generatorForFormat(*of);
if (generator == 0)
outputFormatsLocation.fatal(tr("Unknown output format '%1'").arg(*of));
- generator->generateTree(tree);
+ generator->generateTree();
++of;
}
/*
Generate the XML tag file, if it was requested.
*/
- QString tagFile = config.getString(CONFIG_TAGFILE);
- if (!tagFile.isEmpty()) {
- tree->generateTagFile(tagFile);
- }
+ qdb->generateTagFile(config.getString(CONFIG_TAGFILE));
//Generator::writeOutFileNames();
- tree->setVersion(QString());
+ QDocDatabase::qdocDB()->setVersion(QString());
Generator::terminate();
CodeParser::terminate();
CodeMarker::terminate();
@@ -467,11 +455,11 @@ static void processQdocconfFile(const QString &fileName)
qDeleteAll(translators);
#endif
#ifdef DEBUG_SHUTDOWN_CRASH
- qDebug() << "main(): Delete tree";
+ qDebug() << "main(): Delete qdoc database";
#endif
- delete tree;
+ QDocDatabase::destroyQdocDB();
#ifdef DEBUG_SHUTDOWN_CRASH
- qDebug() << "main(): Tree deleted";
+ qDebug() << "main(): qdoc database deleted";
#endif
}
@@ -584,7 +572,6 @@ int main(int argc, char **argv)
processQdocconfFile(qf);
}
- qDeleteAll(trees);
return EXIT_SUCCESS;
}