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 <casper.vandonderen@nokia.com>
This commit is contained in:
Martin Smith 2012-06-28 10:46:59 +02:00 committed by Qt by Nokia
parent a85759f077
commit ba89230596
4 changed files with 59 additions and 16 deletions

View File

@ -2268,6 +2268,19 @@ bool CppCodeParser::matchDocsAndStuff()
}
}
else {
if (topicCommandsUsed.count() > 1) {
QString topics;
QSet<QString>::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;

View File

@ -211,6 +211,25 @@ void Generator::appendSortedQmlNames(Text& text,
}
}
QMultiMap<QString,QString> 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<QString,QString>::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()));

View File

@ -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);

View File

@ -348,32 +348,43 @@ static void processQdocconfFile(const QString &fileName)
headerList = config.getAllFiles(CONFIG_HEADERS,CONFIG_HEADERDIRS,excludedDirs,excludedFiles);
QMap<QString,QString> headers;
for (int i=0; i<headerList.size(); ++i)
QMultiMap<QString,QString> headerFileNames;
for (int i=0; i<headerList.size(); ++i) {
headers.insert(headerList[i],headerList[i]);
QString t = headerList[i].mid(headerList[i].lastIndexOf('/')+1);
headerFileNames.insert(t,t);
}
sourceList = config.getAllFiles(CONFIG_SOURCES,CONFIG_SOURCEDIRS,excludedDirs,excludedFiles);
QMap<QString,QString> sources;
for (int i=0; i<sourceList.size(); ++i)
QMultiMap<QString,QString> sourceFileNames;
for (int i=0; i<sourceList.size(); ++i) {
sources.insert(sourceList[i],sourceList[i]);
QFile* files = new QFile("/Users/msmith/depot/qt5/qtdoc/files.out");
QString t = sourceList[i].mid(sourceList[i].lastIndexOf('/')+1);
sourceFileNames.insert(t,t);
}
#if 0
QFile* files = new QFile("/Users/msmith/depot/qt5/qtdoc/inputlist.txt");
files->open(QFile::WriteOnly);
QTextStream* filesout = new QTextStream(files);
#if 0
{
QSet<QString>::ConstIterator i = headers.begin();
while (i != headers.end()) {
//(*filesout) << (*i).mid((*i).lastIndexOf('/')+1) << "\n";
QMultiMap<QString,QString>::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();