summaryrefslogtreecommitdiff
path: root/src/qdoc/cppcodemarker.cpp
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2020-01-15 11:08:27 +0100
committerTopi Reinio <topi.reinio@qt.io>2020-01-20 13:11:50 +0100
commit46f71fcce6d278e62ec5a766d769681400b330ed (patch)
treea5c6395ff780c1335958534b37b0b781b243d430 /src/qdoc/cppcodemarker.cpp
parent03f1c6e3ed01f8270463ab8aa4afb4f7c2321cdb (diff)
downloadqttools-46f71fcce6d278e62ec5a766d769681400b330ed.tar.gz
qdoc: Parse enum classes correctly
Clang provides us sufficient information to detect a scoped enum (an enum class). For such enums, include the enum type name into the fully qualified name of the enum values. For enums related to \headerfile nodes, drop the '<Header>::' from the qualified name of the enum values as they are not valid. Ensure that this also applies to all node types in Node::plainFullName(), as including file names into a qualified path is always incorrect. In some cases, enum classes were also forward declared. This was a problem as QDoc skipped the full declaration after seeing the forward one. Combat this by re-processing the enum declarations that do not contain any values yet. Add relevant test case. [ChangeLog][qdoc] QDoc now generates correct documentation for enum classes. Fixes: QTBUG-66740 Change-Id: I36dcb3393500acb788e0a305fd0dfecc4b58ebc3 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/cppcodemarker.cpp')
-rw-r--r--src/qdoc/cppcodemarker.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp
index 25c2f630b..38dd8e79f 100644
--- a/src/qdoc/cppcodemarker.cpp
+++ b/src/qdoc/cppcodemarker.cpp
@@ -221,7 +221,10 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, const Node * /* relati
break;
case Node::Enum:
enume = static_cast<const EnumNode *>(node);
- synopsis = "enum " + name;
+ synopsis = "enum ";
+ if (enume->isScoped())
+ synopsis += "class ";
+ synopsis += name;
if (style == Section::Summary) {
synopsis += " { ";
@@ -382,18 +385,18 @@ QString CppCodeMarker::markedUpEnumValue(const QString &enumValue, const Node *r
return enumValue;
const Node *node = relative->parent();
- QString fullName;
- while (node->parent()) {
- fullName.prepend(markedUpName(node));
+ QStringList parts;
+ while (!node->isHeader() && node->parent()) {
+ parts.prepend(markedUpName(node));
if (node->parent() == relative || node->parent()->name().isEmpty())
break;
- fullName.prepend("<@op>::</@op>");
node = node->parent();
}
- if (!fullName.isEmpty())
- fullName.append("<@op>::</@op>");
- fullName.append(enumValue);
- return fullName;
+ if (static_cast<const EnumNode *>(relative)->isScoped())
+ parts.append(relative->name());
+
+ parts.append(enumValue);
+ return parts.join(QLatin1String("<@op>::</@op>"));
}
QString CppCodeMarker::markedUpIncludes(const QStringList &includes)