From 8597458cebf1df64b5559426ec5c1d14567b2a83 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 16 Apr 2013 14:29:14 +0200 Subject: [PATCH] qdoc: Include words from the module name as tags in example manifest This change adds words from the module name (QHP 'project' name defined in .qdocconf files) as tags for the module's examples. This makes searching for examples easier in Qt Creator: For example, typing 'multimedia' will list all examples in Qt Multimedia and Qt Multimedia Widgets modules. Other minor changes: - Exclude 'qt' as a tag (not needed) - Exclude one-character strings as tags Task-number: QTBUG-28720 Change-Id: I53751b7a87ff39ee7b648f865c9090c52444de76 Reviewed-by: Martin Smith --- src/tools/qdoc/htmlgenerator.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index e49f083e5b..c5dc7d17c9 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -4182,15 +4182,28 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element) else writer.writeCDATA(QString("No description available")); writer.writeEndElement(); // description + + // Add words from module name as tags (QtQuickControls -> qt,quick,controls) + QRegExp re("([A-Z][a-z0-9]+)"); + int pos = 0; + while ((pos = re.indexIn(project, pos)) != -1) { + tags << re.cap(1).toLower(); + pos += re.matchedLength(); + } tags += QSet::fromList(en->title().toLower().split(QLatin1Char(' '))); if (!tags.isEmpty()) { writer.writeStartElement("tags"); bool wrote_one = false; + // Exclude invalid and common words foreach (QString tag, tags) { + if (tag.length() < 2) + continue; if (tag.at(0).isDigit()) continue; if (tag.at(0) == '-') continue; + if (tag == QStringLiteral("qt")) + continue; if (tag.startsWith("example")) continue; if (tag.startsWith("chapter"))