aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-10-01 11:30:48 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-10-06 19:29:55 +0200
commitd3ae7cbd8ee271e2d9ec1d547d2755a3bf2661f6 (patch)
treec1e3221a444de74cd1366531742358dbd98fd9b8 /sources
parent1fb2f32e4768200506924c57bb2d93458d43dfea (diff)
Documentation: Fix missing signal/slot lists in class documentation
shiboken needs to run with pyside extensions to parse the Qt annoations correctly. Change 62c21af778b7bff6c86e7f89ef03a87efa6c51cb moved the compiler defines from the pyside global header into shiboken. This caused the function type detection to fail in the doc generator since it did not pyside extensions and thus signals/slots were listed as normal functions. To fix this, move the --enable-pyside-extensions option to the base class Generator and add it to documentation's CMakeLists.txt. Change-Id: I70142367ee01839d8e44cbf31e894991cf941197 Reviewed-by: Christian Tismer <tismer@stackless.com> (cherry picked from commit 614787bfc8f0210e30beecc0f03c9fe772f9c139)
Diffstat (limited to 'sources')
-rw-r--r--sources/pyside2/doc/CMakeLists.txt1
-rw-r--r--sources/shiboken2/generator/generator.cpp18
-rw-r--r--sources/shiboken2/generator/generator.h3
-rw-r--r--sources/shiboken2/generator/main.cpp3
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp6
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp19
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.h4
7 files changed, 32 insertions, 22 deletions
diff --git a/sources/pyside2/doc/CMakeLists.txt b/sources/pyside2/doc/CMakeLists.txt
index ab5d694e7..950e48686 100644
--- a/sources/pyside2/doc/CMakeLists.txt
+++ b/sources/pyside2/doc/CMakeLists.txt
@@ -152,6 +152,7 @@ configure_file("conf.py.in" "rst/conf.py" @ONLY)
add_custom_target("docrsts"
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/rst
COMMAND Shiboken2::shiboken2 --generator-set=qtdoc ${docHeader}
+ --enable-pyside-extensions
--include-paths="${QT_INCLUDE_DIR}${PATH_SEP}${pyside2_SOURCE_DIR}${PATH_SEP}${TS_ROOT}"
--api-version=${SUPPORTED_QT_VERSION}
--typesystem-paths="${QDOC_TYPESYSTEM_PATH}"
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp
index c1554b6c4..c48ceb231 100644
--- a/sources/shiboken2/generator/generator.cpp
+++ b/sources/shiboken2/generator/generator.cpp
@@ -36,6 +36,8 @@
#include <QDebug>
#include <typedatabase.h>
+static const char ENABLE_PYSIDE_EXTENSIONS[] = "enable-pyside-extensions";
+
/**
* DefaultValue is used for storing default values of types for which code is
* generated in different contexts:
@@ -162,6 +164,7 @@ struct Generator::GeneratorPrivate
QVector<const AbstractMetaType *> instantiatedContainers;
QVector<const AbstractMetaType *> instantiatedSmartPointers;
AbstractMetaClassList m_invisibleTopNamespaces;
+ bool m_usePySideExtensions = false;
};
Generator::Generator() : m_d(new GeneratorPrivate)
@@ -332,11 +335,17 @@ QVector<const AbstractMetaType *> Generator::instantiatedSmartPointers() const
Generator::OptionDescriptions Generator::options() const
{
- return OptionDescriptions();
+ return {
+ {QLatin1String(ENABLE_PYSIDE_EXTENSIONS),
+ QLatin1String("Enable PySide extensions, such as support for signal/slots,\n"
+ "use this if you are creating a binding for a Qt-based library.")}
+ };
}
-bool Generator::handleOption(const QString & /* key */, const QString & /* value */)
+bool Generator::handleOption(const QString & key, const QString & /* value */)
{
+ if (key == QLatin1String(ENABLE_PYSIDE_EXTENSIONS))
+ return ( m_d->m_usePySideExtensions = true);
return false;
}
@@ -608,6 +617,11 @@ bool Generator::isVoidPointer(const AbstractMetaType *type)
&& type->name() == QLatin1String("void");
}
+bool Generator::usePySideExtensions() const
+{
+ return m_d->m_usePySideExtensions;
+}
+
QString Generator::getFullTypeName(const TypeEntry *type) const
{
QString result = type->qualifiedCppName();
diff --git a/sources/shiboken2/generator/generator.h b/sources/shiboken2/generator/generator.h
index 6def445eb..6294e0310 100644
--- a/sources/shiboken2/generator/generator.h
+++ b/sources/shiboken2/generator/generator.h
@@ -237,6 +237,9 @@ public:
/// Returns the generator's name. Used for cosmetic purposes.
virtual const char *name() const = 0;
+ /// Returns true if the user enabled PySide extensions (command line option)
+ bool usePySideExtensions() const;
+
/**
* Retrieves the name of the currently processed module.
* While package name is a complete package idetification, e.g. 'PySide.QtCore',
diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp
index b22d76ad8..69bc1f2b6 100644
--- a/sources/shiboken2/generator/main.cpp
+++ b/sources/shiboken2/generator/main.cpp
@@ -605,8 +605,7 @@ int main(int argc, char *argv[])
extractor.setCppFileNames(cppFileNames);
extractor.setTypeSystem(typeSystemFileName);
- auto shibokenGenerator = dynamic_cast<const ShibokenGenerator *>(generators.constFirst().data());
- const bool usePySideExtensions = shibokenGenerator && shibokenGenerator->usePySideExtensions();
+ const bool usePySideExtensions = generators.constFirst().data()->usePySideExtensions();
if (!extractor.run(usePySideExtensions)) {
errorPrint(QLatin1String("Error running ApiExtractor."));
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index 8622c6c5b..19fc1d066 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -2346,7 +2346,8 @@ bool QtDocGenerator::doSetup()
Generator::OptionDescriptions QtDocGenerator::options() const
{
- return OptionDescriptions()
+ OptionDescriptions result = Generator::options();
+ result
<< qMakePair(QLatin1String("doc-parser=<parser>"),
QLatin1String("The documentation parser used to interpret the documentation\n"
"input files (qdoc|doxygen)"))
@@ -2361,10 +2362,13 @@ Generator::OptionDescriptions QtDocGenerator::options() const
<< qMakePair(additionalDocumentationOption() + QLatin1String("=<file>"),
QLatin1String("List of additional XML files to be converted to .rst files\n"
"(for example, tutorials)."));
+ return result;
}
bool QtDocGenerator::handleOption(const QString &key, const QString &value)
{
+ if (Generator::handleOption(key, value))
+ return true;
if (key == QLatin1String("library-source-dir")) {
m_libSourceDir = value;
return true;
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index f4541a5db..e501d436a 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -39,7 +39,6 @@
static const char AVOID_PROTECTED_HACK[] = "avoid-protected-hack";
static const char PARENT_CTOR_HEURISTIC[] = "enable-parent-ctor-heuristic";
static const char RETURN_VALUE_HEURISTIC[] = "enable-return-value-heuristic";
-static const char ENABLE_PYSIDE_EXTENSIONS[] = "enable-pyside-extensions";
static const char DISABLE_VERBOSE_ERROR_MESSAGES[] = "disable-verbose-error-messages";
static const char USE_ISNULL_AS_NB_NONZERO[] = "use-isnull-as-nb_nonzero";
static const char WRAPPER_DIAGNOSTICS[] = "wrapper-diagnostics";
@@ -2560,7 +2559,8 @@ AbstractMetaFunctionList ShibokenGenerator::getFunctionOverloads(const AbstractM
Generator::OptionDescriptions ShibokenGenerator::options() const
{
- return OptionDescriptions()
+ OptionDescriptions result = Generator::options();
+ result
<< qMakePair(QLatin1String(AVOID_PROTECTED_HACK),
QLatin1String("Avoid the use of the '#define protected public' hack."))
<< qMakePair(QLatin1String(DISABLE_VERBOSE_ERROR_MESSAGES),
@@ -2568,9 +2568,6 @@ Generator::OptionDescriptions ShibokenGenerator::options() const
"but safe few kB on the generated bindings."))
<< qMakePair(QLatin1String(PARENT_CTOR_HEURISTIC),
QLatin1String("Enable heuristics to detect parent relationship on constructors."))
- << qMakePair(QLatin1String(ENABLE_PYSIDE_EXTENSIONS),
- QLatin1String("Enable PySide extensions, such as support for signal/slots,\n"
- "use this if you are creating a binding for a Qt-based library."))
<< qMakePair(QLatin1String(RETURN_VALUE_HEURISTIC),
QLatin1String("Enable heuristics to detect parent relationship on return values\n"
"(USE WITH CAUTION!)"))
@@ -2579,14 +2576,15 @@ Generator::OptionDescriptions ShibokenGenerator::options() const
"the value of boolean casts"))
<< qMakePair(QLatin1String(WRAPPER_DIAGNOSTICS),
QLatin1String("Generate diagnostic code around wrappers"));
+ return result;
}
-bool ShibokenGenerator::handleOption(const QString &key, const QString & /* value */)
+bool ShibokenGenerator::handleOption(const QString &key, const QString &value)
{
+ if (Generator::handleOption(key, value))
+ return true;
if (key == QLatin1String(PARENT_CTOR_HEURISTIC))
return (m_useCtorHeuristic = true);
- if (key == QLatin1String(ENABLE_PYSIDE_EXTENSIONS))
- return (m_usePySideExtensions = true);
if (key == QLatin1String(RETURN_VALUE_HEURISTIC))
return (m_userReturnValueHeuristic = true);
if (key == QLatin1String(DISABLE_VERBOSE_ERROR_MESSAGES))
@@ -2688,11 +2686,6 @@ bool ShibokenGenerator::useReturnValueHeuristic() const
return m_userReturnValueHeuristic;
}
-bool ShibokenGenerator::usePySideExtensions() const
-{
- return m_usePySideExtensions;
-}
-
bool ShibokenGenerator::useIsNullAsNbNonZero() const
{
return m_useIsNullAsNbNonZero;
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
index e81715ad2..104dd9af4 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
@@ -83,9 +83,6 @@ public:
/// Returns a list of all ancestor classes for the given class.
AbstractMetaClassList getAllAncestors(const AbstractMetaClass *metaClass) const;
- /// Returns true if the user enabled PySide extensions.
- bool usePySideExtensions() const;
-
protected:
bool doSetup() override;
@@ -557,7 +554,6 @@ private:
bool m_useCtorHeuristic = false;
bool m_userReturnValueHeuristic = false;
- bool m_usePySideExtensions = false;
bool m_verboseErrorMessagesDisabled = false;
bool m_useIsNullAsNbNonZero = false;
bool m_avoidProtectedHack = false;