summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2025-09-12 08:02:16 +0200
committerPaul Wicking <paul.wicking@qt.io>2025-09-12 12:00:39 +0200
commit9557442d18b78c8adf52d37393a7901b94e45d7c (patch)
tree54aca8753eaadeb6326328f517ca8eaa1dcaa54a
parente601393136094f7dd8cc2a4851101f96ccec0bbc (diff)
QDoc: Extend NodeContext to include 'internal' state
This change makes NodeContext properly track a Node's 'internal' status, and exercises this in the unit tests for the POD. This lays the foundation for future extension of the inclusion policy system that will make it also cover `showinternal` functionality. Task-number: QTBUG-139658 Change-Id: Ieead3a396f255db331797fedf76c16eaa8d0081f Reviewed-by: Topi ReiniΓΆ <topi.reinio@qt.io>
-rw-r--r--src/qdoc/qdoc/src/qdoc/node.cpp1
-rw-r--r--src/qdoc/qdoc/src/qdoc/nodecontext.h1
-rw-r--r--src/qdoc/qdoc/tests/qdoc/inclusion/catch_inclusionstrategytests.cpp82
3 files changed, 84 insertions, 0 deletions
diff --git a/src/qdoc/qdoc/src/qdoc/node.cpp b/src/qdoc/qdoc/src/qdoc/node.cpp
index c399b3c3c..10db16c4b 100644
--- a/src/qdoc/qdoc/src/qdoc/node.cpp
+++ b/src/qdoc/qdoc/src/qdoc/node.cpp
@@ -117,6 +117,7 @@ NodeContext Node::createContext() const
NodeContext context;
context.type = nodeType();
context.isPrivate = isPrivate();
+ context.isInternal = isInternal();
context.isPureVirtual = isPureVirtual();
return context;
diff --git a/src/qdoc/qdoc/src/qdoc/nodecontext.h b/src/qdoc/qdoc/src/qdoc/nodecontext.h
index 22dfafa54..ed14cc81d 100644
--- a/src/qdoc/qdoc/src/qdoc/nodecontext.h
+++ b/src/qdoc/qdoc/src/qdoc/nodecontext.h
@@ -15,6 +15,7 @@ struct NodeContext
{
NodeType type {NodeType::NoType};
bool isPrivate {false};
+ bool isInternal {false};
bool isPureVirtual {false};
InclusionFlags toFlags() const {
diff --git a/src/qdoc/qdoc/tests/qdoc/inclusion/catch_inclusionstrategytests.cpp b/src/qdoc/qdoc/tests/qdoc/inclusion/catch_inclusionstrategytests.cpp
index e2e86a1d4..4f666539e 100644
--- a/src/qdoc/qdoc/tests/qdoc/inclusion/catch_inclusionstrategytests.cpp
+++ b/src/qdoc/qdoc/tests/qdoc/inclusion/catch_inclusionstrategytests.cpp
@@ -8,8 +8,86 @@
#include <qdoc/nodecontext.h>
#include <qdoc/inclusionfilter.h>
+TEST_CASE("NodeContext correctly captures internal status", "[NodeContext]")
+{
+ SECTION("Default NodeContext has isInternal false")
+ {
+ NodeContext context;
+ REQUIRE(context.isInternal == false);
+ }
+
+ SECTION("NodeContext can be set to internal")
+ {
+ NodeContext context;
+ context.isInternal = true;
+ REQUIRE(context.isInternal == true);
+ }
+
+ SECTION("NodeContext preserves all fields when internal is set")
+ {
+ NodeContext context;
+ context.type = NodeType::Class;
+ context.isPrivate = true;
+ context.isInternal = true;
+ context.isPureVirtual = false;
+
+ REQUIRE(context.type == NodeType::Class);
+ REQUIRE(context.isPrivate == true);
+ REQUIRE(context.isInternal == true);
+ REQUIRE(context.isPureVirtual == false);
+ }
+
+ SECTION("NodeContext with private but not internal")
+ {
+ NodeContext context;
+ context.type = NodeType::Function;
+ context.isPrivate = true;
+ context.isInternal = false;
+
+ REQUIRE(context.isPrivate == true);
+ REQUIRE(context.isInternal == false);
+ }
+
+ SECTION("NodeContext with internal but not private")
+ {
+ NodeContext context;
+ context.type = NodeType::Function;
+ context.isPrivate = false;
+ context.isInternal = true;
+
+ REQUIRE(context.isPrivate == false);
+ REQUIRE(context.isInternal == true);
+ }
+
+ SECTION("NodeContext with both private and internal")
+ {
+ NodeContext context;
+ context.type = NodeType::Class;
+ context.isPrivate = true;
+ context.isInternal = true;
+
+ REQUIRE(context.isPrivate == true);
+ REQUIRE(context.isInternal == true);
+ }
+}
+
TEST_CASE("NodeContext toFlags() behavior", "[NodeContext]")
{
+ SECTION("Non-private node returns empty flags regardless of internal status")
+ {
+ NodeContext context;
+ context.type = NodeType::Function;
+ context.isPrivate = false;
+ context.isInternal = false;
+
+ auto flags = context.toFlags();
+ REQUIRE(flags == InclusionFlags{});
+
+ context.isInternal = true;
+ flags = context.toFlags();
+ REQUIRE(flags == InclusionFlags{});
+ }
+
SECTION("Private function node returns correct flags")
{
NodeContext context;
@@ -76,6 +154,7 @@ TEST_CASE("InclusionFilter basic functionality", "[InclusionFilter]")
{
NodeContext context;
context.isPrivate = false;
+ context.isInternal = false;
InclusionPolicy policy;
@@ -86,6 +165,7 @@ TEST_CASE("InclusionFilter basic functionality", "[InclusionFilter]")
{
NodeContext context;
context.isPrivate = true;
+ context.isInternal = false;
InclusionPolicy policy;
policy.includePrivate = false;
@@ -98,6 +178,7 @@ TEST_CASE("InclusionFilter basic functionality", "[InclusionFilter]")
NodeContext context;
context.type = NodeType::Function;
context.isPrivate = true;
+ context.isInternal = false;
InclusionPolicy policy;
policy.includePrivate = true;
@@ -112,6 +193,7 @@ TEST_CASE("InclusionFilter basic functionality", "[InclusionFilter]")
context.type = NodeType::Function;
context.isPrivate = true;
context.isPureVirtual = true;
+ context.isInternal = false;
InclusionPolicy policy;
policy.includePrivate = false;