diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-11-22 13:35:35 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-11-24 14:04:17 +0000 |
commit | b2c75887ff6fcd2fb6579d0e29ffa081fa45b52b (patch) | |
tree | 1b07fcb4a7ff109ab82daa49ce2a59f364d40ff5 | |
parent | a4329741e960bc9f9efc690ba849c55b32496191 (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
Change-Id: Ide236b5918c135e331149ca384ed973fd794b55f
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 56f3ecf68c67c45b42caa7940218d6be42156539)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_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 cf93e5b03..13088f2ab 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp @@ -74,6 +74,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; @@ -360,6 +361,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'(')); @@ -677,10 +685,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 {}; } @@ -765,6 +772,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 025ce6a8b..d95da0f4b 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 8860269a4..57a530add 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 d1de93afd..72b7e8ebf 100644 --- a/sources/shiboken6/ApiExtractor/propertyspec.h +++ b/sources/shiboken6/ApiExtractor/propertyspec.h @@ -14,6 +14,7 @@ class AbstractMetaType; class AbstractMetaClass; class AbstractMetaBuilderPrivate; class AbstractMetaType; +class Documentation; class TypeEntry; struct TypeSystemProperty; @@ -59,6 +60,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 58486a5c9..cb0ddb0f9 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); |