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/generator.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/generator.cpp')
-rw-r--r-- | src/qdoc/generator.cpp | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/src/qdoc/generator.cpp b/src/qdoc/generator.cpp index bdeeec2be..b3aacb623 100644 --- a/src/qdoc/generator.cpp +++ b/src/qdoc/generator.cpp @@ -644,6 +644,9 @@ QString Generator::fullDocumentLocation(const Node *node, bool useSubdir) case Node::Enum: anchorRef = QLatin1Char('#') + node->name() + "-enum"; break; + case Node::TypeAlias: + anchorRef = QLatin1Char('#') + node->name() + "-alias"; + break; case Node::Typedef: { const TypedefNode *tdef = static_cast<const TypedefNode *>(node); if (tdef->associatedEnum()) { @@ -818,10 +821,11 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) tr("No documentation for '%1'").arg(node->plainSignature())); } } else if (!node->isSharingComment()) { - if (fn) { - if (!fn->overridesThis().isEmpty()) - generateReimplementsClause(fn, marker); - } + // Reimplements clause and type alias info precede body text + if (fn && !fn->overridesThis().isEmpty()) + generateReimplementsClause(fn, marker); + else if (node->isTypeAlias()) + generateAddendum(node, TypeAlias, marker, false); if (!generateText(node->doc().body(), node, marker)) { if (node->isMarkedReimp()) @@ -1357,12 +1361,17 @@ void Generator::generateStatus(const Node *node, CodeMarker *marker) Generates an addendum note of type \a type for \a node, using \a marker as the code marker. */ -void Generator::generateAddendum(const Node *node, Addendum type, CodeMarker *marker) +void Generator::generateAddendum(const Node *node, Addendum type, CodeMarker *marker, + bool generateNote) { Q_ASSERT(node && !node->name().isEmpty()); Text text; - text << Atom::ParaLeft << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD) - << "Note: " << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD); + text << Atom::ParaLeft; + + if (generateNote) { + text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD) + << "Note: " << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD); + } switch (type) { case Invokable: @@ -1419,6 +1428,22 @@ void Generator::generateAddendum(const Node *node, Addendum type, CodeMarker *ma } break; } + case TypeAlias: + { + if (!node->isTypeAlias()) + return; + const auto *ta = static_cast<const TypeAliasNode *>(node); + text << "This is a type alias for "; + if (ta->aliasedNode() && ta->aliasedNode()->isInAPI()) { + text << Atom(Atom::LinkNode, CodeMarker::stringForNode(ta->aliasedNode())) + << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK) + << Atom(Atom::String, ta->aliasedNode()->plainFullName(ta->parent())) + << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK) << "."; + } else { + text << Atom(Atom::String, ta->aliasedType()) << "."; + } + break; + } default: return; } @@ -2195,6 +2220,8 @@ QString Generator::typeString(const Node *node) return "enum"; case Node::Typedef: return "typedef"; + case Node::TypeAlias: + return "alias"; case Node::Function: { const auto fn = static_cast<const FunctionNode *>(node); switch (fn->metaness()) { |