From b2fe71d1ee5c9b9c31c808dbdec42592a3ac9c55 Mon Sep 17 00:00:00 2001 From: Martin Smith <martin.smith@qt.io> Date: Wed, 24 Jan 2018 13:07:04 +0100 Subject: [PATCH] qdoc: Fix handling of shared comment nodes in generate phase Shared comments nodes were not detected and handled correctly in certain cases. This update fixes those problems to avoid trying to output documentation for the individual nodes, when they are sharing a comment. Only the shared comment node should cause documentation to be generated for the nodes sharing the comment. Change-Id: I4ad7afc0964b1b6836dd5a140aa874784974b139 Reviewed-by: Martin Smith <martin.smith@qt.io> --- src/qdoc/cppcodemarker.cpp | 8 +++++--- src/qdoc/generator.cpp | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp index cdaecebd9..5bd64ca87 100644 --- a/src/qdoc/cppcodemarker.cpp +++ b/src/qdoc/cppcodemarker.cpp @@ -678,7 +678,7 @@ QList<Section> CppCodeMarker::sections(const Aggregate *inner, FunctionNode *func = static_cast<FunctionNode *>(*r); if (func->isMacro()) insert(macros, *r, style, status); - else + else if (!func->isSharingComment()) insert(relatedNonMembers, *r, style, status); } else { @@ -700,8 +700,10 @@ QList<Section> CppCodeMarker::sections(const Aggregate *inner, insert(memberVariables, *c, style, status); } else if ((*c)->isFunction()) { FunctionNode *function = static_cast<FunctionNode *>(*c); - if (!function->hasAssociatedProperties() || !function->doc().isEmpty()) - insert(memberFunctions, function, style, status); + if (!function->isSharingComment()) { + if (!function->hasAssociatedProperties() || !function->doc().isEmpty()) + insert(memberFunctions, function, style, status); + } } else if ((*c)->isSharedCommentNode()) { SharedCommentNode *scn = static_cast<SharedCommentNode *>(*c); if (!scn->doc().isEmpty()) diff --git a/src/qdoc/generator.cpp b/src/qdoc/generator.cpp index 24dff3ed6..8d088b13f 100644 --- a/src/qdoc/generator.cpp +++ b/src/qdoc/generator.cpp @@ -781,7 +781,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) quiet = true; } } - if (node->doc().isEmpty()) { + if (!node->hasDoc() && !node->hasSharedDoc()) { /* Test for special function, like a destructor or copy constructor, that has no documentation. @@ -863,7 +863,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) node->location().warning(tr("No documentation for '%1'").arg(node->plainSignature())); } } - else { + else if (!node->isSharingComment()) { if (node->type() == Node::Function) { const FunctionNode *func = static_cast<const FunctionNode *>(node); if (func->reimplementedFrom() != 0) -- GitLab