summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@qt.io>2019-03-18 14:03:49 +0100
committerKai Koehne <kai.koehne@qt.io>2019-03-25 13:59:42 +0000
commite9662ddd86f027bdbe617f5171cd63cae13b3845 (patch)
tree8ba70fd2476cfb19b0dd0b4f9aaf69ebedc58ec9
parent9c7502b0e5056da021ace0195e53d5b7b410120b (diff)
downloadqttools-e9662ddd86f027bdbe617f5171cd63cae13b3845.tar.gz
qtattributionsscanner: Add "PackageComment" field
Add a new field that can be used for general purpose comments about the package, not to be included in the generated qdoc documentation. JSON does not support comments as a first-class concept. A common workaround is to use duplicated key entries, so that the first one can be used as a comment field. Anyhow, this is arguably a hack and not common knowledge. The name is inspired by the "PackageComment" field in SPDX. The new feature should already be made part of 5.12 so we can clean up version information that recently became more prominently visible as part of the qdoc title - see https://doc.qt.io/qt-5/licenses-used-in-qt.html Change-Id: Icfe843d1d725618114442687222c24122d0dd6b9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rw-r--r--src/qtattributionsscanner/jsongenerator.cpp1
-rw-r--r--src/qtattributionsscanner/package.h2
-rw-r--r--src/qtattributionsscanner/scanner.cpp2
-rw-r--r--tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution_test.json3
-rw-r--r--tests/auto/qtattributionsscanner/testdata/good/expected.json2
-rw-r--r--tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json1
-rw-r--r--tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json1
-rw-r--r--tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json1
8 files changed, 12 insertions, 1 deletions
diff --git a/src/qtattributionsscanner/jsongenerator.cpp b/src/qtattributionsscanner/jsongenerator.cpp
index 37d0426af..44fb784aa 100644
--- a/src/qtattributionsscanner/jsongenerator.cpp
+++ b/src/qtattributionsscanner/jsongenerator.cpp
@@ -58,6 +58,7 @@ static QJsonObject generate(Package package)
obj.insert(QStringLiteral("LicenseFile"), package.licenseFile);
obj.insert(QStringLiteral("Copyright"), package.copyright);
+ obj.insert(QStringLiteral("PackageComment"), package.packageComment);
return obj;
}
diff --git a/src/qtattributionsscanner/package.h b/src/qtattributionsscanner/package.h
index a0cb82fdd..4a8a9e3e2 100644
--- a/src/qtattributionsscanner/package.h
+++ b/src/qtattributionsscanner/package.h
@@ -53,6 +53,8 @@ struct Package {
QString licenseFile; // path to file containing the license text. Optional.
QString copyright; // A list of copyright owners. Mandatory.
+
+ QString packageComment; // Further comments about the package. Optional.
};
#endif // PACKAGE_H
diff --git a/src/qtattributionsscanner/scanner.cpp b/src/qtattributionsscanner/scanner.cpp
index fe59d9942..0604dc988 100644
--- a/src/qtattributionsscanner/scanner.cpp
+++ b/src/qtattributionsscanner/scanner.cpp
@@ -83,6 +83,8 @@ static Package readPackage(const QJsonObject &object, const QString &filePath, L
p.licenseFile = QDir(directory).absoluteFilePath(value);
} else if (key == QLatin1String("Copyright")) {
p.copyright = value;
+ } else if (key == QLatin1String("PackageComment")) {
+ p.packageComment = value;
} else if (key == QLatin1String("QDocModule")) {
p.qdocModule = value;
} else if (key == QLatin1String("Description")) {
diff --git a/tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution_test.json b/tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution_test.json
index f8e7b1c68..8035cefab 100644
--- a/tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution_test.json
+++ b/tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution_test.json
@@ -17,5 +17,6 @@ Usage",
"Version": "1.0",
"DownloadLocation": "www.qt.io/1.0",
"LicenseId": "xxx",
- "LicenseFile": "LICENSE"
+ "LicenseFile": "LICENSE",
+ "PackageComment": "just a test package"
}
diff --git a/tests/auto/qtattributionsscanner/testdata/good/expected.json b/tests/auto/qtattributionsscanner/testdata/good/expected.json
index 2914dcc4b..89a727cd0 100644
--- a/tests/auto/qtattributionsscanner/testdata/good/expected.json
+++ b/tests/auto/qtattributionsscanner/testdata/good/expected.json
@@ -8,6 +8,7 @@
"LicenseFile": "%{PWD}/complete/LICENSE",
"LicenseId": "xxx",
"Name": "Complete",
+ "PackageComment":"just a test package",
"Path": "%{PWD}/complete",
"Files": "",
"QDocModule": "qtest",
@@ -25,6 +26,7 @@
"LicenseFile": "",
"LicenseId": "",
"Name": "Minimal",
+ "PackageComment":"",
"Path": "%{PWD}/minimal",
"Files": "",
"QDocModule": "qtest",
diff --git a/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json b/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json
index 6a75269c0..8d9a5a31f 100644
--- a/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json
+++ b/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json
@@ -8,6 +8,7 @@
"LicenseFile": "",
"LicenseId": "",
"Name": "Minimal",
+ "PackageComment": "",
"Path": "%{PWD}",
"Files": "",
"QDocModule": "qtest",
diff --git a/tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json b/tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json
index a28547bfe..fa56f2976 100644
--- a/tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json
+++ b/tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json
@@ -8,6 +8,7 @@
"LicenseFile": "",
"LicenseId": "",
"Name": "",
+ "PackageComment": "",
"Path": "%{PWD}",
"Files": "",
"QDocModule": "",
diff --git a/tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json b/tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json
index 151af4093..18c1055f2 100644
--- a/tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json
+++ b/tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json
@@ -8,6 +8,7 @@
"LicenseFile": "",
"LicenseId": "",
"Name": "Unknown",
+ "PackageComment": "",
"Path": "%{PWD}",
"Files": "",
"QDocModule": "qtest",