summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2014-08-11 11:58:44 +0200
committerShawn Rutledge <shawn.rutledge@digia.com>2014-08-12 07:27:45 +0200
commit338f9c4f7c42d2a7bcd2c5b37137b3cc7cd9775d (patch)
tree7ca8647ebf9495509ffa6776ad0de79ab60eb54c /src
parent34198cedbed52d5eb1aa4612b0a162c8a8a9b63a (diff)
qdoc: Distinguish between QML property and attached property
A recent change in qtdeclarative (60ed6a43) added an attached property 'Window' to Item type, with property names identical to the ones already available in Window. This caused QDoc to report warnings for duplicate documentation for QML properties, because there was no distiction between a QML property and an attached property. This change fixes the issue by: - Allowing identical names for \qmlproperty and \qmlattachedproperty - Using distinct URLs/UUIDs/anchor references for them - Marking attached properties with '[attached]' qualifier in 'All Members' page. This doesn't solve the issue of disambiguating between a similarly named QML property and attached property when linking from an external location. However, these can be solved with the help of the \target command. Task-number: QTBUG-40674 Change-Id: Icc74de237366e9897334689fe354ab83e4af0356 Reviewed-by: Martin Smith <martin.smith@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/tools/qdoc/cppcodeparser.cpp2
-rw-r--r--src/tools/qdoc/generator.cpp5
-rw-r--r--src/tools/qdoc/htmlgenerator.cpp9
-rw-r--r--src/tools/qdoc/node.cpp26
-rw-r--r--src/tools/qdoc/node.h2
-rw-r--r--src/tools/qdoc/qmlvisitor.cpp2
6 files changed, 41 insertions, 5 deletions
diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp
index 2755bf7254..df11ee5b24 100644
--- a/src/tools/qdoc/cppcodeparser.cpp
+++ b/src/tools/qdoc/cppcodeparser.cpp
@@ -832,7 +832,7 @@ void CppCodeParser::processQmlProperties(const Doc& doc, NodeList& nodes, DocLis
if (splitQmlPropertyArg(arg, type, module, qmlType, property)) {
qmlClass = qdb_->findQmlType(module, qmlType);
if (qmlClass) {
- if (qmlClass->hasQmlProperty(property) != 0) {
+ if (qmlClass->hasQmlProperty(property, attached) != 0) {
QString msg = tr("QML property documented multiple times: '%1'").arg(arg);
doc.startLocation().warning(msg);
}
diff --git a/src/tools/qdoc/generator.cpp b/src/tools/qdoc/generator.cpp
index 6bba83efdb..6fdc2a916c 100644
--- a/src/tools/qdoc/generator.cpp
+++ b/src/tools/qdoc/generator.cpp
@@ -545,7 +545,10 @@ QString Generator::fullDocumentLocation(const Node *node, bool useSubdir)
anchorRef = QLatin1Char('#') + node->name() + "-prop";
break;
case Node::QmlProperty:
- anchorRef = QLatin1Char('#') + node->name() + "-prop";
+ if (node->isAttached())
+ anchorRef = QLatin1Char('#') + node->name() + "-attached-prop";
+ else
+ anchorRef = QLatin1Char('#') + node->name() + "-prop";
break;
case Node::QmlSignal:
anchorRef = QLatin1Char('#') + node->name() + "-signal";
diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp
index ffaa014d60..51e61117c4 100644
--- a/src/tools/qdoc/htmlgenerator.cpp
+++ b/src/tools/qdoc/htmlgenerator.cpp
@@ -2477,6 +2477,8 @@ QString HtmlGenerator::generateAllQmlMembersFile(QmlClassNode* qml_cn, CodeMarke
prefix = prefix.left(keys.at(j).indexOf("::")+1);
}
generateQmlItem(nodes[j], qcn, marker, true);
+ if (nodes[j]->isAttached())
+ out() << " [attached]";
//generateSynopsis(nodes[j], qcn, marker, CodeMarker::Subpage, false, &prefix);
out() << "</li>\n";
}
@@ -3627,8 +3629,13 @@ QString HtmlGenerator::refForNode(const Node *node)
break;
case Node::Document:
break;
- case Node::QmlPropertyGroup:
case Node::QmlProperty:
+ if (node->isAttached())
+ ref = node->name() + "-attached-prop";
+ else
+ ref = node->name() + "-prop";
+ break;
+ case Node::QmlPropertyGroup:
case Node::Property:
ref = node->name() + "-prop";
break;
diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp
index 03b798cbb3..f16c35c3a9 100644
--- a/src/tools/qdoc/node.cpp
+++ b/src/tools/qdoc/node.cpp
@@ -1339,6 +1339,27 @@ QmlPropertyNode* InnerNode::hasQmlProperty(const QString& n) const
}
/*!
+ If this node has a child that is a QML property named \a n
+ whose type (attached or normal property) matches \a attached,
+ return the pointer to that child.
+ */
+QmlPropertyNode* InnerNode::hasQmlProperty(const QString& n, bool attached) const
+{
+ foreach (Node* child, childNodes()) {
+ if (child->type() == Node::QmlProperty) {
+ if (child->name() == n && child->isAttached() == attached)
+ return static_cast<QmlPropertyNode*>(child);
+ }
+ else if (child->isQmlPropertyGroup()) {
+ QmlPropertyNode* t = child->hasQmlProperty(n, attached);
+ if (t)
+ return t;
+ }
+ }
+ return 0;
+}
+
+/*!
\class LeafNode
*/
@@ -2797,7 +2818,10 @@ QString Node::idForNode() const
str = "qml-module-" + name();
break;
case Node::QmlProperty:
- str = "qml-property-" + name();
+ if (isAttached())
+ str = "qml-attached-property-" + name();
+ else
+ str = "qml-property-" + name();
break;
case Node::QmlPropertyGroup:
{
diff --git a/src/tools/qdoc/node.h b/src/tools/qdoc/node.h
index 4f9097d774..37fbe482b0 100644
--- a/src/tools/qdoc/node.h
+++ b/src/tools/qdoc/node.h
@@ -239,6 +239,7 @@ public:
virtual void setTitle(const QString& ) { }
virtual void setSubTitle(const QString& ) { }
virtual QmlPropertyNode* hasQmlProperty(const QString& ) const { return 0; }
+ virtual QmlPropertyNode* hasQmlProperty(const QString&, bool ) const { return 0; }
virtual void getMemberNamespaces(NodeMap& ) { }
virtual void getMemberClasses(NodeMap& ) { }
virtual bool isInternal() const;
@@ -391,6 +392,7 @@ public:
virtual void setOutputFileName(const QString& f) { outputFileName_ = f; }
virtual QString outputFileName() const { return outputFileName_; }
virtual QmlPropertyNode* hasQmlProperty(const QString& ) const;
+ virtual QmlPropertyNode* hasQmlProperty(const QString&, bool attached) const;
void addChild(Node* child, const QString& title);
const QStringList& groupNames() const { return groupNames_; }
virtual void appendGroupName(const QString& t) { groupNames_.append(t); }
diff --git a/src/tools/qdoc/qmlvisitor.cpp b/src/tools/qdoc/qmlvisitor.cpp
index 2ef751e9bc..fbe4940c19 100644
--- a/src/tools/qdoc/qmlvisitor.cpp
+++ b/src/tools/qdoc/qmlvisitor.cpp
@@ -266,7 +266,7 @@ bool QmlDocVisitor::applyDocumentation(QQmlJS::AST::SourceLocation location, Nod
}
else {
bool isAttached = (topic == COMMAND_QMLATTACHEDPROPERTY);
- QmlPropertyNode* n = parent->hasQmlProperty(qpa.name_);
+ QmlPropertyNode* n = parent->hasQmlProperty(qpa.name_, isAttached);
if (n == 0)
n = new QmlPropertyNode(parent, qpa.name_, qpa.type_, isAttached);
n->setLocation(doc.location());