diff options
| author | Martin Smith <martin.smith@nokia.com> | 2012-05-18 10:18:57 +0200 |
|---|---|---|
| committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-18 15:22:39 +0200 |
| commit | f3a0422acb6d92be26e30c604b7092a8bfd52b7b (patch) | |
| tree | fae13391d7a85f08765f979ec4b4e1cf0aa63ca9 /src/tools/qdoc/cppcodeparser.cpp | |
| parent | 1c7421ad14f9321422cdfeede3902552a34ccf3b (diff) | |
qdoc: Report multiple QML property docss
Documentation authors sometimes make the mistake of
documenting a QML property more than once. Here, we
refer to cases where a C++ class is documented in a
.cpp file as a QML type. In this context one QML
property might be documented in two qdoc comments,
because the author of the second comment does not
search the file for an existing qdoc comment for
the property before adding the second one. When DITA
XML is generated for this case, the QML type element
will contain two <qmlproperty> elements with identical
id attributes, which is invalid XML. id attributes
must be unique within an XML document.
qdoc now reports an error for this case, indicating
that the QMLN property has been documented multiple
times.
This problem can't occur when documenting QML in a
.qml file because in .qml files, each comment must
appear directly above the thing it applies to.
Change-Id: I3a22650a58371fbda2ac7a5429fc036f41750423
Reviewed-by: Martin Smith <martin.smith@nokia.com>
Diffstat (limited to 'src/tools/qdoc/cppcodeparser.cpp')
| -rw-r--r-- | src/tools/qdoc/cppcodeparser.cpp | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp index d25f5e05e88..b5dcae271cd 100644 --- a/src/tools/qdoc/cppcodeparser.cpp +++ b/src/tools/qdoc/cppcodeparser.cpp @@ -960,43 +960,54 @@ Node *CppCodeParser::processTopicCommandGroup(const QString& command, const ArgL QString module; QString element; QString property; + QmlClassNode* qmlClass = 0; bool attached = (command == COMMAND_QMLATTACHEDPROPERTY); ArgList::ConstIterator argsIter = args.begin(); arg = argsIter->first; if (splitQmlPropertyArg(arg,type,module,element,property)) { - QmlClassNode* qmlClass = tree_->findQmlClassNode(module,element); + qmlClass = tree_->findQmlClassNode(module,element); if (qmlClass) { qmlPropGroup = new QmlPropGroupNode(qmlClass,property); //,attached); qmlPropGroup->setLocation(location()); } } if (qmlPropGroup) { - ClassNode *correspondingClass = static_cast<QmlClassNode*>(qmlPropGroup->parent())->classNode(); - QmlPropertyNode *qmlPropNode = new QmlPropertyNode(qmlPropGroup,property,type,attached); - qmlPropNode->setLocation(location()); - qmlPropNode->setQPropertyFlag(); - const PropertyNode *correspondingProperty = 0; - if (correspondingClass) { - correspondingProperty = qmlPropNode->correspondingProperty(tree_); + if (qmlClass->hasProperty(property)) { + location().warning(tr("QML property documented multiple times: '%1'").arg(arg)); } - if (correspondingProperty) { - bool writableList = type.startsWith("list") && correspondingProperty->dataType().endsWith('*'); - qmlPropNode->setReadOnly(!(writableList || correspondingProperty->isWritable())); + else { + ClassNode *correspondingClass = static_cast<QmlClassNode*>(qmlPropGroup->parent())->classNode(); + QmlPropertyNode *qmlPropNode = new QmlPropertyNode(qmlPropGroup,property,type,attached); + qmlPropNode->setLocation(location()); + qmlPropNode->setQPropertyFlag(); + + if (correspondingClass) { + correspondingProperty = qmlPropNode->correspondingProperty(tree_); + } + if (correspondingProperty) { + bool writableList = type.startsWith("list") && correspondingProperty->dataType().endsWith('*'); + qmlPropNode->setReadOnly(!(writableList || correspondingProperty->isWritable())); + } } ++argsIter; while (argsIter != args.end()) { arg = argsIter->first; if (splitQmlPropertyArg(arg,type,module,element,property)) { - QmlPropertyNode* qmlPropNode = new QmlPropertyNode(qmlPropGroup, - property, - type, - attached); - qmlPropNode->setLocation(location()); - qmlPropNode->setQPropertyFlag(); - if (correspondingProperty) { - bool writableList = type.startsWith("list") && correspondingProperty->dataType().endsWith('*'); - qmlPropNode->setReadOnly(!(writableList || correspondingProperty->isWritable())); + if (qmlClass->hasProperty(property)) { + location().warning(tr("QML property documented multiple times: '%1'").arg(arg)); + } + else { + QmlPropertyNode* qmlPropNode = new QmlPropertyNode(qmlPropGroup, + property, + type, + attached); + qmlPropNode->setLocation(location()); + qmlPropNode->setQPropertyFlag(); + if (correspondingProperty) { + bool writableList = type.startsWith("list") && correspondingProperty->dataType().endsWith('*'); + qmlPropNode->setReadOnly(!(writableList || correspondingProperty->isWritable())); + } } } ++argsIter; |
