15#include <QtCore/qobjectdefs.h>
19using namespace Qt::StringLiterals;
26
27
28
29
30
31
34 s_markers.prepend(
this);
38
39
40
43 s_markers.removeAll(
this);
47
48
49
53
54
61
62
63
67 for (
const auto &marker : std::as_const(s_markers))
68 marker->initializeMarker();
72
73
76 for (
const auto &marker : std::as_const(s_markers))
77 marker->terminateMarker();
82 CodeMarker *defaultMarker = markerForLanguage(s_defaultLang);
83 if (defaultMarker !=
nullptr && defaultMarker->recognizeCode(code))
86 for (
const auto &marker : std::as_const(s_markers)) {
87 if (marker->recognizeCode(code))
96 CodeMarker *defaultMarker = markerForLanguage(s_defaultLang);
98 while ((dot = fileName.lastIndexOf(QLatin1Char(
'.'), dot)) != -1) {
99 QString ext = fileName.mid(dot + 1);
100 if (defaultMarker !=
nullptr && defaultMarker->recognizeExtension(ext))
101 return defaultMarker;
102 for (
const auto &marker : std::as_const(s_markers)) {
103 if (marker->recognizeExtension(ext))
108 return defaultMarker;
113 for (
const auto &marker : std::as_const(s_markers)) {
114 if (marker->recognizeLanguage(lang))
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
140 if (node->isPreliminary())
141 return std::optional(u"preliminary"_s);
144 if (
const auto &since = node->since(); !since.isEmpty())
145 result <<
"since %1"_L1.arg(since);
146 if (
const auto &deprecated = node->deprecatedSince(); !deprecated.isEmpty()) {
147 if (node->isDeprecated())
148 result <<
"deprecated in %1"_L1.arg(deprecated);
150 result <<
"until %1"_L1.arg(deprecated);
152 result << u"deprecated"_s;
155 return result.isEmpty() ? std::nullopt : std::optional(result.join(u", "_s));
159
160
161
172 extra <<
"anonymous";
178 extra <<
"anonymous";
181 const auto *func =
static_cast<
const FunctionNode *>(node);
196 if (
auto noexcept_info = func->getNoexcept()) {
197 extra << (QString(
"noexcept") + (!(*noexcept_info).isEmpty() ?
"(...)" :
""));
201 extra <<
"protected";
214 extra <<
"invokable";
221 auto propertyNode =
static_cast<
const PropertyNode *>(node);
225 extra <<
"read-only";
231 extra << u"default"_s;
235 extra << u"read-only"_s;
237 extra << u"required"_s;
238 else if (!qmlProperty->defaultValue().isEmpty()) {
239 extra << u"default: "_s + qmlProperty->defaultValue();
249 if (
auto status = nodeStatusAsString(node)) {
250 if (!extra.isEmpty())
251 extra.last() +=
','_L1;
255 QString extraStr = extra.join(QLatin1Char(
' '));
256 if (!extraStr.isEmpty()) {
266 return Utilities::protect(str);
269void CodeMarker::appendProtectedString(QString *output, QStringView str)
271 qsizetype n = str.size();
272 output->reserve(output->size() + n * 2 + 30);
273 const QChar *data = str.constData();
274 for (
int i = 0; i != n; ++i) {
275 switch (data[i].unicode()) {
277 *output += Utilities::samp;
280 *output += Utilities::slt;
283 *output += Utilities::sgt;
286 *output += Utilities::squot;
299 for (
int i = 0; i <= string.size(); ++i) {
301 if (i != string.size())
304 QChar lower = ch.toLower();
305 if ((lower >= QLatin1Char(
'a') && lower <= QLatin1Char(
'z')) || ch.digitValue() >= 0
306 || ch == QLatin1Char(
'_') || ch == QLatin1Char(
':')) {
309 if (!pendingWord.isEmpty()) {
310 bool isProbablyType = (pendingWord != QLatin1String(
"const"));
312 result += QLatin1String(
"<@type>");
313 result += pendingWord;
315 result += QLatin1String(
"</@type>");
319 switch (ch.unicode()) {
323 result += QLatin1String(
"&");
326 result += QLatin1String(
"<");
329 result += QLatin1String(
">");
336 if (trailingSpace && string.size()) {
337 if (!string.endsWith(QLatin1Char(
'*')) && !string.endsWith(QLatin1Char(
'&')))
338 result += QLatin1Char(
' ');
346 const QString &name = node->name();
350 tag = QLatin1String(
"@namespace");
355 tag = QLatin1String(
"@class");
358 tag = QLatin1String(
"@enum");
362 tag = QLatin1String(
"@typedef");
365 tag = QLatin1String(
"@function");
368 tag = QLatin1String(
"@property");
371 tag = QLatin1String(
"@property");
374 tag = QLatin1String(
"@property");
377 tag = QLatin1String(
"@unknown");
380 return (QLatin1Char(
'<') + tag + QLatin1Char(
'>') + protect(name) + QLatin1String(
"</") + tag
388 const auto *fn =
static_cast<
const FunctionNode *>(node);
391 tag = QLatin1String(
"@signal");
394 tag = QLatin1String(
"@signalhandler");
397 tag = QLatin1String(
"@method");
400 tag = QLatin1String(
"@unknown");
404 tag = QLatin1String(
"@property");
406 tag = QLatin1String(
"@unknown");
408 return QLatin1Char(
'<') + tag + QLatin1Char(
'>') + protect(node->name()) + QLatin1String(
"</")
409 + tag + QLatin1Char(
'>');
414 return QLatin1String(
"<@link node=\"") + Utilities::stringForNode(node) + QLatin1String(
"\">") + body
415 + QLatin1String(
"</@link>");
The ClassNode represents a C++ class.
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 isPureVirtual() const override
bool isNonvirtual() const
bool isDefault() const override
Returns true if the QML property node is marked as default.
bool isStatic() const override
Returns true if the FunctionNode represents a static function.
Metaness metaness() 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,.
The Node class is the base class for all the nodes in QDoc's parse tree.
NodeType nodeType() const override
Returns this node's type.
virtual bool isDeprecated() const
Returns true if this node's status is Deprecated.
Access access() const
Returns the node's Access setting, which can be Public, Protected, or Private.
bool isFunction(Genus g=Genus::DontCare) const
Returns true if this is a FunctionNode and its Genus is set to g.
bool isQmlProperty() const
Returns true if the node type is QmlProperty.
bool isPrivateSignal() const