summaryrefslogtreecommitdiff
path: root/src/qdoc/cppcodeparser.cpp
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2021-08-20 18:01:02 +0200
committerTopi Reiniƶ <topi.reinio@qt.io>2021-08-23 12:22:10 +0000
commit76fb767296e12235d93da683a7f2feb84a7a6675 (patch)
tree9b94000c1e1b4c4ea1e5c766b22cedca0ed33fa4 /src/qdoc/cppcodeparser.cpp
parente64a8cce3c31ab00afee959854621ae83f494ce1 (diff)
downloadqttools-76fb767296e12235d93da683a7f2feb84a7a6675.tar.gz
qdoc: Improve function tagging for grouped \fn commands
QDoc provides a mechanism for tagging specific function declarations in a header with //! [tag] comments, allowing these tags to be referenced in an \fn command. This feature did not work for shared comment nodes containing multiple \fn commands, however. To make this work, we need to associate the 'bracketed args' (where the id tag is) with the command itself - previously it was stored in the Doc instance, but that doesn't work when there are multiple topic commands sharing a doc. To do so, repurpose the ArgLocPair structure to store the bracketed arg instead of a Location, as we never used this particular Location for anything, anyway. Pick-to: 6.2 Fixes: QTBUG-95948 Change-Id: Ic899d4252d705f84ba56ea201a55f3e5db068f00 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qdoc/cppcodeparser.cpp')
-rw-r--r--src/qdoc/cppcodeparser.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp
index 26309194e..bf155c520 100644
--- a/src/qdoc/cppcodeparser.cpp
+++ b/src/qdoc/cppcodeparser.cpp
@@ -188,7 +188,7 @@ const QSet<QString> &CppCodeParser::topicCommands()
Process the topic \a command found in the \a doc with argument \a arg.
*/
Node *CppCodeParser::processTopicCommand(const Doc &doc, const QString &command,
- const ArgLocPair &arg)
+ const ArgPair &arg)
{
ExtraFuncData extra;
if (command == COMMAND_FN) {
@@ -496,9 +496,9 @@ const QSet<QString> &CppCodeParser::metaCommands()
\a node is guaranteed to be non-null.
*/
void CppCodeParser::processMetaCommand(const Doc &doc, const QString &command,
- const ArgLocPair &argLocPair, Node *node)
+ const ArgPair &argPair, Node *node)
{
- QString arg = argLocPair.first;
+ QString arg = argPair.first;
if (command == COMMAND_INHEADERFILE) {
if (node->isAggregate())
static_cast<Aggregate *>(node)->addIncludeFile(arg);
@@ -624,8 +624,8 @@ void CppCodeParser::processMetaCommand(const Doc &doc, const QString &command,
node->setAbstract(true);
} else if (command == COMMAND_DEPRECATED) {
node->setStatus(Node::Deprecated);
- if (const QString version = doc.bracketedArgs(command); !version.isEmpty())
- node->setDeprecatedSince(version);
+ if (!argPair.second.isEmpty())
+ node->setDeprecatedSince(argPair.second);
} else if (command == COMMAND_INGROUP || command == COMMAND_INPUBLICGROUP) {
// Note: \ingroup and \inpublicgroup are the same (and now recognized as such).
m_qdb->addToGroup(arg, node);
@@ -915,7 +915,7 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL
if (args.size() == 1) {
if (topic == COMMAND_FN) {
if (showInternal() || !doc.isInternal())
- node = parserForLanguage("Clang")->parseFnArg(doc.location(), args[0].first, doc.bracketedArgs(topic));
+ 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)) {
@@ -935,7 +935,7 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL
node = nullptr;
if (topic == COMMAND_FN) {
if (showInternal() || !doc.isInternal())
- node = parserForLanguage("Clang")->parseFnArg(doc.location(), arg.first); // TODO: Ensure \fn commands sharing a comment can have individual bracketed args
+ 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)) {
@@ -958,6 +958,7 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL
nodes.append(scn);
docs.append(doc);
}
+ processMetaCommands(doc, node);
}
}
for (auto *scn : sharedCommentNodes)