diff options
author | Luca Di Sera <luca.disera@qt.io> | 2022-09-06 13:50:35 +0200 |
---|---|---|
committer | Luca Di Sera <luca.disera@qt.io> | 2022-09-07 12:32:23 +0200 |
commit | a285decaf612f75229d8429891be1beef165994b (patch) | |
tree | d0cb5d9fffa4981ffcce112b52709039217fec7f /src/qdoc/qmlvisitor.cpp | |
parent | 157cb7cbcb5a8d148b25e43066b80edd71a1d1b9 (diff) | |
download | qttools-a285decaf612f75229d8429891be1beef165994b.tar.gz |
QDoc: Remove unfinished support for documenting javascript
The codebase for QDoc has support for commands related to documenting
pure javascript codebases.
Generally, given a certain QML specific command, a javascript equivalent
is provided.
For example, "\jstype" or "\jsmodule".
Codewise, the support is bolted on by reusing the exact same code that
is used for QML types. The internal structures used to represent QML
elements, like `QmlPropertyNode`, were reused for javascript elements,
with the sole difference of changing the metaness value, for elements
where the metaness is meaningful, and the internal type tag of the node.
Code that branched specifically with QML types was modified to branch
for javascript types too, with mostly no other difference in the
branched code itself.
The support for javascript was never finalized, albeit it is supposed to
work, lacking, for example, representation in the documentation.
As a consequence of this it is not currently used, tested or necessary.
Hence, the code supporting the documentation of javascript elements is
now removed as dead code.
Anything referring to javascript specific elements were removed, from
the commands definitions to the categorization functions.
"Node::changeType" and "FunctionNode::changeMetaness", that switched the
type and metaness, respectively, of an existing node with a new one,
albeit implemented in a more general fashion, are now removed as dead
code, since they were used specifically to "convert" Qml nodes to
"javascript nodes".
References to javascript were removed in the documentation for QDoc.
Do note that not all javascript related features were removed from the
codebase.
In particular, the "js" and "endjs" commands, to mark a codeblock as
being javascript code, and their supporting code such as `JsCodeMarker`,
were currently retained as, albeit no documentation exists, are
currently used a couple of time in the current Qt's codebase.
The remaining javascript specific code is expected to be addressed and
removed in a future commit, unless the current usages are specific
enough that they cannot be replaced with qml specific commands.
Task-number: QTBUG-106275
Change-Id: I6a199ce97b26d6a3a645c0022e599a8654989a85
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/qmlvisitor.cpp')
-rw-r--r-- | src/qdoc/qmlvisitor.cpp | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/qdoc/qmlvisitor.cpp b/src/qdoc/qmlvisitor.cpp index 28e125a4e..bf0cefadc 100644 --- a/src/qdoc/qmlvisitor.cpp +++ b/src/qdoc/qmlvisitor.cpp @@ -124,13 +124,10 @@ bool QmlDocVisitor::applyDocumentation(QQmlJS::SourceLocation location, Node *no if (!topicsUsed.empty()) { for (int i = 0; i < topicsUsed.size(); ++i) { QString topic = topicsUsed.at(i).m_topic; - if (!topic.startsWith(QLatin1String("qml")) - && !topic.startsWith(QLatin1String("js"))) + if (!topic.startsWith(QLatin1String("qml"))) continue; // maybe a qdoc warning here? mws 18/07/18 QString args = topicsUsed.at(i).m_args; - if (topic == COMMAND_JSTYPE) { - node->changeType(Node::QmlType, Node::JsType); - } else if (topic.endsWith(QLatin1String("property"))) { + if (topic.endsWith(QLatin1String("property"))) { QmlPropArgs qpa; if (splitQmlPropertyArg(doc, args, qpa)) { if (qpa.m_name == nodePassedIn->name()) { @@ -148,19 +145,14 @@ bool QmlDocVisitor::applyDocumentation(QQmlJS::SourceLocation location, Node *no n->markDefault(); if (isAttached) n->markReadOnly(0); - if ((topic == COMMAND_JSPROPERTY) - || (topic == COMMAND_JSATTACHEDPROPERTY)) - n->changeType(Node::QmlProperty, Node::JsProperty); nodes.append(n); } } else - qDebug() << " FAILED TO PARSE QML OR JS PROPERTY:" << topic << args; + qDebug() << " FAILED TO PARSE QML PROPERTY:" << topic << args; } else if (topic.endsWith(QLatin1String("method")) || topic == COMMAND_QMLSIGNAL) { if (node->isFunction()) { auto *fn = static_cast<FunctionNode *>(node); QmlSignatureParser qsp(fn, args, doc.location()); - if (topic == COMMAND_JSMETHOD || topic == COMMAND_JSATTACHEDMETHOD) - fn->changeMetaness(FunctionNode::QmlMethod, FunctionNode::JsMethod); } } } @@ -394,20 +386,20 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::SourceLocation, Node *node, Doc &d for (const auto &command : qAsConst(metacommands)) { const ArgList args = doc.metaCommandArgs(command); if ((command == COMMAND_QMLABSTRACT) || (command == COMMAND_ABSTRACT)) { - if (node->isQmlType() || node->isJsType()) { + if (node->isQmlType()) { node->setAbstract(true); } } else if (command == COMMAND_DEPRECATED) { node->setStatus(Node::Deprecated); if (!args[0].second.isEmpty()) node->setDeprecatedSince(args[0].second); - } else if ((command == COMMAND_INQMLMODULE) || (command == COMMAND_INJSMODULE)) { + } else if (command == COMMAND_INQMLMODULE) { qdb->addToQmlModule(args[0].first, node); } else if (command == COMMAND_QMLINHERITS) { if (node->name() == args[0].first) doc.location().warning( QStringLiteral("%1 tries to inherit itself").arg(args[0].first)); - else if (node->isQmlType() || node->isJsType()) { + else if (node->isQmlType()) { auto *qmlType = static_cast<QmlTypeNode *>(node); qmlType->setQmlBaseName(args[0].first); } @@ -475,9 +467,7 @@ QString QmlDocVisitor::getFullyQualifiedId(QQmlJS::AST::UiQualifiedId *id) is level 1. Note that this visit() function creates the qdoc object node as a - QmlType. If it is actually a JsType, this fact is discovered when - the qdoc comment is applied to the node. The node's typet is then - changed to JsType. + QmlType. */ bool QmlDocVisitor::visit(QQmlJS::AST::UiObjectDefinition *definition) { @@ -592,12 +582,10 @@ bool QmlDocVisitor::visit(QQmlJS::AST::UiPublicMember *member) } switch (member->type) { case QQmlJS::AST::UiPublicMember::Signal: { - if (m_current->isQmlType() || m_current->isJsType()) { + if (m_current->isQmlType()) { auto *qmlType = static_cast<QmlTypeNode *>(m_current); if (qmlType) { FunctionNode::Metaness metaness = FunctionNode::QmlSignal; - if (qmlType->isJsType()) - metaness = FunctionNode::JsSignal; QString name = member->name.toString(); auto *newSignal = new FunctionNode(metaness, m_current, name); Parameters ¶meters = newSignal->parameters(); @@ -613,7 +601,7 @@ bool QmlDocVisitor::visit(QQmlJS::AST::UiPublicMember *member) } case QQmlJS::AST::UiPublicMember::Property: { QString type = qualifiedIdToString(member->memberType); - if (m_current->isQmlType() || m_current->isJsType()) { + if (m_current->isQmlType()) { auto *qmlType = static_cast<QmlTypeNode *>(m_current); if (qmlType) { QString name = member->name.toString(); @@ -658,9 +646,7 @@ bool QmlDocVisitor::visit(QQmlJS::AST::FunctionDeclaration *fd) { if (m_nestingLevel <= 1) { FunctionNode::Metaness metaness = FunctionNode::QmlMethod; - if (m_current->isJsType()) - metaness = FunctionNode::JsMethod; - else if (!m_current->isQmlType()) + if (!m_current->isQmlType()) return true; QString name = fd->name.toString(); auto *method = new FunctionNode(metaness, m_current, name); |