13#include <QtCore/qobjectdefs.h>
17using namespace Qt::StringLiterals;
24
25
26
27
28
29
32 s_markers.prepend(
this);
36
37
38
41 s_markers.removeAll(
this);
45
46
47
51
52
59
60
61
65 for (
const auto &marker : std::as_const(s_markers))
66 marker->initializeMarker();
70
71
74 for (
const auto &marker : std::as_const(s_markers))
75 marker->terminateMarker();
80 CodeMarker *defaultMarker = markerForLanguage(s_defaultLang);
81 if (defaultMarker !=
nullptr && defaultMarker->recognizeCode(code))
84 for (
const auto &marker : std::as_const(s_markers)) {
85 if (marker->recognizeCode(code))
94 CodeMarker *defaultMarker = markerForLanguage(s_defaultLang);
96 while ((dot = fileName.lastIndexOf(QLatin1Char(
'.'), dot)) != -1) {
97 QString ext = fileName.mid(dot + 1);
98 if (defaultMarker !=
nullptr && defaultMarker->recognizeExtension(ext))
100 for (
const auto &marker : std::as_const(s_markers)) {
101 if (marker->recognizeExtension(ext))
106 return defaultMarker;
111 for (
const auto &marker : std::as_const(s_markers)) {
112 if (marker->recognizeLanguage(lang))
120#if QT_POINTER_SIZE == 4
121 const quintptr n = string.toUInt();
123 const quintptr n = string.toULongLong();
125 return reinterpret_cast<
const Node *>(n);
130 return QString::number(
reinterpret_cast<quintptr>(node));
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
153 if (node->isPreliminary())
154 return std::optional(u"preliminary"_s);
157 if (
const auto &since = node->since(); !since.isEmpty())
158 result <<
"since %1"_L1.arg(since);
159 if (
const auto &deprecated = node->deprecatedSince(); !deprecated.isEmpty()) {
160 if (node->isDeprecated())
161 result <<
"deprecated in %1"_L1.arg(deprecated);
163 result <<
"until %1"_L1.arg(deprecated);
165 result << u"deprecated"_s;
168 return result.isEmpty() ? std::nullopt : std::optional(result.join(u", "_s));
172
173
174
184 const auto *func =
static_cast<
const FunctionNode *>(node);
199 if (
auto noexcept_info = func->getNoexcept()) {
200 extra << (QString(
"noexcept") + (!(*noexcept_info).isEmpty() ?
"(...)" :
""));
203 if (func
->access() == Access::Protected)
204 extra <<
"protected";
205 else if (func
->access() == Access::Private)
217 extra <<
"invokable";
224 auto propertyNode =
static_cast<
const PropertyNode *>(node);
228 extra <<
"read-only";
234 extra << u"default"_s;
238 extra << u"read-only"_s;
240 extra << u"required"_s;
241 else if (!qmlProperty->defaultValue().isEmpty()) {
242 extra << u"default: "_s + qmlProperty->defaultValue();
252 if (
auto status = nodeStatusAsString(node)) {
253 if (!extra.isEmpty())
254 extra.last() +=
','_L1;
258 QString extraStr = extra.join(QLatin1Char(
' '));
259 if (!extraStr.isEmpty()) {
274 qsizetype n = str.size();
276 marked.reserve(n * 2 + 30);
277 const QChar *data = str.constData();
278 for (
int i = 0; i != n; ++i) {
279 switch (data[i].unicode()) {
299void CodeMarker::appendProtectedString(QString *output, QStringView str)
301 qsizetype n = str.size();
302 output->reserve(output->size() + n * 2 + 30);
303 const QChar *data = str.constData();
304 for (
int i = 0; i != n; ++i) {
305 switch (data[i].unicode()) {
329 for (
int i = 0; i <= string.size(); ++i) {
331 if (i != string.size())
334 QChar lower = ch.toLower();
335 if ((lower >= QLatin1Char(
'a') && lower <= QLatin1Char(
'z')) || ch.digitValue() >= 0
336 || ch == QLatin1Char(
'_') || ch == QLatin1Char(
':')) {
339 if (!pendingWord.isEmpty()) {
340 bool isProbablyType = (pendingWord != QLatin1String(
"const"));
342 result += QLatin1String(
"<@type>");
343 result += pendingWord;
345 result += QLatin1String(
"</@type>");
349 switch (ch.unicode()) {
353 result += QLatin1String(
"&");
356 result += QLatin1String(
"<");
359 result += QLatin1String(
">");
366 if (trailingSpace && string.size()) {
367 if (!string.endsWith(QLatin1Char(
'*')) && !string.endsWith(QLatin1Char(
'&')))
368 result += QLatin1Char(
' ');
376 const QString &name = node->name();
380 tag = QLatin1String(
"@namespace");
385 tag = QLatin1String(
"@class");
388 tag = QLatin1String(
"@enum");
392 tag = QLatin1String(
"@typedef");
395 tag = QLatin1String(
"@function");
398 tag = QLatin1String(
"@property");
401 tag = QLatin1String(
"@property");
404 tag = QLatin1String(
"@property");
407 tag = QLatin1String(
"@unknown");
410 return (QLatin1Char(
'<') + tag + QLatin1Char(
'>') + protect(name) + QLatin1String(
"</") + tag
418 const auto *fn =
static_cast<
const FunctionNode *>(node);
421 tag = QLatin1String(
"@signal");
424 tag = QLatin1String(
"@signalhandler");
427 tag = QLatin1String(
"@method");
430 tag = QLatin1String(
"@unknown");
434 tag = QLatin1String(
"@property");
436 tag = QLatin1String(
"@unknown");
438 return QLatin1Char(
'<') + tag + QLatin1Char(
'>') + protect(node->name()) + QLatin1String(
"</")
439 + tag + QLatin1Char(
'>');
444 return QLatin1String(
"<@link node=\"") + stringForNode(node) + QLatin1String(
"\">") + body
445 + QLatin1String(
"</@link>");
QString typified(const QString &string, bool trailingSpace=false)
CodeMarker()
When a code marker constructs itself, it puts itself into the static list of code markers.
virtual void initializeMarker()
A code market performs no initialization by default.
static void initialize()
All the code markers in the static list are initialized here, after the qdoc configuration file has b...
QString taggedQmlNode(const Node *node)
virtual ~CodeMarker()
When a code marker destroys itself, it removes itself from the static list of code markers.
virtual void terminateMarker()
Terminating a code marker is trivial.
static void terminate()
All the code markers in the static list are terminated here.
QString linkTag(const Node *node, const QString &body)
QString taggedNode(const Node *node)
This node is used to represent any kind of function being documented.
const Parameters & parameters() const
bool isNonvirtual() const
bool isDefault() const override
Returns true if the QML property node is marked as default.
bool isPureVirtual() const
bool isStatic() const override
Returns true if the FunctionNode represents a static function.
Metaness metaness() const
bool isFunction(Genus g=DontCare) const
Returns true if this is a FunctionNode and its Genus is set to g.
virtual bool isDeprecated() const
Returns true if this node's status is Deprecated.
NodeType nodeType() const
Returns this node's type.
Access access() const
Returns the node's Access setting, which can be Public, Protected, or Private.
LinkType
An unsigned char value that probably should be moved out of the Node base class.
bool isQmlProperty() const
Returns true if the node type is QmlProperty.
bool isPrivateSignal() const
This class describes one instance of using the Q_PROPERTY macro.
PropertyType propertyType() const
bool isDefault() const override
Returns true if the QML property node is marked as default.
bool isRequired()
Returns true if this QML property is marked with \required or the corresponding C++ property uses the...
bool isReadOnly()
Returns true if this QML property or attached property is read-only.
A class for containing the elements of one documentation section.
static std::optional< QString > nodeStatusAsString(const Node *node)
Returns a string representing the node status, set using \preliminary,.
static const QString samp
static const QString squot
Combined button and popup list for selecting options.