diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-11-22 13:35:35 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-11-24 12:40:38 +0100 |
commit | 56f3ecf68c67c45b42caa7940218d6be42156539 (patch) | |
tree | baa0dd88ed53c31c421d0ef69f39d45759cf055b | |
parent | 34e8eb569b865259055558384f91b7eeb4e27958 (diff) |
shiboken6: Store the property documentation in QPropertySpec
Similar to AbstractMetaFunction and AbstractMetaClass, store
the documentation (brief/detail) in QPropertySpec.
Task-number: PYSIDE-1106
Task-number: PYSIDE-1019
Pick-to: 6.4
Change-Id: Ide236b5918c135e331149ca384ed973fd794b55f
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
7 files changed, 48 insertions, 5 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp index 1ae0e1f1a..77d346a9d 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp @@ -69,6 +69,7 @@ public: bool isUsingMember(const AbstractMetaClass *c, const QString &memberName, Access minimumAccess) const; bool hasConstructors() const; + qsizetype indexOfProperty(const QString &name) const; uint m_hasVirtuals : 1; uint m_isPolymorphic : 1; @@ -355,6 +356,13 @@ void AbstractMetaClass::addPropertySpec(const QPropertySpec &spec) d->m_propertySpecs << spec; } +void AbstractMetaClass::setPropertyDocumentation(const QString &name, const Documentation &doc) +{ + const auto index = d->indexOfProperty(name); + if (index >= 0) + d->m_propertySpecs[index].setDocumentation(doc); +} + void AbstractMetaClassPrivate::addFunction(const AbstractMetaFunctionCPtr &function) { Q_ASSERT(!function->signature().startsWith(u'(')); @@ -672,10 +680,9 @@ AbstractMetaClass::PropertyFunctionSearchResult std::optional<QPropertySpec> AbstractMetaClass::propertySpecByName(const QString &name) const { - for (const auto &propertySpec : d->m_propertySpecs) { - if (name == propertySpec.name()) - return propertySpec; - } + const auto index = d->indexOfProperty(name); + if (index >= 0) + return d->m_propertySpecs.at(index); return {}; } @@ -760,6 +767,15 @@ bool AbstractMetaClassPrivate::hasConstructors() const FunctionQueryOption::AnyConstructor) != nullptr; } +qsizetype AbstractMetaClassPrivate::indexOfProperty(const QString &name) const +{ + for (qsizetype i = 0; i < m_propertySpecs.size(); ++i) { + if (m_propertySpecs.at(i).name() == name) + return i; + } + return -1; +} + bool AbstractMetaClass::hasConstructors() const { return d->hasConstructors(); diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang.h b/sources/shiboken6/ApiExtractor/abstractmetalang.h index 8e18d2338..526df69af 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang.h +++ b/sources/shiboken6/ApiExtractor/abstractmetalang.h @@ -262,6 +262,7 @@ public: const QList<QPropertySpec> &propertySpecs() const; void addPropertySpec(const QPropertySpec &spec); + void setPropertyDocumentation(const QString &name, const Documentation &doc); // Helpers to search whether a functions is a property setter/getter/reset enum class PropertyFunction diff --git a/sources/shiboken6/ApiExtractor/classdocumentation.cpp b/sources/shiboken6/ApiExtractor/classdocumentation.cpp index ae0750210..3d4abb87d 100644 --- a/sources/shiboken6/ApiExtractor/classdocumentation.cpp +++ b/sources/shiboken6/ApiExtractor/classdocumentation.cpp @@ -135,6 +135,7 @@ static void parseWebXmlElement(WebXmlTag tag, const QXmlStreamAttributes &attrib case WebXmlTag::Property: { PropertyDocumentation pd; pd.name = attributes.value(u"name"_s).toString(); + pd.brief = attributes.value(u"brief"_s).toString(); cd->properties.append(pd); } break; diff --git a/sources/shiboken6/ApiExtractor/classdocumentation.h b/sources/shiboken6/ApiExtractor/classdocumentation.h index 9c1acbbae..ef66912f8 100644 --- a/sources/shiboken6/ApiExtractor/classdocumentation.h +++ b/sources/shiboken6/ApiExtractor/classdocumentation.h @@ -19,6 +19,7 @@ struct EnumDocumentation struct PropertyDocumentation { QString name; + QString brief; QString description; }; diff --git a/sources/shiboken6/ApiExtractor/propertyspec.cpp b/sources/shiboken6/ApiExtractor/propertyspec.cpp index 10f9b7267..1c86cacf6 100644 --- a/sources/shiboken6/ApiExtractor/propertyspec.cpp +++ b/sources/shiboken6/ApiExtractor/propertyspec.cpp @@ -5,6 +5,7 @@ #include "abstractmetalang.h" #include "abstractmetabuilder_p.h" #include "abstractmetatype.h" +#include "documentation.h" #include "messages.h" #include "complextypeentry.h" #include "typeinfo.h" @@ -43,6 +44,7 @@ public: QString m_designable; QString m_reset; QString m_notify; + Documentation m_documentation; AbstractMetaType m_type; int m_index = -1; // Indicates whether actual code is generated instead of relying on libpyside. @@ -88,6 +90,17 @@ void QPropertySpec::setName(const QString &name) d->m_name = name; } +Documentation QPropertySpec::documentation() const +{ + return d->m_documentation; +} + +void QPropertySpec::setDocumentation(const Documentation &doc) +{ + if (d->m_documentation != doc) + d->m_documentation = doc; +} + QString QPropertySpec::read() const { return d->m_read; @@ -312,6 +325,8 @@ void QPropertySpec::formatDebug(QDebug &debug) const debug << ", reset=" << d->m_reset; if (!d->m_designable.isEmpty()) debug << ", designable=" << d->m_designable; + if (!d->m_documentation.isEmpty()) + debug << ", doc=\"" << d->m_documentation << '"'; } QDebug operator<<(QDebug d, const QPropertySpec &p) diff --git a/sources/shiboken6/ApiExtractor/propertyspec.h b/sources/shiboken6/ApiExtractor/propertyspec.h index 1ffbb1cfc..907668cb1 100644 --- a/sources/shiboken6/ApiExtractor/propertyspec.h +++ b/sources/shiboken6/ApiExtractor/propertyspec.h @@ -16,6 +16,7 @@ class AbstractMetaType; class AbstractMetaClass; class AbstractMetaBuilderPrivate; class AbstractMetaType; +class Documentation; class TypeEntry; struct TypeSystemProperty; @@ -61,6 +62,9 @@ public: QString name() const; void setName(const QString &name); + Documentation documentation() const; + void setDocumentation(const Documentation &doc); + QString read() const; void setRead(const QString &read); diff --git a/sources/shiboken6/ApiExtractor/qtdocparser.cpp b/sources/shiboken6/ApiExtractor/qtdocparser.cpp index b98226733..6d8a0eba6 100644 --- a/sources/shiboken6/ApiExtractor/qtdocparser.cpp +++ b/sources/shiboken6/ApiExtractor/qtdocparser.cpp @@ -242,12 +242,17 @@ void QtDocParser::fillDocumentation(AbstractMetaClass *metaClass) const QString sourceFileName = sourceFile.absoluteFilePath(); QString errorMessage; - ClassDocumentation classDocumentation = parseWebXml(sourceFileName, &errorMessage); + const ClassDocumentation classDocumentation = parseWebXml(sourceFileName, &errorMessage); if (!classDocumentation) { qCWarning(lcShibokenDoc, "%s", qPrintable(errorMessage)); return; } + for (const auto &p : classDocumentation.properties) { + Documentation doc(p.description, p.brief); + metaClass->setPropertyDocumentation(p.name, doc); + } + QString docString = applyDocModifications(metaClass->typeEntry()->docModifications(), classDocumentation.description); |