From 12f8258efcab39a571df4cbb8cacf5bfc2eb8a82 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 28 Oct 2020 21:17:48 +0100 Subject: qdoc: Allow type aliases as a parameter to \class command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Qt 6, some types that used to be classes are now type aliases or specializations of a templated class; for example, QPair is now an alias to std::pair. While the \typedef command supports aliases, it's not always clear where the reference of such type should live, as a \typedef cannot generate a page of its own and needs to be related to some other aggregate (class, header, or namespace). Therefore, allow aliases to generate a type page using the \class command. Fixes: QTBUG-88012 Change-Id: Ice67d58eb036299c0fd04f6ed48a846bfed8ed1d Reviewed-by: Topi Reiniƶ --- src/qdoc/cppcodeparser.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/qdoc/cppcodeparser.cpp') diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index bfc4b6e8d..d49566ba9 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -29,6 +29,7 @@ #include "cppcodeparser.h" #include "access.h" +#include "classnode.h" #include "collectionnode.h" #include "config.h" #include "examplenode.h" @@ -213,6 +214,19 @@ Node *CppCodeParser::processTopicCommand(const Doc &doc, const QString &command, node = qdb_->findNodeInOpenNamespace(path, m_nodeTypeTestFuncMap[command]); if (node == nullptr) node = qdb_->findNodeByNameAndType(path, m_nodeTypeTestFuncMap[command]); + // Allow representing a type alias as a class + if (node == nullptr && command == COMMAND_CLASS) { + node = qdb_->findNodeByNameAndType(path, &Node::isTypeAlias); + if (node) { + auto access = node->access(); + auto loc = node->location(); + auto templateDecl = node->templateDecl(); + node = new ClassNode(Node::Class, node->parent(), node->name()); + node->setAccess(access); + node->setLocation(loc); + node->setTemplateDecl(templateDecl); + } + } if (node == nullptr) { if (isWorthWarningAbout(doc)) { doc.location().warning( -- cgit v1.2.1