25 QMap<QString, QString> attributesToWarnFor;
29 if (missingImageWarning)
30 attributesToWarnFor.insert(QStringLiteral(
"imageUrl"),
31 QStringLiteral(
"Example documentation should have at least one '\\image'"));
32 if (missingProjectFileWarning)
33 attributesToWarnFor.insert(QStringLiteral(
"projectPath"),
34 QStringLiteral(
"Example has no project file"));
36 if (attributesToWarnFor.empty())
39 for (
auto it = attributesToWarnFor.cbegin(); it != attributesToWarnFor.cend(); ++it) {
40 if (!usedAttributes.contains(it.key()))
41 example
->doc().location().warning(example->name() +
": " + it.value());
72 QMap<
int, QString> filesToOpen;
73 for (
const QString &file : files) {
74 QFileInfo fileInfo(file);
75 QString fileName = fileInfo.fileName().toLower();
80 if ((fileInfo.baseName().compare(exampleName, Qt::CaseInsensitive) == 0)) {
81 if (fileName.endsWith(
".qml"))
82 filesToOpen.insert(0, file);
83 else if (fileName.endsWith(
".cpp"))
84 filesToOpen.insert(1, file);
85 else if (fileName.endsWith(
".h"))
86 filesToOpen.insert(2, file);
89 else if (fileName.endsWith(
"main.qml")) {
90 filesToOpen.insert(3, file);
91 }
else if (fileName.endsWith(
"main.cpp")) {
92 filesToOpen.insert(4, file);
272 if (exampleNodeMap.isEmpty())
275 const QString outputFileName =
"examples-manifest.xml";
276 QFile outputFile(m_outputDirectory + QLatin1Char(
'/') + outputFileName);
277 if (!outputFile.open(QFile::WriteOnly | QFile::Text))
280 QXmlStreamWriter writer(&outputFile);
281 writer.setAutoFormatting(
true);
282 writer.writeStartDocument();
283 writer.writeStartElement(
"instructionals");
284 writer.writeAttribute(
"module", m_project);
285 writer.writeStartElement(
"examples");
287 for (
const auto &example : exampleNodeMap.values()) {
288 QMap<QString, QString> usedAttributes;
290 const QString installPath = retrieveExampleInstallationPath(example);
291 const QString fullName = m_project + QLatin1Char(
'/') + example->title();
293 processManifestMetaContent(
294 fullName, [&](
const ManifestMetaFilter &filter) { tags += filter.m_tags; });
295 tags += tagsAddedWithMetaCommand(example);
297 if (tags.contains(
"broken"))
301 usedAttributes.insert(
"name", example->title());
302 usedAttributes.insert(
"docUrl", m_manifestDir + Generator::currentGenerator()->fileBase(example) +
".html");
304 if (!example->projectFile().isEmpty())
305 usedAttributes.insert(
"projectPath", installPath + example->projectFile());
306 if (!example->imageFileName().isEmpty())
307 usedAttributes.insert(
"imageUrl", m_manifestDir + example->imageFileName());
309 processManifestMetaContent(fullName, [&](
const ManifestMetaFilter &filter) {
310 const auto attributes = filter.m_attributes;
311 for (
const auto &attribute : attributes) {
312 const QLatin1Char div(
':');
313 QStringList attrList = attribute.split(div);
314 if (attrList.size() == 1)
315 attrList.append(QStringLiteral(
"true"));
316 QString attrName = attrList.takeFirst();
317 if (!usedAttributes.contains(attrName))
318 usedAttributes.insert(attrName, attrList.join(div));
322 writer.writeStartElement(
"example");
323 for (
auto it = usedAttributes.cbegin(); it != usedAttributes.cend(); ++it)
324 writer.writeAttribute(it.key(), it.value());
326 warnAboutUnusedAttributes(usedAttributes.keys(), example);
327 writeDescription(&writer, example);
329 const QString moduleNameTag = moduleNameAsTag(m_project);
330 if (!moduleNameTag.isEmpty())
331 tags << moduleNameTag;
332 writeTagsElement(&writer, tags);
334 const QString exampleName = example->name().mid(example->name().lastIndexOf(
'/') + 1);
335 const auto files = example->files();
336 const QMap<
int, QString> filesToOpen = getFilesToOpen(files, exampleName);
337 writeFilesToOpen(writer, installPath, filesToOpen);
339 if (
const QStringMultiMap *metaTagMapP = example->doc().metaTagMap()) {
342 QStringMultiMap map = *metaTagMapP;
343 erase_if(map, [](QStringMultiMap::iterator iter) {
344 return iter.key() ==
"tag" || iter.key() ==
"tags" || iter.key() ==
"installpath";
346 writeMetaInformation(writer, map);
349 writer.writeEndElement();
352 writer.writeEndElement();
354 if (!m_exampleCategories.isEmpty()) {
355 writer.writeStartElement(
"categories");
356 for (
const auto &examplecategory : m_exampleCategories) {
357 writer.writeStartElement(
"category");
358 writer.writeCharacters(examplecategory);
359 writer.writeEndElement();
361 writer.writeEndElement();
364 writer.writeEndElement();
365 writer.writeEndDocument();