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 <martin.smith@digia.com>
bb10
Topi Reinio 2015-06-16 14:10:51 +02:00 committed by Jani Heikkinen
parent 0e8d657ae0
commit 997f52b83d
1 changed files with 12 additions and 2 deletions

View File

@ -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<QString> 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;
}
}
}
}