diff options
author | Kai Koehne <kai.koehne@qt.io> | 2016-11-21 15:44:43 +0100 |
---|---|---|
committer | Kai Koehne <kai.koehne@qt.io> | 2016-11-28 13:45:22 +0000 |
commit | c3b5247161eff3b521381a9ada14b180e330a037 (patch) | |
tree | 4411a75b2d11b6b8569a199c4eacc339a7701968 | |
parent | 1ba2796c6b32e33824230fe85300f4ee4d615ab5 (diff) |
qtattributionscanner: Support optional QtParts property
We'd like to differentiate between code that ends up in the
Qt libraries or plugins, or code that only is added to examples,
tests, or (host) tools. This can now be specified with the
JSON property 'QtParts'.
If 'QtParts' does not contain 'libs', the page will not show up in the
list of attributions generated by module with e.g.
\generatelist{groupsbymodule attributions-qtcore}
nor in the global list generated by
\generatelist annotatedattributions
Instead, third party code in examples or tests can now be documented
separately using e.g.
\generatelist{groupsbymodule attributions-examples}
and
\annotatedlist attributions-examples
Change-Id: Iba72f76b63e4435af54a61b7b4a2cf4617746ba6
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
8 files changed, 51 insertions, 4 deletions
diff --git a/src/qtattributionsscanner/jsongenerator.cpp b/src/qtattributionsscanner/jsongenerator.cpp index 580fddf57..d5b0249a5 100644 --- a/src/qtattributionsscanner/jsongenerator.cpp +++ b/src/qtattributionsscanner/jsongenerator.cpp @@ -46,6 +46,7 @@ static QJsonObject generate(Package package) obj.insert(QStringLiteral("QDocModule"), package.qdocModule); obj.insert(QStringLiteral("Name"), package.name); obj.insert(QStringLiteral("QtUsage"), package.qtUsage); + obj.insert(QStringLiteral("QtParts"), QJsonArray::fromStringList(package.qtParts)); obj.insert(QStringLiteral("Description"), package.description); obj.insert(QStringLiteral("Homepage"), package.homepage); diff --git a/src/qtattributionsscanner/package.h b/src/qtattributionsscanner/package.h index 31d95c9fb..a0cb82fdd 100644 --- a/src/qtattributionsscanner/package.h +++ b/src/qtattributionsscanner/package.h @@ -40,6 +40,8 @@ struct Package { QString name; // Descriptive name of the package. Will be used as the title. Mandatory. QString qdocModule; // QDoc module where the documentation should be included. Mandatory. QString qtUsage; // How the package is used in Qt. Any way to disable? Mandatory. + QStringList qtParts; // Possible values are "examples", "tests", "tools", or "libs". + // "libs" is the default. QString description; // A short description of what the package is and is used for. Optional. QString homepage; // Homepage of the upstream project. Optional. diff --git a/src/qtattributionsscanner/qdocgenerator.cpp b/src/qtattributionsscanner/qdocgenerator.cpp index dae942f66..c78ebd4b9 100644 --- a/src/qtattributionsscanner/qdocgenerator.cpp +++ b/src/qtattributionsscanner/qdocgenerator.cpp @@ -71,8 +71,20 @@ static void generate(QTextStream &out, const Package &package, const QDir &baseD { out << "/*!\n\n"; out << "\\contentspage attributions.html\n"; - out << "\\ingroup attributions-" << package.qdocModule << "\n"; - out << "\\page " << package.qdocModule << "-attribution-" << package.id << ".html attribution\n"; + for (const QString &part: package.qtParts) + out << "\\ingroup attributions-" << part << "\n"; + + if (package.qtParts.contains(QLatin1String("libs"))) { + // show up in xxx-index.html page of module + out << "\\ingroup attributions-" << package.qdocModule << "\n"; + // include in '\generatelist annotatedattributions' + out << "\\page " << package.qdocModule << "-attribution-" << package.id + << ".html attribution\n"; + } else { + out << "\\page " << package.qdocModule << "-attribution-" << package.id + << ".html \n"; + } + out << "\\target " << package.id << "\n\n"; out << "\\title " << package.name << "\n"; out << "\\brief " << package.license << "\n\n"; diff --git a/src/qtattributionsscanner/scanner.cpp b/src/qtattributionsscanner/scanner.cpp index 3babfbaef..a405b2b03 100644 --- a/src/qtattributionsscanner/scanner.cpp +++ b/src/qtattributionsscanner/scanner.cpp @@ -34,7 +34,6 @@ #include <QtCore/qjsondocument.h> #include <QtCore/qjsonobject.h> #include <QtCore/qvariant.h> - #include <iostream> namespace Scanner { @@ -54,7 +53,7 @@ static Package readPackage(const QJsonObject &object, const QString &filePath, L for (auto iter = object.constBegin(); iter != object.constEnd(); ++iter) { const QString key = iter.key(); - if (!iter.value().isString() && key != QLatin1String("files")) { + if (!iter.value().isString() && key != QLatin1String("QtParts")) { if (logLevel != SilentLog) std::cerr << qPrintable(tr("File %1: Expected JSON string as value of %2.").arg( QDir::toNativeSeparators(filePath), key)) << std::endl; @@ -89,6 +88,16 @@ static Package readPackage(const QJsonObject &object, const QString &filePath, L p.description = value; } else if (key == QLatin1String("QtUsage")) { p.qtUsage = value; + } else if (key == QLatin1String("QtParts")) { + const QVariantList variantList = iter.value().toArray().toVariantList(); + for (const QVariant &v: variantList) { + if (v.type() != QMetaType::QString && logLevel != SilentLog) { + std::cerr << qPrintable(tr("File %1: Expected JSON string in array of %2.").arg( + QDir::toNativeSeparators(filePath), key)) + << std::endl; + } + p.qtParts.append(v.toString()); + } } else { if (logLevel != SilentLog) std::cerr << qPrintable(tr("File %1: Unknown key %2.").arg( @@ -110,6 +119,22 @@ static Package readPackage(const QJsonObject &object, const QString &filePath, L missingPropertyWarning(filePath, QStringLiteral("License")); if (p.copyright.isEmpty()) missingPropertyWarning(filePath, QStringLiteral("Copyright")); + if (p.qtParts.isEmpty()) + p.qtParts << QStringLiteral("libs"); + + foreach (const QString &part, p.qtParts) { + if (part != QLatin1String("examples") + && part != QLatin1String("tests") + && part != QLatin1String("tools") + && part != QLatin1String("libs") + && logLevel != SilentLog) { + std::cerr << qPrintable(tr("File %1: Property 'QtPart' contains unknown element " + "'%2'. Valid entries are 'examples', 'tests', 'tools' " + "and 'libs'.").arg( + QDir::toNativeSeparators(filePath), part)) + << std::endl; + } + } } return p; } diff --git a/tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution.json b/tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution.json index eaebdb9ef..f8e7b1c68 100644 --- a/tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution.json +++ b/tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution.json @@ -2,6 +2,7 @@ "Id": "complete", "Name": "Complete", "QDocModule": "qtest", + "QtParts": ["examples"], "License": "License", "Copyright": "Copyright", diff --git a/tests/auto/qtattributionsscanner/testdata/good/expected.json b/tests/auto/qtattributionsscanner/testdata/good/expected.json index 2a076d650..2914dcc4b 100644 --- a/tests/auto/qtattributionsscanner/testdata/good/expected.json +++ b/tests/auto/qtattributionsscanner/testdata/good/expected.json @@ -11,6 +11,7 @@ "Path": "%{PWD}/complete", "Files": "", "QDocModule": "qtest", + "QtParts": [ "examples" ], "QtUsage": "Multi\nLine\nUsage", "Version": "1.0", "DownloadLocation": "www.qt.io/1.0" @@ -27,6 +28,9 @@ "Path": "%{PWD}/minimal", "Files": "", "QDocModule": "qtest", + "QtParts": [ + "libs" + ], "QtUsage": "Usage", "Version": "", "DownloadLocation": "" diff --git a/tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json b/tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json index 5ddb2d32d..a28547bfe 100644 --- a/tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json +++ b/tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json @@ -11,6 +11,7 @@ "Path": "%{PWD}", "Files": "", "QDocModule": "", + "QtParts": [ "libs" ], "QtUsage": "", "Version": "", "DownloadLocation": "" diff --git a/tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json b/tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json index da2febe18..151af4093 100644 --- a/tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json +++ b/tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json @@ -11,6 +11,7 @@ "Path": "%{PWD}", "Files": "", "QDocModule": "qtest", + "QtParts": [ "libs" ], "QtUsage": "Usage", "Version": "", "DownloadLocation": "" |