diff options
author | Topi Reinio <topi.reinio@qt.io> | 2020-10-28 21:17:48 +0100 |
---|---|---|
committer | Topi Reinio <topi.reinio@qt.io> | 2020-11-09 23:02:24 +0100 |
commit | 12f8258efcab39a571df4cbb8cacf5bfc2eb8a82 (patch) | |
tree | 70d07f8f1f411d22a791e7f0204bd3c0effbdf6d /src/qdoc/cppcodeparser.cpp | |
parent | 071b4615e264cf097414095828e6b8bea742c065 (diff) | |
download | qttools-12f8258efcab39a571df4cbb8cacf5bfc2eb8a82.tar.gz |
qdoc: Allow type aliases as a parameter to \class command
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ƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/cppcodeparser.cpp')
-rw-r--r-- | src/qdoc/cppcodeparser.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
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( |