From b02913d943a36d1cb1142b2fe9d94b90cc3a63a9 Mon Sep 17 00:00:00 2001 From: Martin Smith <martin.smith@qt.io> Date: Wed, 24 Jan 2018 13:01:06 +0100 Subject: [PATCH] qdoc: Make setRelates() work for SharedCommentNode When the \fn commands in a shared comment are global functions that relate to some class or namespace, the shared comment node and all the nodes sharing the comment must be marked as relating to the class or namespace. This update makes the setRelates() function virtual, and implements a special override in the SharedCommentNode to mark all the nodes in the collective as related to the class or namespace. Also added hasSharedDoc() to return true if a node is sharing a comment and the shared comment is not empty. It might be the case that it can never return false if the node is sharing a comment, but the function is convenient anyway. Change-Id: Ie064364e72fd150eacdd51a0131fe730311ee892 Reviewed-by: Martin Smith <martin.smith@qt.io> --- src/qdoc/node.cpp | 33 ++++++++++++++++++++++++++++++++- src/qdoc/node.h | 7 +++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp index 5c834abdf..9fe459690 100644 --- a/src/qdoc/node.cpp +++ b/src/qdoc/node.cpp @@ -797,6 +797,15 @@ void Node::setSharedCommentNode(SharedCommentNode* t) t->append(this); } +/*! + Returns true if this node is sharing a comment and the + shared comment is not empty. + */ +bool Node::hasSharedDoc() const +{ + return (sharedCommentNode_ && sharedCommentNode_->hasDoc()); +} + /*! \class Aggregate */ @@ -1044,7 +1053,7 @@ QStringList Aggregate::secondaryKeys() void Aggregate::makeUndocumentedChildrenInternal() { foreach (Node *child, childNodes()) { - if (child->doc().isEmpty() && child->status() != Node::Intermediate) { + if (!child->isSharingComment() && child->doc().isEmpty() && child->status() != Node::Intermediate) { child->setAccess(Node::Private); child->setStatus(Node::Internal); } @@ -3089,4 +3098,26 @@ void SharedCommentNode::setOverloadFlag(bool b) n->setOverloadFlag(b); } +/*! + Sets the pointer to the node that this node relates to + in each of the nodes in this shared comment node's collective. + */ +void SharedCommentNode::setRelates(Aggregate *pseudoParent) +{ + Node::setRelates(pseudoParent); + for (Node *n : collective_) + n->setRelates(pseudoParent); +} + +/*! + Sets the (unresolved) entity \a name that this node relates to + in each of the nodes in this shared comment node's collective. + */ +void SharedCommentNode::setRelates(const QString& name) +{ + Node::setRelates(name); + for (Node *n : collective_) + n->setRelates(name); +} + QT_END_NAMESPACE diff --git a/src/qdoc/node.h b/src/qdoc/node.h index b4e2e5823..51f4b46ee 100644 --- a/src/qdoc/node.h +++ b/src/qdoc/node.h @@ -178,8 +178,8 @@ public: } void setThreadSafeness(ThreadSafeness t) { safeness_ = (unsigned char) t; } void setSince(const QString &since); - void setRelates(Aggregate* pseudoParent); - void setRelates(const QString &name); + virtual void setRelates(Aggregate* pseudoParent); + virtual void setRelates(const QString &name); void setPhysicalModuleName(const QString &name) { physicalModuleName_ = name; } void setUrl(const QString& url) { url_ = url; } void setTemplateStuff(const QString &t) { templateStuff_ = t; } @@ -311,6 +311,7 @@ public: void clearRelated() { relatesTo_ = 0; } bool isSharingComment() const { return (sharedCommentNode_ != 0); } + bool hasSharedDoc() const; void setSharedCommentNode(SharedCommentNode* t); //QString guid() const; @@ -895,6 +896,8 @@ class SharedCommentNode : public LeafNode void append(Node* n) { collective_.append(n); } const QVector<Node*>& collective() const { return collective_; } void setOverloadFlag(bool b) override; + void setRelates(Aggregate* pseudoParent) override; + void setRelates(const QString &name) override; private: QVector<Node*> collective_; -- GitLab