diff options
author | Martin Smith <martin.smith@qt.io> | 2018-02-22 10:26:36 +0100 |
---|---|---|
committer | Martin Smith <martin.smith@qt.io> | 2018-02-23 11:44:05 +0000 |
commit | 9dfdfdf5744d3bf0ffea3c380ed37f0ab9273fe5 (patch) | |
tree | f166f5b5bc01bc8bb8943cf1e078cb5140d97253 | |
parent | a40749199be276aa89fcb4c171c4943a581d91de (diff) |
qdoc: Generate correct links to QML propertiesv5.11.0-beta1
When a QML type is marked \qmlabstract, the documentation for
its properties is included on the reference page for each QML
type that inherits the abstract QML type. This means that when
using the link command to link to one of these properties in
HTML, qdoc must first obtain the correct file name. It was not
getting the correct file name, when the link command appeared
in documentation for a QML type that didn't inherit the QML
type marked abstract. This update corrects that bug.
Change-Id: I91ccb34e43618b7bbc1909026cbdf0c1b719df87
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r-- | src/qdoc/htmlgenerator.cpp | 11 | ||||
-rw-r--r-- | src/qdoc/node.cpp | 14 | ||||
-rw-r--r-- | src/qdoc/node.h | 1 |
3 files changed, 24 insertions, 2 deletions
diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index 137da05ff..60ed94981 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -3943,8 +3943,15 @@ QString HtmlGenerator::linkForNode(const Node *node, const Node *relative) if (node && node->parent() && (node->parent()->isQmlType() || node->parent()->isJsType()) && node->parent()->isAbstract()) { - if (Generator::qmlTypeContext()) - fn = fileName(Generator::qmlTypeContext()); + if (Generator::qmlTypeContext()) { + if (Generator::qmlTypeContext()->inherits(node->parent())) { + fn = fileName(Generator::qmlTypeContext()); + } + else if (node->parent()->isInternal()) { + node->doc().location().warning(tr("Cannot link to property in internal type '%1'").arg(node->parent()->name())); + return QString(); + } + } } QString link = fn; diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp index e2ed08032..7e3b2d96a 100644 --- a/src/qdoc/node.cpp +++ b/src/qdoc/node.cpp @@ -2669,6 +2669,20 @@ QString QmlTypeNode::logicalModuleIdentifier() const } /*! + Returns true if this QML type inherits \a type. + */ +bool QmlTypeNode::inherits(Aggregate* type) +{ + QmlTypeNode* qtn = qmlBaseNode(); + while (qtn != 0) { + if (qtn == type) + return true; + qtn = qtn->qmlBaseNode(); + } + return false; +} + +/*! Constructs a Qml basic type node. The new node has the given \a parent and \a name. */ diff --git a/src/qdoc/node.h b/src/qdoc/node.h index faea2dcb1..38fc99f03 100644 --- a/src/qdoc/node.h +++ b/src/qdoc/node.h @@ -677,6 +677,7 @@ public: static void addInheritedBy(const Node *base, Node* sub); static void subclasses(const Node *base, NodeList& subs); static void terminate(); + bool inherits(Aggregate* type); public: static bool qmlOnly; |