aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/doc
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-04-06 16:24:34 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-04-30 12:46:05 +0000
commitd2fa0f63f08f5cca57be306b9569cb9a76af7cea (patch)
treee9dc99c0c1c68f50a59b6b3ba3988f14e0a12d32 /sources/pyside2/doc
parentfaefb8130908da20b4a738dd1d3f1eac7e87bde5 (diff)
Add tool for creating a license page
Add a tool which runs qtattributionsscanner and converts its JSON output to .rst to create an additional license page It differs from the Qt usage in that the license text is extracted from triple quotes of the referenced file. Task-number: PYSIDE-363 Change-Id: Idef9b0ada06bec5947aac210d7fec25fd0742ab8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/pyside2/doc')
-rw-r--r--sources/pyside2/doc/CMakeLists.txt12
-rw-r--r--sources/pyside2/doc/qtattributionsscannertorst.py141
2 files changed, 152 insertions, 1 deletions
diff --git a/sources/pyside2/doc/CMakeLists.txt b/sources/pyside2/doc/CMakeLists.txt
index 326e5ae7d..e40602b97 100644
--- a/sources/pyside2/doc/CMakeLists.txt
+++ b/sources/pyside2/doc/CMakeLists.txt
@@ -98,7 +98,17 @@ add_custom_target("docrsts"
WORKING_DIRECTORY ${${module}_SOURCE_DIR}
COMMENT "Running generator to generate documentation..."
)
-add_dependencies(apidoc docrsts)
+
+add_custom_target("licensedocrsts"
+ COMMAND ${PYTHON_EXECUTABLE}
+ ${CMAKE_CURRENT_LIST_DIR}/qtattributionsscannertorst.py
+ ${CMAKE_CURRENT_LIST_DIR}/../../..
+ ${CMAKE_CURRENT_BINARY_DIR}/rst/licenses.rst
+ COMMENT "Creating 3rdparty license documentation..."
+)
+
+add_dependencies(apidoc docrsts licensedocrsts)
+add_dependencies(licensedocrsts docrsts)
add_dependencies(docrsts qdoc)
# #create devhelp file
diff --git a/sources/pyside2/doc/qtattributionsscannertorst.py b/sources/pyside2/doc/qtattributionsscannertorst.py
new file mode 100644
index 000000000..fa1e1d2de
--- /dev/null
+++ b/sources/pyside2/doc/qtattributionsscannertorst.py
@@ -0,0 +1,141 @@
+#############################################################################
+##
+## Copyright (C) 2018 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the Qt for Python project.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU Lesser
+## General Public License version 3 as published by the Free Software
+## Foundation and appearing in the file LICENSE.LGPL3 included in the
+## packaging of this file. Please review the following information to
+## ensure the GNU Lesser General Public License version 3 requirements
+## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 2.0 or (at your option) the GNU General
+## Public license version 3 or any later version approved by the KDE Free
+## Qt Foundation. The licenses are as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-2.0.html and
+## https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+"""
+Tool to run qtattributionsscanner and convert its output to rst
+"""
+
+import os, json, subprocess, sys
+
+def indent(lines, indent):
+ result = ''
+ for l in lines:
+ result += "{}{}\n".format(indent, l)
+ return result
+
+rstHeader="""Licenses Used in Qt for Python
+******************************
+
+Qt for Python contains some code that is not provided under the
+GNU Lesser General Public License (LGPL) or the Qt Commercial License,
+but rather under specific licenses from the original authors.
+
+Qt for Python contains some code that is not provided under the
+GNU Lesser General Public License (LGPL) or the Qt Commercial License,
+but rather under specific licenses from the original authors.
+The Qt Company gratefully acknowledges these and other contributions
+to Qt for Python. We recommend that programs that use Qt for Python
+also acknowledge these contributions, and quote these license
+statements in an appendix to the documentation.
+
+Note: You only need to comply with (and acknowledge) the licenses of
+the third-party components that you are using with your application.
+Click the name of the component to see the licensing details.
+
+Third-party Licenses
+^^^^^^^^^^^^^^^^^^^^
+
+The following table lists parts of Qt for Python that incorporate code
+licensed under third-party open-source licenses:
+
+"""
+
+rstEntryFormat = """{}
+
+{}
+
+{}
+
+{}
+
+`Project Homepage <{}>`_ , upstream version: {}
+
+::
+
+{}
+
+
+"""
+
+# Extract the license which is embedded in triple quotes
+def extractLicense(fileName):
+ result = []
+ with open(fileName, 'r') as file:
+ recording = False
+ for line in file.readlines():
+ line = line.strip("\n\r\xc2\xb6")
+ if line == '"""':
+ if recording:
+ break
+ else:
+ recording = True
+ elif recording:
+ result.append(line)
+ return result
+
+def runScanner(directory, targetFileName):
+ # qtattributionsscanner recursively searches for qt_attribution.json files
+ # and outputs them in JSON with the paths of the 'LicenseFile' made absolute
+ command = 'qtattributionsscanner --output-format json {}'.format(directory)
+ jsonS = subprocess.check_output(command, shell=True)
+ if not jsonS:
+ raise RuntimeError('{} failed to produce output.'.format(command))
+
+ with open(targetFileName, 'w') as targetFile:
+ targetFile.write(rstHeader)
+ for entry in json.loads(jsonS):
+ name = entry['Name']
+ title = "{}\n{}".format(name, '-' * len(name))
+ brief = entry['License']
+ url = entry['Homepage']
+ version = entry['Version']
+ description = entry['Description']
+ qtUsage = entry['QtUsage']
+ content = extractLicense(entry['LicenseFile'])
+ rst = rstEntryFormat.format(title, brief, description, qtUsage,
+ url, version, indent(content, ' '))
+ targetFile.write(rst)
+
+if len(sys.argv) < 3:
+ print("Usage: qtattributionsscannertorst [directory] [file]'")
+ sys.exit(0)
+
+directory = sys.argv[1]
+targetFileName = sys.argv[2]
+runScanner(directory, targetFileName)