Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
parsererror.cpp
Go to the documentation of this file.
1
// Copyright (C) 2024 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4
#
include
"parsererror.h"
5
#
include
"node.h"
6
#
include
"qdocdatabase.h"
7
#
include
"config.h"
8
#
include
"inclusionfilter.h"
9
#
include
"qdoclogging.h"
10
11
#
include
<
QtCore
/
qregularexpression
.
h
>
12
13
using
namespace
Qt::Literals::StringLiterals;
14
15
QT_BEGIN_NAMESPACE
16
17
/*!
18
\class FnMatchError
19
\brief Encapsulates information about \fn match error during parsing.
20
*/
21
22
/*!
23
\variable FnMatchError::signature
24
25
Signature for the \fn topic that failed to match.
26
*/
27
28
/*!
29
\relates FnMatchError
30
31
Returns \c true if any parent of a C++ function represented by
32
\a signature is documented as \\internal.
33
*/
34
bool
isParentInternal
(
const
QString &signature)
35
{
36
const
QRegularExpression scoped_fn{R"((?:\w+(?:<[^>]+>)?::)+~?\w\S*\()"};
37
auto
match = scoped_fn.match(signature);
38
if
(!match.isValid())
39
return
false
;
40
41
auto
scope = match.captured().split(
"::"_L1
);
42
scope.removeLast();
// Drop function name
43
44
for
(
auto
&s : scope)
45
if
(qsizetype pos = s.indexOf(
'<'
); pos >= 0)
46
s.truncate(pos);
47
48
auto
parent =
QDocDatabase
::
qdocDB
(
)
->findNodeByNameAndType(scope, &
Node
::
isCppNode
);
49
if
(parent && !(parent->isClassNode() || parent->isNamespace())) {
50
qCDebug(lcQdoc).noquote()
51
<<
"Invalid scope:"
<< qPrintable(parent->nodeTypeString())
52
<< qPrintable(parent->fullName())
53
<<
"for \\fn"
<< qPrintable(signature);
54
return
false
;
55
}
56
57
while
(parent) {
58
if
(parent->isInternal())
59
return
true
;
60
parent = parent->parent();
61
}
62
63
return
false
;
64
}
65
66
/*!
67
\class ParserErrorHandler
68
\brief Processes parser errors and outputs warnings for them.
69
*/
70
71
/*!
72
Generates a warning specific to FnMatchError.
73
74
Warnings for internal documentation are omitted. Specifically, this
75
(omission) happens if:
76
77
\list
78
\li \c {--showinternal} command line option is \b not
79
used, and
80
\li The warning is for an \\fn that is declared
81
under a namespace/class that is documented as
82
\\internal.
83
\endlist
84
*/
85
void
ParserErrorHandler
::
operator
()(
const
FnMatchError
&e)
const
86
{
87
const
InclusionPolicy policy = Config::instance().createInclusionPolicy();
88
if
(InclusionFilter::processInternalDocs(policy) || !isParentInternal(e.signature))
89
e.location.warning(
"Failed to find function when parsing \\fn %1"_L1
.arg(e.signature));
90
}
91
92
QT_END_NAMESPACE
QDocDatabase
This class provides exclusive access to the qdoc database, which consists of a forrest of trees and a...
Definition
qdocdatabase.h:214
QDocDatabase::qdocDB
static QDocDatabase * qdocDB()
Creates the singleton.
Definition
qdocdatabase.cpp:373
FnMatchError
Encapsulates information about.
Definition
parsererror.h:13
FnMatchError::isParentInternal
bool isParentInternal(const QString &signature)
Returns true if any parent of a C++ function represented by signature is documented as \internal.
Definition
parsererror.cpp:34
Node
The Node class is the base class for all the nodes in QDoc's parse tree.
Definition
src_corelib_text_qstring.cpp:10
Node::isCppNode
bool isCppNode() const
Returns true if this node's Genus value is CPP.
Definition
node.h:92
ParserErrorHandler
Processes parser errors and outputs warnings for them.
Definition
parsererror.h:20
ParserErrorHandler::operator()
void operator()(const FnMatchError &e) const
Generates a warning specific to FnMatchError.
Definition
parsererror.cpp:85
qttools
src
qdoc
qdoc
src
qdoc
parsererror.cpp
Generated on
for Qt by
1.18.0