From 105791ef458d50f84387efbd8526671a8d8fd9a6 Mon Sep 17 00:00:00 2001 From: Luca Di Sera Date: Fri, 17 Mar 2023 14:00:02 +0100 Subject: QDoc: Remove `CppCodeParser::topicCommands` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As part of extracting user-provided documentation, QDoc has to parse a variety of source files in a variety of languages. `CodeParser` is the base class of objects that take care of performing this parsing process in QDoc. When extracting the documentation in one of the `CodeParser`s QDoc generally tries to parse the extracted documentation in-place. The documentation has a series of available commands that might depend on the currently used parser. To support this process some of the `CodeParser` child classes provides series of methods to retrieve the required commands for each parser. `CppCodeParser`, the parser that provides the semantic for QDoc's comment-blocks, for example, provides `topicCommands`, to list the available "topic commands" in a commnet-block. `topicCommands` initializes a static member, `topicCommands_` and then returns it, avoiding initialization if the method is called more than once. While this process can be better expressed by the simple use of a `static` there are two probable reason for why it wasn't done in this way. Supposedly, when this code was written, there was no suitable way to initialize a `QSet`, the type of `topicCommands_`, in-place, as similar patterns can be found in other legacy parts of QDoc that are confirmed to have had this issue due to their age. Additionally, the expansion of the `COMMAND_*` macros, which form the content for `topicCommands_`, were, until recently, dependent on certain data being available in another part of the system, so that expanding them in a static context that would be processed before this data was available would incur into a series of errors. This dependency was removed in a recent patch, so that the issue is no more. Hence, the `topicCommands()` method is removed, along with `topicCommands_`, in favor of a public static, `topic_commands`, that is initialized in-place, to simplify the related code. All usages of `topicCommands` were modified to refer to `CppCodeParser::topic_commands`, keeping an equivalent semantic, as a consequence of the change. Change-Id: I9de2332bf557254e7ffd33290e6af678c2b121aa Reviewed-by: Topi Reiniƶ --- src/qdoc/cppcodeparser.cpp | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'src/qdoc/cppcodeparser.cpp') diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index 01434f352..7c0cee764 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -33,7 +33,6 @@ QT_BEGIN_NAMESPACE QSet CppCodeParser::m_excludeDirs; QSet CppCodeParser::m_excludeFiles; -static QSet topicCommands_; static QSet metaCommands_; /* @@ -63,19 +62,6 @@ static const QMap s_nodeTypeTestFuncMap{ */ CppCodeParser::CppCodeParser() { - if (topicCommands_.isEmpty()) { - topicCommands_ << COMMAND_CLASS << COMMAND_DONTDOCUMENT << COMMAND_ENUM << COMMAND_EXAMPLE - << COMMAND_EXTERNALPAGE << COMMAND_FN << COMMAND_GROUP << COMMAND_HEADERFILE - << COMMAND_MACRO << COMMAND_MODULE << COMMAND_NAMESPACE << COMMAND_PAGE - << COMMAND_PROPERTY << COMMAND_TYPEALIAS << COMMAND_TYPEDEF - << COMMAND_VARIABLE << COMMAND_QMLTYPE << COMMAND_QMLPROPERTY - << COMMAND_QMLPROPERTYGROUP // mws 13/03/2019 - << COMMAND_QMLATTACHEDPROPERTY << COMMAND_QMLSIGNAL - << COMMAND_QMLATTACHEDSIGNAL << COMMAND_QMLMETHOD - << COMMAND_QMLATTACHEDMETHOD << COMMAND_QMLVALUETYPE << COMMAND_QMLBASICTYPE - << COMMAND_QMLMODULE - << COMMAND_STRUCT << COMMAND_UNION; - } if (metaCommands_.isEmpty()) { metaCommands_ = CodeParser::common_meta_commands; metaCommands_ << COMMAND_INHEADERFILE << COMMAND_NEXTPAGE @@ -137,14 +123,6 @@ QStringList CppCodeParser::sourceFileNameFilter() return QStringList(); } -/*! - Returns the set of strings representing the topic commands. - */ -const QSet &CppCodeParser::topicCommands() -{ - return topicCommands_; -} - /*! Process the topic \a command found in the \a doc with argument \a arg. */ @@ -971,7 +949,7 @@ void CppCodeParser::processMetaCommands(NodeList &nodes, DocList &docs) */ bool CppCodeParser::hasTooManyTopics(const Doc &doc) const { - const QSet topicCommandsUsed = topicCommands() & doc.metaCommandsUsed(); + const QSet topicCommandsUsed = CppCodeParser::topic_commands & doc.metaCommandsUsed(); if (topicCommandsUsed.empty() || topicCommandsUsed.size() == 1) return false; -- cgit v1.2.1