summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2013-02-14 10:39:37 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-15 17:48:36 +0100
commit284958c2221cabc9b5cbc9cacb2fc848204c9369 (patch)
tree9789fdf99e5742dc8c9643c51728fce680b2a1c0 /src/tools
parent57953e0fea25a7b6ed5292401150869f708c7fd5 (diff)
Doc: Support for meta-content in manifest XML files
This change makes qdoc support additional attributes and tags written to example/demo manifest files. The goal is to enable highlighting of selected items, as well as having additional content to make searching for specific categories work better in Qt Creator welcome screen. This meta-content is stored in manifest-meta.qdocconf, which is loaded globally for all modules. Tag handling is also changed to use a QSet to eliminate possible duplicate tags. Task-number: QTBUG-29354 Change-Id: I2c4b2dff6229172efbecc2bfc1c269017edc4d56 Reviewed-by: Martin Smith <martin.smith@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/qdoc/config.h1
-rw-r--r--src/tools/qdoc/htmlgenerator.cpp60
-rw-r--r--src/tools/qdoc/htmlgenerator.h9
3 files changed, 65 insertions, 5 deletions
diff --git a/src/tools/qdoc/config.h b/src/tools/qdoc/config.h
index 2c655cdf23..521f1c12b8 100644
--- a/src/tools/qdoc/config.h
+++ b/src/tools/qdoc/config.h
@@ -188,6 +188,7 @@ private:
#define CONFIG_INDEXES "indexes"
#define CONFIG_LANGUAGE "language"
#define CONFIG_MACRO "macro"
+#define CONFIG_MANIFESTMETA "manifestmeta"
#define CONFIG_NATURALLANGUAGE "naturallanguage"
#define CONFIG_NOLINKERRORS "nolinkerrors"
#define CONFIG_OBSOLETELINKS "obsoletelinks"
diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp
index 8718161703..2666f10eb4 100644
--- a/src/tools/qdoc/htmlgenerator.cpp
+++ b/src/tools/qdoc/htmlgenerator.cpp
@@ -223,6 +223,7 @@ void HtmlGenerator::initializeGenerator(const Config &config)
QString prefix = CONFIG_QHP + Config::dot + project + Config::dot;
manifestDir = "qthelp://" + config.getString(prefix + "namespace");
manifestDir += QLatin1Char('/') + config.getString(prefix + "virtualFolder") + QLatin1Char('/');
+ readManifestMetaContent(config);
examplesPath = config.getString(CONFIG_EXAMPLESINSTALLPATH);
if (!examplesPath.isEmpty())
examplesPath += QLatin1Char('/');
@@ -3991,10 +3992,11 @@ void HtmlGenerator::generateManifestFiles()
generateManifestFile("examples", "example");
generateManifestFile("demos", "demo");
ExampleNode::exampleNodeMap.clear();
+ manifestMetaContent.clear();
}
/*!
- This function is called by generaqteManiferstFile(), once
+ This function is called by generateManifestFiles(), once
for each manifest file to be generated. \a manifest is the
type of manifest file.
*/
@@ -4086,6 +4088,36 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element)
}
if (!en->imageFileName().isEmpty())
writer.writeAttribute("imageUrl", manifestDir + en->imageFileName());
+
+ QString fullName = project + QLatin1Char('/') + en->title();
+ QSet<QString> tags;
+ for (int idx=0; idx < manifestMetaContent.size(); ++idx) {
+ foreach (const QString &name, manifestMetaContent[idx].names) {
+ bool match = false;
+ int wildcard = name.indexOf(QChar('*'));
+ switch (wildcard) {
+ case -1: // no wildcard, exact match
+ match = (fullName == name);
+ break;
+ case 0: // '*' matches all
+ match = true;
+ break;
+ default: // match with wildcard at the end
+ match = fullName.startsWith(name.left(wildcard));
+ }
+ if (match) {
+ tags += manifestMetaContent[idx].tags;
+ foreach (const QString &attr, manifestMetaContent[idx].attributes) {
+ QStringList attrList = attr.split(QLatin1Char(':'), QString::SkipEmptyParts);
+ if (attrList.count() == 1)
+ attrList.append(QStringLiteral("true"));
+ if (attrList.count() == 2)
+ writer.writeAttribute(attrList[0], attrList[1]);
+ }
+ }
+ }
+ }
+
writer.writeStartElement("description");
Text brief = en->doc().briefText();
if (!brief.isEmpty())
@@ -4093,12 +4125,11 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element)
else
writer.writeCDATA(QString("No description available"));
writer.writeEndElement(); // description
- QStringList tags = en->title().toLower().split(QLatin1Char(' '));
+ tags += QSet<QString>::fromList(en->title().toLower().split(QLatin1Char(' ')));
if (!tags.isEmpty()) {
writer.writeStartElement("tags");
bool wrote_one = false;
- for (int n=0; n<tags.size(); ++n) {
- QString tag = tags.at(n);
+ foreach (QString tag, tags) {
if (tag.at(0).isDigit())
continue;
if (tag.at(0) == '-')
@@ -4109,7 +4140,7 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element)
continue;
if (tag.endsWith(QLatin1Char(':')))
tag.chop(1);
- if (n>0 && wrote_one)
+ if (wrote_one)
writer.writeCharacters(",");
writer.writeCharacters(tag);
wrote_one = true;
@@ -4163,6 +4194,25 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element)
}
/*!
+ Reads metacontent - additional attributes and tags to apply
+ when generating manifest files, read from config. Takes the
+ configuration class \a config as a parameter.
+ */
+void HtmlGenerator::readManifestMetaContent(const Config &config)
+{
+ QStringList names = config.getStringList(CONFIG_MANIFESTMETA + Config::dot + QStringLiteral("filters"));
+
+ foreach (const QString &manifest, names) {
+ ManifestMetaFilter filter;
+ QString prefix = CONFIG_MANIFESTMETA + Config::dot + manifest + Config::dot;
+ filter.names = config.getStringSet(prefix + QStringLiteral("names"));
+ filter.attributes = config.getStringSet(prefix + QStringLiteral("attributes"));
+ filter.tags = config.getStringSet(prefix + QStringLiteral("tags"));
+ manifestMetaContent.append(filter);
+ }
+}
+
+/*!
Find global entities that have documentation but no
\e{relates} comand. Report these as errors if they
are not also marked \e {internal}.
diff --git a/src/tools/qdoc/htmlgenerator.h b/src/tools/qdoc/htmlgenerator.h
index 65d874f619..f2efab78a1 100644
--- a/src/tools/qdoc/htmlgenerator.h
+++ b/src/tools/qdoc/htmlgenerator.h
@@ -108,6 +108,7 @@ protected:
virtual QString linkForNode(const Node *node, const Node *relative);
void generateManifestFile(QString manifest, QString element);
+ void readManifestMetaContent(const Config &config);
private:
enum SubTitleSize { SmallSubTitle, LargeSubTitle };
@@ -118,6 +119,13 @@ private:
EndMark
};
+ struct ManifestMetaFilter
+ {
+ QSet<QString> names;
+ QSet<QString> attributes;
+ QSet<QString> tags;
+ };
+
const QPair<QString,QString> anchorForNode(const Node *node);
void generateBreadCrumbs(const QString& title,
const Node *node,
@@ -242,6 +250,7 @@ private:
bool obsoleteLinks;
QStack<QXmlStreamWriter*> xmlWriterStack;
static int id;
+ QList<ManifestMetaFilter> manifestMetaContent;
public:
static bool debugging_on;
static QString divNavTop;