diff options
author | Luca Di Sera <luca.disera@qt.io> | 2023-03-17 16:42:24 +0100 |
---|---|---|
committer | Luca Di Sera <luca.disera@qt.io> | 2023-03-19 16:04:48 +0100 |
commit | 407f831e79fe2c3f662c82cb196afc49b1ec2934 (patch) | |
tree | 70702e5d30754f079ca79d5580a9873479e59fe8 /src/qdoc/cppcodeparser.cpp | |
parent | bf03e5a11f4052e74da260bfedcf23f4761113af (diff) | |
download | qttools-407f831e79fe2c3f662c82cb196afc49b1ec2934.tar.gz |
QDoc: Move `CodeParser::checkModuleInclusion` to "cppcodeparser.cpp"
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.
For certain documentable elements, QDoc expects that an "\inmodule"
commands is provided, as it requires it to understand where to position
them when generating the output documentation.
To ensure that this constraint is satisfied, CppCodeParser`, the
`CodeParser` subclass that takes care of providing the semantic for QDoc
block-comments, calls at a certain point
`CodeParser::checkModuleInclusion`, a method that makes sure that the
internal representation of the comment-block and the documented element
have a valid "\inmodule" information for the later stages.
`checkModuleInclusion` is only called by `CppCodeParser` and does not
require any instance-state that would not otherwise be available.
Hence, `checkModuleInclusion` is removed from `CodeParser` in favor of
being a static in "cppcodeparser.cpp", just above its actual usage.
An access to `m_qdb`, an instance-member for `CodeParser` that reference
the `QDocDatabase` singleton was modified to directly obtain a
`QDocDatabase` instance, as the member is not available outside
`CodeParser`s.
Change-Id: I0a8abc53d3c4fbd3e6687254a0034a3e12a6e018
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/cppcodeparser.cpp')
-rw-r--r-- | src/qdoc/cppcodeparser.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index 341acb6b3..b15c870de 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -872,6 +872,35 @@ void CppCodeParser::processTopicArgs(const Doc &doc, const QString &topic, NodeL } } +/*! + For each node that is part of C++ API and produces a documentation + page, this function ensures that the node belongs to a module. + */ +static void checkModuleInclusion(Node *n) +{ + if (n->physicalModuleName().isEmpty()) { + if (n->isInAPI() && !n->name().isEmpty()) { + switch (n->nodeType()) { + case Node::Class: + case Node::Struct: + case Node::Union: + case Node::Namespace: + case Node::HeaderFile: + break; + default: + return; + } + n->setPhysicalModuleName(Generator::defaultModuleName()); + QDocDatabase::qdocDB()->addToModule(Generator::defaultModuleName(), n); + n->doc().location().warning( + QStringLiteral("Documentation for %1 '%2' has no \\inmodule command; " + "using project name by default: %3") + .arg(Node::nodeTypeString(n->nodeType()), n->name(), + n->physicalModuleName())); + } + } +} + void CppCodeParser::processMetaCommands(NodeList &nodes, DocList &docs) { QList<Doc>::Iterator d = docs.begin(); |