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/cppcodeparser.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/cppcodeparser.cpp')
-rw-r--r-- | src/qdoc/cppcodeparser.cpp | 75 |
1 files changed, 13 insertions, 62 deletions
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index 196efd527..8a2ed65eb 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -51,11 +51,7 @@ CppCodeParser::CppCodeParser() << COMMAND_QMLATTACHEDSIGNAL << COMMAND_QMLMETHOD << COMMAND_QMLATTACHEDMETHOD << COMMAND_QMLVALUETYPE << COMMAND_QMLBASICTYPE << COMMAND_QMLMODULE - << COMMAND_JSTYPE << COMMAND_JSPROPERTY - << COMMAND_JSPROPERTYGROUP // mws 13/03/2019 - << COMMAND_JSATTACHEDPROPERTY << COMMAND_JSSIGNAL << COMMAND_JSATTACHEDSIGNAL - << COMMAND_JSMETHOD << COMMAND_JSATTACHEDMETHOD << COMMAND_JSBASICTYPE - << COMMAND_JSMODULE << COMMAND_STRUCT << COMMAND_UNION; + << COMMAND_STRUCT << COMMAND_UNION; } if (metaCommands_.isEmpty()) { metaCommands_ = commonMetaCommands(); @@ -263,13 +259,6 @@ Node *CppCodeParser::processTopicCommand(const Doc &doc, const QString &command, cn->setLocation(doc.startLocation()); cn->markSeen(); return cn; - } else if (command == COMMAND_JSMODULE) { - QStringList blankSplit = arg.first.split(QLatin1Char(' ')); - CollectionNode *cn = m_qdb->addJsModule(blankSplit[0]); - cn->setLogicalModuleInfo(blankSplit); - cn->setLocation(doc.startLocation()); - cn->markSeen(); - return cn; } else if (command == COMMAND_PAGE) { Node::PageType ptype = Node::ArticlePage; QStringList args = arg.first.split(QLatin1Char(' ')); @@ -302,27 +291,12 @@ Node *CppCodeParser::processTopicCommand(const Doc &doc, const QString &command, qcn = new QmlTypeNode(m_qdb->primaryTreeRoot(), arg.first); qcn->setLocation(doc.startLocation()); return qcn; - } else if (command == COMMAND_JSTYPE) { - QmlTypeNode *qcn = nullptr; - Node *candidate = m_qdb->primaryTreeRoot()->findChildNode(arg.first, Node::JS); - if (candidate != nullptr && candidate->isJsType()) - qcn = static_cast<QmlTypeNode *>(candidate); - else - qcn = new QmlTypeNode(m_qdb->primaryTreeRoot(), arg.first, Node::JsType); - qcn->setLocation(doc.startLocation()); - return qcn; } else if (command == COMMAND_QMLVALUETYPE || command == COMMAND_QMLBASICTYPE) { auto *node = new QmlValueTypeNode(m_qdb->primaryTreeRoot(), arg.first); node->setLocation(doc.startLocation()); return node; - } else if (command == COMMAND_JSBASICTYPE) { - auto *node = new QmlValueTypeNode(m_qdb->primaryTreeRoot(), arg.first, Node::JsBasicType); - node->setLocation(doc.startLocation()); - return node; } else if ((command == COMMAND_QMLSIGNAL) || (command == COMMAND_QMLMETHOD) - || (command == COMMAND_QMLATTACHEDSIGNAL) || (command == COMMAND_QMLATTACHEDMETHOD) - || (command == COMMAND_JSSIGNAL) || (command == COMMAND_JSMETHOD) - || (command == COMMAND_JSATTACHEDSIGNAL) || (command == COMMAND_JSATTACHEDMETHOD)) { + || (command == COMMAND_QMLATTACHEDSIGNAL) || (command == COMMAND_QMLATTACHEDMETHOD)) { Q_UNREACHABLE(); } return nullptr; @@ -391,7 +365,6 @@ void CppCodeParser::processQmlProperties(const Doc &doc, NodeList &nodes, DocLis QString qmlTypeName; Topic topic = topics.at(0); - bool jsProps = isJSPropertyTopic(topic.m_topic); arg = topic.m_args; if (splitQmlPropertyArg(arg, type, module, qmlTypeName, property, doc.location())) { qsizetype i = property.indexOf('.'); @@ -407,8 +380,7 @@ void CppCodeParser::processQmlProperties(const Doc &doc, NodeList &nodes, DocLis for (const auto &topicCommand : topics) { QString cmd = topicCommand.m_topic; arg = topicCommand.m_args; - if ((cmd == COMMAND_QMLPROPERTY) || (cmd == COMMAND_QMLATTACHEDPROPERTY) - || (cmd == COMMAND_JSPROPERTY) || (cmd == COMMAND_JSATTACHEDPROPERTY)) { + if ((cmd == COMMAND_QMLPROPERTY) || (cmd == COMMAND_QMLATTACHEDPROPERTY)) { bool attached = cmd.contains(QLatin1String("attached")); if (splitQmlPropertyArg(arg, type, module, qmlTypeName, property, doc.location())) { if (qmlType != m_qdb->findQmlType(module, qmlTypeName)) { @@ -431,14 +403,14 @@ void CppCodeParser::processQmlProperties(const Doc &doc, NodeList &nodes, DocLis } auto *qpn = new QmlPropertyNode(qmlType, property, type, attached); qpn->setLocation(doc.startLocation()); - qpn->setGenus(jsProps ? Node::JS : Node::QML); + qpn->setGenus(Node::QML); nodes.append(qpn); docs.append(doc); sharedNodes << qpn; } } else { doc.startLocation().warning( - QStringLiteral("Command '\\%1'; not allowed with QML/JS property commands") + QStringLiteral("Command '\\%1'; not allowed with QML property commands") .arg(cmd)); } } @@ -578,12 +550,12 @@ void CppCodeParser::processMetaCommand(const Doc &doc, const QString &command, } else if (command == COMMAND_QMLINHERITS) { if (node->name() == arg) doc.location().warning(QStringLiteral("%1 tries to inherit itself").arg(arg)); - else if (node->isQmlType() || node->isJsType()) { + else if (node->isQmlType()) { auto *qmlType = static_cast<QmlTypeNode *>(node); qmlType->setQmlBaseName(arg); } } else if (command == COMMAND_QMLINSTANTIATES) { - if (node->isQmlType() || node->isJsType()) { + if (node->isQmlType()) { ClassNode *classNode = m_qdb->findClassNode(arg.split("::")); if (classNode) node->setClassNode(classNode); @@ -617,7 +589,7 @@ void CppCodeParser::processMetaCommand(const Doc &doc, const QString &command, else static_cast<QmlPropertyNode *>(node)->setRequired(); } else 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); @@ -630,8 +602,6 @@ void CppCodeParser::processMetaCommand(const Doc &doc, const QString &command, m_qdb->addToModule(arg, node); } else if (command == COMMAND_INQMLMODULE) { m_qdb->addToQmlModule(arg, node); - } else if (command == COMMAND_INJSMODULE) { - m_qdb->addToJsModule(arg, node); } else if (command == COMMAND_OBSOLETE) { node->setStatus(Node::Deprecated); } else if (command == COMMAND_NONREENTRANT) { @@ -710,7 +680,7 @@ void CppCodeParser::processMetaCommands(const Doc &doc, Node *node) } /*! - Parse QML/JS signal/method topic commands. + Parse QML signal/method topic commands. */ FunctionNode *CppCodeParser::parseOtherFuncArg(const QString &topic, const Location &location, const QString &funcArg) @@ -881,16 +851,6 @@ void CppCodeParser::setExampleFileLists(ExampleNode *en) } /*! - returns true if \a t is \e {jssignal}, \e {jsmethod}, - \e {jsattachedsignal}, or \e {jsattachedmethod}. - */ -bool CppCodeParser::isJSMethodTopic(const QString &t) -{ - return (t == COMMAND_JSSIGNAL || t == COMMAND_JSMETHOD || t == COMMAND_JSATTACHEDSIGNAL - || t == COMMAND_JSATTACHEDMETHOD); -} - -/*! returns true if \a t is \e {qmlsignal}, \e {qmlmethod}, \e {qmlattachedsignal}, or \e {qmlattachedmethod}. */ @@ -901,15 +861,6 @@ bool CppCodeParser::isQMLMethodTopic(const QString &t) } /*! - Returns true if \a t is \e {jsproperty}, \e {jspropertygroup}, - or \e {jsattachedproperty}. - */ -bool CppCodeParser::isJSPropertyTopic(const QString &t) -{ - return (t == COMMAND_JSPROPERTY || t == COMMAND_JSATTACHEDPROPERTY); -} - -/*! Returns true if \a t is \e {qmlproperty}, \e {qmlpropertygroup}, or \e {qmlattachedproperty}. */ @@ -921,7 +872,7 @@ bool CppCodeParser::isQMLPropertyTopic(const QString &t) void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeList &nodes, DocList &docs) { - if (isQMLPropertyTopic(topic) || isJSPropertyTopic(topic)) { + if (isQMLPropertyTopic(topic)) { processQmlProperties(doc, nodes, docs); } else { ArgList args = doc.metaCommandArgs(topic); @@ -932,7 +883,7 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL node = parserForLanguage("Clang")->parseFnArg(doc.location(), args[0].first, args[0].second); } else if (topic == COMMAND_MACRO) { node = parseMacroArg(doc.location(), args[0].first); - } else if (isQMLMethodTopic(topic) || isJSMethodTopic(topic)) { + } else if (isQMLMethodTopic(topic)) { node = parseOtherFuncArg(topic, doc.location(), args[0].first); } else if (topic == COMMAND_DONTDOCUMENT) { m_qdb->primaryTree()->addToDontDocumentMap(args[0].first); @@ -952,7 +903,7 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL node = parserForLanguage("Clang")->parseFnArg(doc.location(), arg.first, arg.second); } else if (topic == COMMAND_MACRO) { node = parseMacroArg(doc.location(), arg.first); - } else if (isQMLMethodTopic(topic) || isJSMethodTopic(topic)) { + } else if (isQMLMethodTopic(topic)) { node = parseOtherFuncArg(topic, doc.location(), arg.first); } else { node = processTopicCommand(doc, topic, arg); @@ -1026,7 +977,7 @@ bool CppCodeParser::hasTooManyTopics(const Doc &doc) const if (topicCommandsUsed.count() > 1) { bool ok = true; for (const auto &t : topicCommandsUsed) { - if (!t.startsWith(QLatin1String("qml")) && !t.startsWith(QLatin1String("js"))) + if (!t.startsWith(QLatin1String("qml"))) ok = false; } if (ok) |