From 997f52b83d41d2ed31a3b36384d1dd3bc78a697c Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 16 Jun 2015 14:10:51 +0200 Subject: qdoc: Keep track of attributes written to example manifest files The content written to example manifest files can be extended with additional metadata in the form of xml attributes. In order to avoid invalid (duplicated) input from generating malformed xml, QDoc now keeps track of the attributes and only writes metadata that hasn't already been written. Task-number: QTBUG-46692 Change-Id: I645935fa8f32b915b7335c400f5a8f2cf72802b7 Reviewed-by: Martin Smith --- src/tools/qdoc/htmlgenerator.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/tools/qdoc/htmlgenerator.cpp') diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index 8d84019ab5..21fffdabc3 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -4456,6 +4456,7 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString writer.writeAttribute("module", project); writer.writeStartElement(manifest); + QStringList usedAttributes; i = exampleNodeMap.begin(); while (i != exampleNodeMap.end()) { const ExampleNode* en = i.value(); @@ -4469,6 +4470,10 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString ++i; continue; } + // attributes that are always written for the element + usedAttributes.clear(); + usedAttributes << "name" << "docUrl" << "projectPath"; + writer.writeStartElement(element); writer.writeAttribute("name", en->title()); QString docUrl = manifestDir + fileBase(en) + ".html"; @@ -4502,8 +4507,10 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString writer.writeAttribute("projectPath", examplesPath + proFiles[0]); } } - if (!en->imageFileName().isEmpty()) + if (!en->imageFileName().isEmpty()) { writer.writeAttribute("imageUrl", manifestDir + en->imageFileName()); + usedAttributes << "imageUrl"; + } QString fullName = project + QLatin1Char('/') + en->title(); QSet tags; @@ -4529,7 +4536,10 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString if (attrList.count() == 1) attrList.append(QStringLiteral("true")); QString attrName = attrList.takeFirst(); - writer.writeAttribute(attrName, attrList.join(div)); + if (!usedAttributes.contains(attrName)) { + writer.writeAttribute(attrName, attrList.join(div)); + usedAttributes << attrName; + } } } } -- cgit v1.2.3