diff options
author | Luca Di Sera <luca.disera@qt.io> | 2023-03-17 12:40:56 +0100 |
---|---|---|
committer | Luca Di Sera <luca.disera@qt.io> | 2023-03-19 15:04:32 +0000 |
commit | 8adba40d7c780c7ad2b75b6fdc8105568094907b (patch) | |
tree | 85c03375475b7a68fabac172126c06bebfb2eb6c /src/qdoc/cppcodeparser.cpp | |
parent | a45b2106549e8b0eb665651b053fba3743d50324 (diff) | |
download | qttools-8adba40d7c780c7ad2b75b6fdc8105568094907b.tar.gz |
QDoc: Remove `QmlCodeParser::topicCommands`
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 various `CodeParser` child classes provides a
way to access the available commands.
In particular, `QmlCodeParser`, the class that processes QML files,
provides `topicCommands`, a method to retrieve the available topic
commands for documentation extracted by QML files.
`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<QString>`, 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 static,
`topic_commands`, that is initialized in-place, to simplify the
related code.
`topicCommands()` only uses were in `QmlCodeParser::parseSourceFile`,
the entry point for the extraction of documentation from a specific QML
file.
Thus, `topic_commands` is now scoped as a static in `parseSourceFile`,
the smaller scope where it is required.
All usages of `topicCommands()` were modified to refer to
`topic_commands`, keeping an equivalent semantic.
Change-Id: Ic97166a9a563f4e8d5ac840999231d92045a6f0d
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/cppcodeparser.cpp')
0 files changed, 0 insertions, 0 deletions