From ba892305960b37846ee49a90c5684aa8dbfd3d72 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 28 Jun 2012 10:46:59 +0200 Subject: [PATCH] qdoc: Report multiple topic commands as an error Some documenters are using two topic commands in a single qdoc comment. This is only allowed for \qmlproperty so that multiple QML properties can be documented with a single comment. qdoc now reports an error for all other combinations of multiple topic commands. Task Nr: QTBUG-26345 Change-Id: I1f9a6d2502ccffa76c2d41f961be3750014a0a56 Reviewed-by: Casper van Donderen --- src/tools/qdoc/cppcodeparser.cpp | 13 ++++++++++ src/tools/qdoc/generator.cpp | 20 ++++++++++++++++ src/tools/qdoc/generator.h | 1 + src/tools/qdoc/main.cpp | 41 +++++++++++++++++++------------- 4 files changed, 59 insertions(+), 16 deletions(-) diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp index 8737468844..f1a01e72f1 100644 --- a/src/tools/qdoc/cppcodeparser.cpp +++ b/src/tools/qdoc/cppcodeparser.cpp @@ -2268,6 +2268,19 @@ bool CppCodeParser::matchDocsAndStuff() } } else { + if (topicCommandsUsed.count() > 1) { + QString topics; + QSet::ConstIterator t = topicCommandsUsed.constBegin(); + while (t != topicCommandsUsed.constEnd()) { + topics += " \\" + *t + ","; + ++t; + } + topics[topics.lastIndexOf(',')] = '.'; + int i = topics.lastIndexOf(','); + topics[i] = ' '; + topics.insert(i+1,"and"); + doc.location().warning(tr("Multiple topic commands found in comment: %1").arg(topics)); + } ArgList::ConstIterator a = args.constBegin(); while (a != args.constEnd()) { Doc nodeDoc = doc; diff --git a/src/tools/qdoc/generator.cpp b/src/tools/qdoc/generator.cpp index 762f1156b2..ef46e4057f 100644 --- a/src/tools/qdoc/generator.cpp +++ b/src/tools/qdoc/generator.cpp @@ -211,6 +211,25 @@ void Generator::appendSortedQmlNames(Text& text, } } +QMultiMap outFileNames; + +/*! + For debugging qdoc. + */ +void Generator::writeOutFileNames() +{ + QFile* files = new QFile("/Users/msmith/depot/qt5/qtdoc/outputlist.txt"); + files->open(QFile::WriteOnly); + QTextStream* filesout = new QTextStream(files); + QMultiMap::ConstIterator i = outFileNames.begin(); + while (i != outFileNames.end()) { + (*filesout) << i.key() << "\n"; + ++i; + } + filesout->flush(); + files->close(); +} + /*! Creates the file named \a fileName in the output directory. Attaches a QTextStream to the created file, which is written @@ -222,6 +241,7 @@ void Generator::beginSubPage(const InnerNode* node, const QString& fileName) if (!node->outputSubdirectory().isEmpty()) path += node->outputSubdirectory() + QLatin1Char('/'); path += fileName; + outFileNames.insert(fileName,fileName); QFile* outFile = new QFile(path); if (!outFile->open(QFile::WriteOnly)) node->location().fatal(tr("Cannot open output file '%1'").arg(outFile->fileName())); diff --git a/src/tools/qdoc/generator.h b/src/tools/qdoc/generator.h index 59df66b4a7..74cca3ff5b 100644 --- a/src/tools/qdoc/generator.h +++ b/src/tools/qdoc/generator.h @@ -96,6 +96,7 @@ public: static void initialize(const Config& config); static const QString& outputDir() { return outDir_; } static void terminate(); + static void writeOutFileNames(); protected: virtual void beginSubPage(const InnerNode* node, const QString& fileName); diff --git a/src/tools/qdoc/main.cpp b/src/tools/qdoc/main.cpp index 4099a6e729..7686bd3f64 100644 --- a/src/tools/qdoc/main.cpp +++ b/src/tools/qdoc/main.cpp @@ -348,32 +348,43 @@ static void processQdocconfFile(const QString &fileName) headerList = config.getAllFiles(CONFIG_HEADERS,CONFIG_HEADERDIRS,excludedDirs,excludedFiles); QMap headers; - for (int i=0; i headerFileNames; + for (int i=0; i sources; - for (int i=0; i sourceFileNames; + for (int i=0; iopen(QFile::WriteOnly); QTextStream* filesout = new QTextStream(files); -#if 0 + { - QSet::ConstIterator i = headers.begin(); - while (i != headers.end()) { - //(*filesout) << (*i).mid((*i).lastIndexOf('/')+1) << "\n"; + QMultiMap::ConstIterator i = headerFileNames.begin(); + while (i != headerFileNames.end()) { + (*filesout) << i.key() << "\n"; ++i; } - i = sources.begin(); - while (i != sources.end()) { - //(*filesout) << (*i).mid((*i).lastIndexOf('/')+1) << "\n"; + i = sourceFileNames.begin(); + while (i != sourceFileNames.end()) { + (*filesout) << i.key() << "\n"; ++i; } } - //filesout->flush(); - //files->close(); + filesout->flush(); + files->close(); #endif + /* Parse each header file in the set using the appropriate parser and add it to the big tree. @@ -388,7 +399,6 @@ static void processQdocconfFile(const QString &fileName) ++parsed; codeParser->parseHeaderFile(config.location(), h.key(), tree); usedParsers.insert(codeParser); - (*filesout) << (h.key()).mid((h.key()).lastIndexOf('/')+1) << "\n"; } ++h; } @@ -409,12 +419,9 @@ static void processQdocconfFile(const QString &fileName) ++parsed; codeParser->parseSourceFile(config.location(), s.key(), tree); usedParsers.insert(codeParser); - (*filesout) << s.key().mid((s.key()).lastIndexOf('/')+1) << "\n"; } ++s; } - filesout->flush(); - files->close(); foreach (CodeParser *codeParser, usedParsers) codeParser->doneParsingSourceFiles(tree); @@ -452,6 +459,8 @@ static void processQdocconfFile(const QString &fileName) tree->generateTagFile(tagFile); } + //Generator::writeOutFileNames(); + tree->setVersion(QString()); Generator::terminate(); CodeParser::terminate();