diff options
author | Topi Reinio <topi.reinio@qt.io> | 2020-04-21 23:57:46 +0200 |
---|---|---|
committer | Topi Reinio <topi.reinio@qt.io> | 2020-04-23 10:19:54 +0200 |
commit | e967772fe884dd8a488a359c122c9cbae9d94c55 (patch) | |
tree | 570c6bb5f46ef5409f4508a746dbde4542f7d7a9 /src/qdoc/clangcodeparser.cpp | |
parent | 95cd9078938bcd88fdfbba707911e8111f59f195 (diff) |
qdoc: properly implement \typealias command
\typealias was already a command recognized by QDoc, but it was simply
treated as a synonym for \typedef and was not documented. Implement
proper support for the command:
- Add [alias] designation both in type summary and details.
- Auto-generate information about the aliased type, including a link
if aliasing a public, documented type.
- Auto-convert aliases documented with \typedef to type aliases.
- Add basic support for aliases also to DocBook and WebXML generators.
- Document \typealias.
Fixes: QTBUG-82712
Change-Id: Iafa8c7def0a7488d7521fbc2862290a9bb3167ff
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qdoc/clangcodeparser.cpp')
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index b5c6a8ac6..0a0b7e7ac 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -632,18 +632,14 @@ CXChildVisitResult ClangVisitor::visitHeader(CXCursor cursor, CXSourceLocation l QString templateString; switch (kind) { case CXCursor_TypeAliasDecl: { - QString spelling = getSpelling(clang_getCursorExtent(cursor)); - QStringList typeAlias = spelling.split(QChar('=')); + QString aliasDecl = getSpelling(clang_getCursorExtent(cursor)).simplified(); + QStringList typeAlias = aliasDecl.split(QLatin1Char('=')); if (typeAlias.size() == 2) { - typeAlias[0] = typeAlias[0].trimmed(); + typeAlias[0] = typeAlias[0].trimmed().split(QLatin1Char(' ')).last(); typeAlias[1] = typeAlias[1].trimmed(); - int lastBlank = typeAlias[0].lastIndexOf(QChar(' ')); - if (lastBlank > 0) { - typeAlias[0] = typeAlias[0].right(typeAlias[0].size() - (lastBlank + 1)); - TypeAliasNode *ta = new TypeAliasNode(parent_, typeAlias[0], typeAlias[1]); - ta->setAccess(fromCX_CXXAccessSpecifier(clang_getCXXAccessSpecifier(cursor))); - ta->setLocation(fromCXSourceLocation(clang_getCursorLocation(cursor))); - } + TypeAliasNode *ta = new TypeAliasNode(parent_, typeAlias[0], typeAlias[1]); + ta->setAccess(fromCX_CXXAccessSpecifier(clang_getCXXAccessSpecifier(cursor))); + ta->setLocation(fromCXSourceLocation(clang_getCursorLocation(cursor))); } return CXChildVisit_Continue; } |