Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdocindexfiles.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
5
6#include "access.h"
7#include "atom.h"
8#include "classnode.h"
11#include "config.h"
12#include "enumnode.h"
13#include "qmlenumnode.h"
14#include "examplenode.h"
16#include "functionnode.h"
17#include "generator.h"
18#include "genustypes.h"
19#include "headernode.h"
22#include "location.h"
23#include "utilities.h"
24#include "textutils.h"
25#include "propertynode.h"
26#include "qdocdatabase.h"
29#include "typedefnode.h"
30#include "variablenode.h"
31
32#include <QtCore/qxmlstream.h>
33
34#include <algorithm>
35
37
47
48/*!
49 \class QDocIndexFiles
50
51 This class imports QDoc index files and serializes index sections for
52 module indexes and WebXML output.
53 */
54
55/*!
56 \struct QDocIndexFiles::ReadState
57 \internal
58 \brief Holds state for one index file import.
59
60 A new state is created for each file. Deferred base-class resolution,
61 related nodes, and shared documentation remain isolated from other imports.
62*/
63
64/*!
65 \variable QDocIndexFiles::ReadState::project
66 \brief The project name declared by the imported index.
67*/
68
69/*!
70 \variable QDocIndexFiles::ReadState::bases
71 \brief Classes and their base-class names awaiting resolution.
72*/
73
74/*!
75 \variable QDocIndexFiles::ReadState::relatedNodes
76 \brief Related non-member nodes used to resolve references during import.
77*/
78
79/*!
80 \variable QDocIndexFiles::ReadState::sharedDocNodes
81 \brief Shared documentation nodes keyed by property group name.
82*/
83
84/*!
85 \struct QDocIndexFiles::WriteState
86 \internal
87 \brief Holds state for one index file export.
88
89 A standalone index export creates a fresh state. WebXML owns a separate
90 state across the pages it serializes. Neither inherits related-node
91 numbering from an earlier import or output operation.
92*/
93
94/*!
95 \variable QDocIndexFiles::WriteState::root
96 \brief The primary tree root whose traversal completes an index export.
97
98 WebXML leaves this null because it serializes individual pages.
99*/
100
101/*!
102 \variable QDocIndexFiles::WriteState::relatedNodes
103 \brief Related non-member nodes numbered across this serialization operation.
104*/
105
106QDocIndexFiles *QDocIndexFiles::s_qdocIndexFiles = nullptr;
107
108/*!
109 Constructs the singleton QDocIndexFiles.
110 */
111QDocIndexFiles::QDocIndexFiles()
112{
114}
115
116/*!
117 Destroys the singleton QDocIndexFiles.
118 */
119QDocIndexFiles::~QDocIndexFiles()
120{
121 m_qdb = nullptr;
122}
123
124/*!
125 Creates the singleton. Allows only one instance of the class
126 to be created. Returns a pointer to the singleton.
127 */
128QDocIndexFiles *QDocIndexFiles::qdocIndexFiles()
129{
130 if (s_qdocIndexFiles == nullptr)
131 s_qdocIndexFiles = new QDocIndexFiles;
132 return s_qdocIndexFiles;
133}
134
135/*!
136 Destroys the singleton.
137 */
138void QDocIndexFiles::destroyQDocIndexFiles()
139{
140 if (s_qdocIndexFiles != nullptr) {
141 delete s_qdocIndexFiles;
142 s_qdocIndexFiles = nullptr;
143 }
144}
145
146/*!
147 Reads and parses the list of index files in \a indexFiles.
148 */
149void QDocIndexFiles::readIndexes(const QStringList &indexFiles)
150{
151 for (const QString &file : indexFiles) {
152 qCDebug(lcQdoc) << "Loading index file: " << file;
153 readIndexFile(file);
154 }
155}
156
157/*!
158 Reads and parses the index file at \a path, with a fresh import state.
159 */
160void QDocIndexFiles::readIndexFile(const QString &path)
161{
162 ReadState state;
163
164 QFile file(path);
165 if (!file.open(QFile::ReadOnly)) {
166 qWarning() << "Could not read index file" << path;
167 return;
168 }
169
170 QXmlStreamReader reader(&file);
171 reader.setNamespaceProcessing(false);
172
173 if (!reader.readNextStartElement())
174 return;
175
176 if (reader.name() != QLatin1String("INDEX"))
177 return;
178
179 QXmlStreamAttributes attrs = reader.attributes();
180
181 QString indexUrl {attrs.value(QLatin1String("url")).toString()};
182
183 // Decide how we link to nodes loaded from this index file:
184 // If building a set that will be installed AND the URL of
185 // the dependency is identical to ours, assume that also
186 // the dependent html files are available under the same
187 // directory tree. Otherwise, link using the full index URL.
188 if (!Config::installDir.isEmpty() && indexUrl == Config::instance().get(CONFIG_URL).asString()) {
189 // Generate a relative URL between the install dir and the index file
190 // when the --installdir command line option is set.
191 QDir installDir(path.section('/', 0, -3) + '/' + Generator::outputSubdir());
192 indexUrl = installDir.relativeFilePath(path).section('/', 0, -2);
193 }
194 state.project = attrs.value(QLatin1String("project")).toString();
195 QString indexTitle = attrs.value(QLatin1String("indexTitle")).toString();
196
197 NamespaceNode *root = m_qdb->newIndexTree(state.project);
198 if (!root) {
199 qWarning() << "Issue parsing index tree" << path;
200 return;
201 }
202
203 root->tree()->setIndexTitle(indexTitle);
204
205 // Scan all elements in the XML file, constructing a map that contains
206 // base classes for each class found.
207 while (reader.readNextStartElement()) {
208 readIndexSection(reader, root, indexUrl, state);
209 }
210
211 // Now that all the base classes have been found for this index,
212 // arrange them into an inheritance hierarchy.
213 resolveIndex(state);
214}
215
216/*!
217 Reads an element from the index file and creates the appropriate nodes
218 under \a current. The \a indexUrl supplies imported link locations;
219 \a state retains deferred relationships and shared documentation for this
220 file's remaining elements.
221 */
222void QDocIndexFiles::readIndexSection(QXmlStreamReader &reader, Node *current,
223 const QString &indexUrl, ReadState &state)
224{
225 QXmlStreamAttributes attributes = reader.attributes();
226 QStringView elementName = reader.name();
227
228 QString name = attributes.value(QLatin1String("name")).toString();
229 QString href = attributes.value(QLatin1String("href")).toString();
230 Node *node{nullptr};
231 Location location;
232 Aggregate *parent = nullptr;
233 bool hasReadChildren = false;
234
235 if (current->isAggregate())
236 parent = static_cast<Aggregate *>(current);
237
238 if (attributes.hasAttribute(QLatin1String("related"))) {
239 bool isIntTypeRelatedValue = false;
240 int relatedIndex = attributes.value(QLatin1String("related")).toInt(&isIntTypeRelatedValue);
241 if (isIntTypeRelatedValue) {
242 if (adoptRelatedNode(parent, relatedIndex, state)) {
243 reader.skipCurrentElement();
244 return;
245 }
246 } else {
247 QList<Node *>::iterator nodeIterator =
248 std::find_if(state.relatedNodes.begin(), state.relatedNodes.end(), [&](const Node *relatedNode) {
249 return (name == relatedNode->name() && href == relatedNode->url().section(QLatin1Char('/'), -1));
250 });
251
252 if (nodeIterator != state.relatedNodes.end() && parent) {
253 parent->adoptChild(*nodeIterator);
254 reader.skipCurrentElement();
255 return;
256 }
257 }
258 }
259
260 QString filePath;
261 int lineNo = 0;
262 if (attributes.hasAttribute(QLatin1String("filepath"))) {
263 filePath = attributes.value(QLatin1String("filepath")).toString();
264 lineNo = attributes.value("lineno").toInt();
265 }
266 if (parent && elementName == QLatin1String("namespace")) {
267 auto *namespaceNode = new NamespaceNode(parent, name);
268 node = namespaceNode;
269 if (!indexUrl.isEmpty())
270 location = Location(indexUrl + QLatin1Char('/') + name.toLower() + ".html");
271 else if (!indexUrl.isNull())
272 location = Location(name.toLower() + ".html");
273 } else if (parent && (elementName == QLatin1String("class") || elementName == QLatin1String("struct")
274 || elementName == QLatin1String("union"))) {
276 if (elementName == QLatin1String("class"))
277 type = NodeType::Class;
278 else if (elementName == QLatin1String("struct"))
279 type = NodeType::Struct;
280 else if (elementName == QLatin1String("union"))
281 type = NodeType::Union;
282 node = new ClassNode(type, parent, name);
283 if (attributes.hasAttribute(QLatin1String("bases"))) {
284 QString bases = attributes.value(QLatin1String("bases")).toString();
285 if (!bases.isEmpty())
286 state.bases.append(
287 std::pair<ClassNode *, QString>(static_cast<ClassNode *>(node), bases));
288 }
289 if (!indexUrl.isEmpty())
290 location = Location(indexUrl + QLatin1Char('/') + name.toLower() + ".html");
291 else if (!indexUrl.isNull())
292 location = Location(name.toLower() + ".html");
293 bool abstract = false;
294 if (attributes.value(QLatin1String("abstract")) == QLatin1String("true"))
295 abstract = true;
296 node->setAbstract(abstract);
297 } else if (parent && elementName == QLatin1String("header")) {
298 node = new HeaderNode(parent, name);
299
300 if (attributes.hasAttribute(QLatin1String("location")))
301 name = attributes.value(QLatin1String("location")).toString();
302
303 if (!indexUrl.isEmpty())
304 location = Location(indexUrl + QLatin1Char('/') + name);
305 else if (!indexUrl.isNull())
306 location = Location(name);
307 } else if (parent && ((elementName == QLatin1String("qmlclass") || elementName == QLatin1String("qmlvaluetype")
308 || elementName == QLatin1String("qmlbasictype")))) {
309 auto *qmlTypeNode = new QmlTypeNode(parent, name,
310 elementName == QLatin1String("qmlclass") ? NodeType::QmlType : NodeType::QmlValueType);
311 QString logicalModuleName = attributes.value(QLatin1String("qml-module-name")).toString();
312 if (!logicalModuleName.isEmpty())
313 m_qdb->addToQmlModule(logicalModuleName, qmlTypeNode);
314 bool abstract = false;
315 if (attributes.value(QLatin1String("abstract")) == QLatin1String("true"))
316 abstract = true;
317 qmlTypeNode->setAbstract(abstract);
318 if (attributes.value(QLatin1String("singleton")) == QLatin1String("true"))
319 qmlTypeNode->setSingleton();
320 else if (attributes.value(QLatin1String("uncreatable")) == QLatin1String("true"))
321 qmlTypeNode->setUncreatable();
322 QString qmlFullBaseName = attributes.value(QLatin1String("qml-base-type")).toString();
323 if (!qmlFullBaseName.isEmpty()) {
324 qmlTypeNode->setQmlBaseName(qmlFullBaseName);
325 }
326 if (attributes.hasAttribute(QLatin1String("location")))
327 name = attributes.value("location").toString();
328 if (!indexUrl.isEmpty())
329 location = Location(indexUrl + QLatin1Char('/') + name);
330 else if (!indexUrl.isNull())
331 location = Location(name);
332 node = qmlTypeNode;
333 } else if (parent && elementName == QLatin1String("qmlproperty")) {
334 // Find the associated property group, if defined.
335 QString propertyGroup = attributes.value("inpropertygroup").toString();
336
337 if (attributes.value("propertygroup") == "true") {
338 // A node representing a property group defines the name of the group.
339 propertyGroup = attributes.value("fullname").toString();
340 } else {
341 QString type = attributes.value(QLatin1String("type")).toString();
342 bool attached = false;
343 if (attributes.value(QLatin1String("attached")) == QLatin1String("true"))
344 attached = true;
345 bool readonly = false;
346 if (attributes.value(QLatin1String("writable")) == QLatin1String("false"))
347 readonly = true;
348 auto *qmlPropertyNode = new QmlPropertyNode(parent, name, std::move(type), attached);
349 qmlPropertyNode->markReadOnly(readonly);
350 if (attributes.value(QLatin1String("required")) == QLatin1String("true"))
351 qmlPropertyNode->setRequired();
352
353 node = qmlPropertyNode;
354 }
355
356 if (!propertyGroup.isEmpty()) {
357 // Handle the relevant property group by obtaining or creating a
358 // shared comment node.
359 SharedCommentNode *scn = state.sharedDocNodes.value(propertyGroup);
360 if (!scn) {
361 scn = new SharedCommentNode(static_cast<QmlTypeNode *>(parent), 0, propertyGroup.split(".").last());
362 state.sharedDocNodes[propertyGroup] = scn;
363 }
364 if (node) {
365 // Regular properties are appended to the shared comment node.
366 scn->append(node);
367 } else {
368 node = scn;
369 hasReadChildren = true;
370 }
371 }
372 } else if (elementName == QLatin1String("group")) {
373 auto *collectionNode = m_qdb->addGroup(name);
374 collectionNode->setTitle(attributes.value(QLatin1String("title")).toString());
375 collectionNode->setSubtitle(attributes.value(QLatin1String("subtitle")).toString());
376 if (attributes.value(QLatin1String("seen")) == QLatin1String("true"))
377 collectionNode->markSeen();
378 node = collectionNode;
379 } else if (elementName == QLatin1String("module")) {
380 auto *collectionNode = m_qdb->addModule(name);
381 collectionNode->setTitle(attributes.value(QLatin1String("title")).toString());
382 collectionNode->setSubtitle(attributes.value(QLatin1String("subtitle")).toString());
383 if (attributes.value(QLatin1String("seen")) == QLatin1String("true"))
384 collectionNode->markSeen();
385 node = collectionNode;
386 } else if (elementName == QLatin1String("concept")) {
387 auto *collectionNode = m_qdb->addConcept(name);
388 collectionNode->setTitle(attributes.value(QLatin1String("title")).toString());
389 collectionNode->setSubtitle(attributes.value(QLatin1String("subtitle")).toString());
390 if (attributes.value(QLatin1String("seen")) == QLatin1String("true"))
391 collectionNode->markSeen();
392 node = collectionNode;
393 } else if (elementName == QLatin1String("qmlmodule")) {
394 auto *collectionNode = m_qdb->addQmlModule(name);
395 const QStringList info = QStringList()
396 << name
397 << QString(attributes.value(QLatin1String("qml-module-version")).toString());
398 collectionNode->setLogicalModuleInfo(info);
399 collectionNode->setTitle(attributes.value(QLatin1String("title")).toString());
400 collectionNode->setSubtitle(attributes.value(QLatin1String("subtitle")).toString());
401 if (attributes.value(QLatin1String("seen")) == QLatin1String("true"))
402 collectionNode->markSeen();
403 node = collectionNode;
404 } else if (elementName == QLatin1String("page")) {
405 QDocAttr subtype = QDocAttrNone;
406 QString attr = attributes.value(QLatin1String("subtype")).toString();
407 if (attr == QLatin1String("attribution")) {
408 subtype = QDocAttrAttribution;
409 } else if (attr == QLatin1String("example")) {
410 subtype = QDocAttrExample;
411 } else if (attr == QLatin1String("file")) {
412 subtype = QDocAttrFile;
413 } else if (attr == QLatin1String("image")) {
414 subtype = QDocAttrImage;
415 } else if (attr == QLatin1String("page")) {
416 subtype = QDocAttrDocument;
417 } else if (attr == QLatin1String("externalpage")) {
418 subtype = QDocAttrExternalPage;
419 } else
420 goto done;
421
422 if (current->isExample()) {
423 auto *exampleNode = static_cast<ExampleNode *>(current);
424 if (subtype == QDocAttrFile) {
425 exampleNode->appendFile(name);
426 goto done;
427 } else if (subtype == QDocAttrImage) {
428 exampleNode->appendImage(name);
429 goto done;
430 }
431 } else if (parent) {
432 PageNode *pageNode = nullptr;
433 if (subtype == QDocAttrExample)
434 pageNode = new ExampleNode(parent, name);
435 else if (subtype == QDocAttrExternalPage)
436 pageNode = new ExternalPageNode(parent, name);
437 else {
438 pageNode = new PageNode(parent, name);
439 if (subtype == QDocAttrAttribution) pageNode->markAttribution();
440 }
441
442 pageNode->setTitle(attributes.value(QLatin1String("title")).toString());
443
444 if (attributes.hasAttribute(QLatin1String("location")))
445 name = attributes.value(QLatin1String("location")).toString();
446
447 if (!indexUrl.isEmpty())
448 location = Location(indexUrl + QLatin1Char('/') + name);
449 else if (!indexUrl.isNull())
450 location = Location(name);
451
452 node = pageNode;
453 }
454 } else if (parent && (elementName == QLatin1String("enum") || elementName == QLatin1String("qmlenum"))) {
455 EnumNode *enumNode;
456 if (elementName == QLatin1String("enum"))
457 enumNode = new EnumNode(parent, name, attributes.hasAttribute("scoped"));
458 else
459 enumNode = new QmlEnumNode(parent, name);
460
461 if (!indexUrl.isEmpty())
462 location = Location(indexUrl + QLatin1Char('/') + parent->name().toLower() + ".html");
463 else if (!indexUrl.isNull())
464 location = Location(parent->name().toLower() + ".html");
465
466 if (attributes.value("anonymous") == "true")
467 enumNode->setAnonymous(true);
468
469 while (reader.readNextStartElement()) {
470 QXmlStreamAttributes childAttributes = reader.attributes();
471 if (reader.name() == QLatin1String("value")) {
472 EnumItem item(childAttributes.value(QLatin1String("name")).toString(),
473 childAttributes.value(QLatin1String("value")).toString(),
474 childAttributes.value(QLatin1String("since")).toString()
475 );
476 enumNode->addItem(item);
477 } else if (reader.name() == QLatin1String("keyword")) {
478 insertTarget(TargetRec::Keyword, childAttributes, enumNode);
479 } else if (reader.name() == QLatin1String("target")) {
480 insertTarget(TargetRec::Target, childAttributes, enumNode);
481 }
482 reader.skipCurrentElement();
483 }
484
485 node = enumNode;
486
487 hasReadChildren = true;
488 } else if (parent && elementName == QLatin1String("typedef")) {
489 TypedefNode *typedefNode;
490 if (attributes.hasAttribute("aliasedtype"))
491 typedefNode = new TypeAliasNode(parent, name, attributes.value(QLatin1String("aliasedtype")).toString());
492 else
493 typedefNode = new TypedefNode(parent, name);
494
495 // Associate the typedef with an enum, if specified.
496 if (attributes.hasAttribute("enum")) {
497 auto path = attributes.value(QLatin1String("enum")).toString();
498 const Node *enode = m_qdb->findNodeForTarget(path, typedefNode);
499 if (enode && enode->isEnumType()) {
500 const EnumNode *n = static_cast<const EnumNode *>(enode);
501 const_cast<EnumNode *>(n)->setFlagsType(typedefNode);
502 }
503 }
504 node = typedefNode;
505
506 if (!indexUrl.isEmpty())
507 location = Location(indexUrl + QLatin1Char('/') + parent->name().toLower() + ".html");
508 else if (!indexUrl.isNull())
509 location = Location(parent->name().toLower() + ".html");
510 } else if (parent && elementName == QLatin1String("property")) {
511 auto *propNode = new PropertyNode(parent, name);
512 node = propNode;
513 if (attributes.value(QLatin1String("bindable")) == QLatin1String("true"))
514 propNode->setPropertyType(PropertyNode::PropertyType::BindableProperty);
515
516 propNode->setWritable(attributes.value(QLatin1String("writable")) != QLatin1String("false"));
517 propNode->setDataType(attributes.value(QLatin1String("dataType")).toString());
518
519 if (attributes.value(QLatin1String("constant")) == QLatin1String("true"))
520 propNode->setConstant();
521
522 if (!indexUrl.isEmpty())
523 location = Location(indexUrl + QLatin1Char('/') + parent->name().toLower() + ".html");
524 else if (!indexUrl.isNull())
525 location = Location(parent->name().toLower() + ".html");
526
527 } else if (parent && elementName == QLatin1String("function")) {
528 QString t = attributes.value(QLatin1String("meta")).toString();
529 bool attached = false;
530 Metaness metaness = Metaness::Plain;
531 if (!t.isEmpty())
532 metaness = FunctionNode::getMetaness(t);
533 if (attributes.value(QLatin1String("attached")) == QLatin1String("true"))
534 attached = true;
535 auto *fn = new FunctionNode(metaness, parent, name, attached);
536
537 fn->setReturnType(attributes.value(QLatin1String("type")).toString());
538
539 const auto &declaredTypeAttr = attributes.value(QLatin1String("declaredtype"));
540 if (!declaredTypeAttr.isEmpty())
541 fn->setDeclaredReturnType(declaredTypeAttr.toString());
542
543 if (fn->isCppNode()) {
544 fn->setVirtualness(attributes.value(QLatin1String("virtual")).toString());
545 fn->setConst(attributes.value(QLatin1String("const")) == QLatin1String("true"));
546 fn->setStatic(attributes.value(QLatin1String("static")) == QLatin1String("true"));
547 fn->setFinal(attributes.value(QLatin1String("final")) == QLatin1String("true"));
548 fn->setOverride(attributes.value(QLatin1String("override")) == QLatin1String("true"));
549
550 if (attributes.value(QLatin1String("explicit")) == QLatin1String("true"))
551 fn->markExplicit();
552
553 if (attributes.value(QLatin1String("constexpr")) == QLatin1String("true"))
554 fn->markConstexpr();
555
556 if (attributes.value(QLatin1String("explicitly-defaulted")) == QLatin1String("true"))
557 fn->markExplicitlyDefaulted();
558
559 if (attributes.value(QLatin1String("deleted")) == QLatin1String("true"))
560 fn->markDeletedAsWritten();
561 if (attributes.value(QLatin1String("hidden-friend")) == QLatin1String("true"))
562 fn->setHiddenFriend(true);
563
564 if (attributes.value(QLatin1String("noexcept")) == QLatin1String("true")) {
565 fn->markNoexcept(attributes.value("noexcept_expression").toString());
566 }
567
568 if (attributes.hasAttribute(QLatin1String("trailing_requires")))
569 fn->setTrailingRequiresClause(attributes.value(QLatin1String("trailing_requires")).toString());
570
571 qsizetype refness = attributes.value(QLatin1String("refness")).toUInt();
572 if (refness == 1)
573 fn->setRef(true);
574 else if (refness == 2)
575 fn->setRefRef(true);
576 /*
577 Theoretically, this should ensure that each function
578 node receives the same overload number and overload
579 flag it was written with, and it should be unnecessary
580 to call normalizeOverloads() for index nodes.
581 */
582 if (attributes.value(QLatin1String("overload")) == QLatin1String("true"))
583 fn->setOverloadNumber(attributes.value(QLatin1String("overload-number")).toUInt());
584 else
585 fn->setOverloadNumber(0);
586 }
587
588 /*
589 Note: The "signature" attribute was written to the
590 index file, but it is not read back in. That is ok
591 because we reconstruct the parameter list and the
592 return type, from which the signature was built in
593 the first place and from which it can be rebuilt.
594 */
595 while (reader.readNextStartElement()) {
596 QXmlStreamAttributes childAttributes = reader.attributes();
597 if (reader.name() == QLatin1String("parameter")) {
598 QString type = childAttributes.value(QLatin1String("type")).toString();
599 QString name = childAttributes.value(QLatin1String("name")).toString();
600 QString default_ = childAttributes.value(QLatin1String("default")).toString();
601 fn->parameters().append(type, name, default_);
602 } else if (reader.name() == QLatin1String("keyword")) {
603 insertTarget(TargetRec::Keyword, childAttributes, fn);
604 } else if (reader.name() == QLatin1String("target")) {
605 insertTarget(TargetRec::Target, childAttributes, fn);
606 }
607 reader.skipCurrentElement();
608 }
609
610 node = fn;
611 if (!indexUrl.isEmpty())
612 location = Location(indexUrl + QLatin1Char('/') + parent->name().toLower() + ".html");
613 else if (!indexUrl.isNull())
614 location = Location(parent->name().toLower() + ".html");
615
616 hasReadChildren = true;
617 } else if (parent && elementName == QLatin1String("variable")) {
618 auto *varNode = new VariableNode(parent, name);
619 varNode->setLeftType(attributes.value("type").toString());
620 varNode->setStatic((attributes.value("static").toString() == "true") ? true : false);
621 node = varNode;
622 if (!indexUrl.isEmpty())
623 location = Location(indexUrl + QLatin1Char('/') + parent->name().toLower() + ".html");
624 else if (!indexUrl.isNull())
625 location = Location(parent->name().toLower() + ".html");
626 } else if (elementName == QLatin1String("keyword")) {
627 insertTarget(TargetRec::Keyword, attributes, current);
628 goto done;
629 } else if (elementName == QLatin1String("target")) {
630 insertTarget(TargetRec::Target, attributes, current);
631 goto done;
632 } else if (elementName == QLatin1String("contents")) {
633 insertTarget(TargetRec::Contents, attributes, current);
634 goto done;
635 } else if (parent && elementName == QLatin1String("proxy")) {
636 node = new ProxyNode(parent, name);
637 if (!indexUrl.isEmpty())
638 location = Location(indexUrl + QLatin1Char('/') + name.toLower() + ".html");
639 else if (!indexUrl.isNull())
640 location = Location(name.toLower() + ".html");
641 } else {
642 goto done;
643 }
644
645 if (node) {
646 // Read attributes for the requisites table.
647 if (node->isCollectionNode()) {
648 auto *cn = static_cast<CollectionNode *>(node);
649 if (attributes.hasAttribute(QLatin1String("cmakepackage")))
650 cn->setCMakePackage(attributes.value(QLatin1String("cmakepackage")).toString());
651 if (attributes.hasAttribute(QLatin1String("cmakecomponent")))
652 cn->setCMakeComponent(attributes.value(QLatin1String("cmakecomponent")).toString());
653 if (attributes.hasAttribute(QLatin1String("cmaketargetitem")))
654 cn->setCMakeTargetItem(attributes.value(QLatin1String("cmaketargetitem")).toString());
655 if (attributes.hasAttribute(QLatin1String("qtvariable")))
656 cn->setQtVariable(attributes.value(QLatin1String("qtvariable")).toString());
657 }
658 if (node->isAggregate() && attributes.hasAttribute(QLatin1String("includefile"))) {
659 auto *agg = static_cast<Aggregate *>(node);
660 agg->setIncludeFile(attributes.value(QLatin1String("includefile")).toString());
661 }
662
663 if (!href.isEmpty()) {
664 node->setUrl(href);
665 // Include the index URL if it exists
666 if (!node->isExternalPage() && !indexUrl.isEmpty())
667 node->setUrl(indexUrl + QLatin1Char('/') + href);
668 }
669
670 const QString access = attributes.value(QLatin1String("access")).toString();
671 if (access == "protected")
672 node->setAccess(Access::Protected);
673 else if (access == "private")
674 node->setAccess(Access::Private);
675 else
676 node->setAccess(Access::Public);
677
678 if (attributes.hasAttribute(QLatin1String("related"))) {
680 state.relatedNodes << node;
681 }
682
683 if (attributes.hasAttribute(QLatin1String("relatedto"))) {
684 const auto targets = attributes.value(QLatin1String("relatedto")).split(u',');
685 for (const auto &target : targets)
686 node->tree()->addExternalRelates(node, target.toString());
687 }
688
689 if (attributes.hasAttribute(QLatin1String("threadsafety"))) {
690 QString threadSafety = attributes.value(QLatin1String("threadsafety")).toString();
691 if (threadSafety == QLatin1String("non-reentrant"))
693 else if (threadSafety == QLatin1String("reentrant"))
695 else if (threadSafety == QLatin1String("thread safe"))
697 else
699 } else
701
702 const QString category = attributes.value(QLatin1String("comparison_category")).toString();
703 node->setComparisonCategory(comparisonCategoryFromString(category.toStdString()));
704
705 QString status = attributes.value(QLatin1String("status")).toString();
706 // TODO: "obsolete" is kept for backward compatibility, remove in the near future
707 if (status == QLatin1String("obsolete") || status == QLatin1String("deprecated"))
709 else if (status == QLatin1String("preliminary"))
711 else if (status == QLatin1String("internal"))
713 else if (status == QLatin1String("internal-auto"))
715 else if (status == QLatin1String("ignored"))
717 else
719
720 QString physicalModuleName = attributes.value(QLatin1String("module")).toString();
721 if (!physicalModuleName.isEmpty())
722 m_qdb->addToModule(physicalModuleName, node);
723
724 QString since = attributes.value(QLatin1String("since")).toString();
725 if (!since.isEmpty()) {
726 node->setSince(since);
727 }
728
729 if (attributes.hasAttribute(QLatin1String("documented"))) {
730 if (attributes.value(QLatin1String("documented")) == QLatin1String("true"))
731 node->setHadDoc();
732 }
733
734 QString groupsAttr = attributes.value(QLatin1String("groups")).toString();
735 if (!groupsAttr.isEmpty()) {
736 const QStringList groupNames = groupsAttr.split(QLatin1Char(','));
737 for (const auto &group : groupNames) {
738 m_qdb->addToGroup(group, node);
739 }
740 }
741
742 // Create some content for the node.
743 QSet<QString> emptySet;
744 Location t(filePath);
745 if (!filePath.isEmpty()) {
746 t.setLineNo(lineNo);
747 node->setLocation(t);
748 location = t;
749 }
750 Doc doc(location, location, QString(), emptySet, emptySet); // placeholder
751 if (attributes.value(QLatin1String("auto-generated")) == QLatin1String("true"))
753 node->setDoc(doc);
754 node->setIndexNodeFlag(); // Important: This node came from an index file.
755 QString briefAttr = attributes.value(QLatin1String("brief")).toString();
756 if (!briefAttr.isEmpty()) {
757 node->setReconstitutedBrief(briefAttr);
758 }
759
760 if (const auto sortKey = attributes.value(QLatin1String("sortkey")).toString(); !sortKey.isEmpty()) {
762 if (auto *metaMap = node->doc().metaTagMap())
763 metaMap->insert("sortkey", sortKey);
764 }
765 if (!hasReadChildren) {
766 bool useParent = (elementName == QLatin1String("namespace") && name.isEmpty());
767 while (reader.readNextStartElement()) {
768 if (useParent)
769 readIndexSection(reader, parent, indexUrl, state);
770 else
771 readIndexSection(reader, node, indexUrl, state);
772 }
773 }
774 }
775
776done:
777 while (!reader.isEndElement()) {
778 if (reader.readNext() == QXmlStreamReader::Invalid) {
779 break;
780 }
781 }
782}
783
784void QDocIndexFiles::insertTarget(TargetRec::TargetType type,
785 const QXmlStreamAttributes &attributes, Node *node)
786{
787 int priority;
788 switch (type) {
790 priority = 1;
791 break;
793 priority = 2;
794 break;
796 priority = 3;
797 break;
798 default:
799 return;
800 }
801
802 QString name = attributes.value(QLatin1String("name")).toString();
803 QString title = attributes.value(QLatin1String("title")).toString();
804 m_qdb->insertTarget(name, title, type, node, priority);
805}
806
807/*!
808 This function tries to resolve class inheritance recorded in \a state
809 immediately after its index file is read. It is not always possible to
810 resolve a class inheritance at this point, because the base
811 class might be in an index file that hasn't been read yet, or
812 it might be in one of the header files that will be read for
813 the current module. These cases will be resolved after all
814 the index files and header and source files have been read,
815 just prior to beginning the generate phase for the current
816 module.
817
818 I don't think this is completely correct because it always
819 sets the access to public.
820 */
821void QDocIndexFiles::resolveIndex(ReadState &state)
822{
823 for (const auto &pair : std::as_const(state.bases)) {
824 const QStringList bases = pair.second.split(QLatin1Char(','));
825 for (const auto &base : bases) {
826 QStringList basePath = base.split(QString("::"));
827 Node *n = m_qdb->findClassNode(basePath);
828 if (n)
829 pair.first->addResolvedBaseClass(Access::Public, static_cast<ClassNode *>(n));
830 else
831 pair.first->addUnresolvedBaseClass(Access::Public, basePath);
832 }
833 }
834}
835
836static QString getAccessString(Access t)
837{
838
839 switch (t) {
840 case Access::Public:
841 return QLatin1String("public");
842 case Access::Protected:
843 return QLatin1String("protected");
844 case Access::Private:
845 return QLatin1String("private");
846 default:
847 break;
848 }
849 return QLatin1String("public");
850}
851
853{
854 switch (t) {
856 return QLatin1String("deprecated");
858 return QLatin1String("preliminary");
859 case Status::Active:
860 return QLatin1String("active");
861 case Status::Internal:
862 return QLatin1String("internal");
864 return QLatin1String("internal-auto");
866 return QLatin1String("ignored");
867 default:
868 break;
869 }
870 return QLatin1String("active");
871}
872
874{
875 switch (t) {
877 return QLatin1String("non-reentrant");
878 case Node::Reentrant:
879 return QLatin1String("reentrant");
880 case Node::ThreadSafe:
881 return QLatin1String("thread safe");
883 default:
884 break;
885 }
886 return QLatin1String("unspecified");
887}
888
889/*!
890 Returns the index of \a node in \a state's related non-member list,
891 adding it if necessary. The numbering lasts for this serialization
892 operation.
893*/
894int QDocIndexFiles::indexForNode(Node *node, WriteState &state)
895{
896 qsizetype i = state.relatedNodes.indexOf(node);
897 if (i == -1) {
898 i = state.relatedNodes.size();
899 state.relatedNodes << node;
900 }
901 return i;
902}
903
904/*!
905 Write an attribute to the current element using the \a writer for the
906 attribute with the given \a name if the \a value is not an empty string.
907*/
908static void writeNonEmpty(QXmlStreamWriter &writer, const QString &name, const QString &value)
909{
910 if (!value.isEmpty())
911 writer.writeAttribute(name, value);
912}
913
914/*!
915 Writes the \c relatedto attribute for \a node using the \a writer,
916 if \a node is related to aggregates in other modules with the
917 \c relates command. The value is a comma-separated list of the
918 qualified names of those aggregates.
919
920 \sa Tree::addExternalRelates()
921*/
922static void writeExternalRelates(QXmlStreamWriter &writer, Node *node)
923{
924 QStringList targets = node->tree()->externalRelates().values(node);
925 targets.sort();
926 writeNonEmpty(writer, "relatedto", targets.join(u','));
927}
928
929/*!
930 Adopts the related non-member node identified by \a index to the
931 parent \a adoptiveParent. Looks up the index in the current import's
932 \a state. Returns \c true if successful.
933*/
934bool QDocIndexFiles::adoptRelatedNode(Aggregate *adoptiveParent, int index, ReadState &state)
935{
936 Node *related = state.relatedNodes.value(index);
937
938 if (adoptiveParent && related) {
939 adoptiveParent->adoptChild(related);
940 return true;
941 }
942
943 return false;
944}
945
946/*!
947 Write canonicalized versions of \\target and \\keyword identifiers
948 that appear in the documentation of \a node into the index using
949 \a writer, so that they can be used as link targets in external
950 documentation sets.
951*/
952void QDocIndexFiles::writeTargets(QXmlStreamWriter &writer, Node *node)
953{
954 if (node->doc().hasTargets()) {
955 for (const Atom *target : std::as_const(node->doc().targets())) {
956 const QString &title = target->string();
957 const QString name = target->count() >= 2 ? target->string(1)
958 : TextUtils::asAsciiPrintable(title);
959 writer.writeStartElement("target");
960 writer.writeAttribute("name", node->isExternalPage() ? title : name);
961 if (name != title)
962 writer.writeAttribute("title", title);
963 writer.writeEndElement(); // target
964 }
965 }
966 if (node->doc().hasKeywords()) {
967 for (const Atom *keyword : std::as_const(node->doc().keywords())) {
968 const QString &title = keyword->string();
969 const QString &name{TextUtils::asAsciiPrintable(title)};
970 writer.writeStartElement("keyword");
971 writer.writeAttribute("name", name);
972 if (name != title)
973 writer.writeAttribute("title", title);
974 writer.writeEndElement(); // keyword
975 }
976 }
977}
978
979/*!
980 Generate the index section with the given \a writer for the \a node
981 specified, returning true if an element was written, and returning
982 false if an element is not written.
983
984 The \a context supplies document locations and, for inline example entries,
985 example-file locations, along with inclusion and source-location policy.
986 The \a state numbers related nodes across the current output operation.
987 If supplied, \a post extends the section before it closes.
988
989 \note Function nodes are processed in generateFunctionSection()
990 */
991bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter &writer, Node *node,
992 const IndexSerializationContext &context, WriteState &state,
993 IndexSectionWriter *post)
994{
995 Q_ASSERT(context.documentLocation);
996 /*
997 Don't include index nodes in a new index file.
998 */
999 if (node->isIndexNode())
1000 return false;
1001
1002 QString nodeName;
1003 QString logicalModuleName;
1004 QString logicalModuleVersion;
1005 QString qmlFullBaseName;
1006 QString baseNameAttr;
1007 QString moduleNameAttr;
1008 QString moduleVerAttr;
1009
1010 switch (node->nodeType()) {
1012 nodeName = "namespace";
1013 break;
1014 case NodeType::Class:
1015 nodeName = "class";
1016 break;
1017 case NodeType::Struct:
1018 nodeName = "struct";
1019 break;
1020 case NodeType::Union:
1021 nodeName = "union";
1022 break;
1024 nodeName = "header";
1025 break;
1026 case NodeType::QmlEnum:
1027 nodeName = "qmlenum";
1028 break;
1029 case NodeType::QmlType:
1031 nodeName = (node->nodeType() == NodeType::QmlType) ? "qmlclass" : "qmlvaluetype";
1032 logicalModuleName = node->logicalModuleName();
1033 baseNameAttr = "qml-base-type";
1034 moduleNameAttr = "qml-module-name";
1035 moduleVerAttr = "qml-module-version";
1036 qmlFullBaseName = node->qmlFullBaseName();
1037 break;
1038 case NodeType::Page:
1039 case NodeType::Example:
1041 nodeName = "page";
1042 break;
1043 case NodeType::Group:
1044 nodeName = "group";
1045 break;
1046 case NodeType::Module:
1047 nodeName = "module";
1048 break;
1049 case NodeType::Concept:
1050 nodeName = "concept";
1051 break;
1053 nodeName = "qmlmodule";
1054 moduleNameAttr = "qml-module-name";
1055 moduleVerAttr = "qml-module-version";
1056 logicalModuleName = node->logicalModuleName();
1057 logicalModuleVersion = node->logicalModuleVersion();
1058 break;
1059 case NodeType::Enum:
1060 nodeName = "enum";
1061 break;
1063 case NodeType::Typedef:
1064 nodeName = "typedef";
1065 break;
1066 case NodeType::Property:
1067 nodeName = "property";
1068 break;
1069 case NodeType::Variable:
1070 nodeName = "variable";
1071 break;
1073 if (!node->isPropertyGroup())
1074 return false;
1075 // Add an entry for property groups so that they can be linked to
1076 nodeName = "qmlproperty";
1077 break;
1079 nodeName = "qmlproperty";
1080 break;
1081 case NodeType::Proxy:
1082 nodeName = "proxy";
1083 break;
1084 case NodeType::Function: // Now processed in generateFunctionSection()
1085 default:
1086 return false;
1087 }
1088
1089 QString objName = node->name();
1090 // Special case: only the root node should have an empty name.
1091 if (objName.isEmpty() && node != m_qdb->primaryTreeRoot())
1092 return false;
1093
1094 writer.writeStartElement(nodeName);
1095
1096 if (!node->isTextPageNode() && !node->isCollectionNode() && !node->isHeader()) {
1098 writer.writeAttribute("threadsafety", getThreadSafenessString(node->threadSafeness()));
1099 }
1100
1101 writer.writeAttribute("name", objName);
1102
1103 if (node->isPropertyGroup())
1104 writer.writeAttribute("propertygroup", "true");
1106 writer.writeAttribute("inpropertygroup", node->sharedCommentNode()->fullDocumentName());
1107
1108 // Write module and base type info for QML types
1109 if (!moduleNameAttr.isEmpty()) {
1110 if (!logicalModuleName.isEmpty())
1111 writer.writeAttribute(moduleNameAttr, logicalModuleName);
1112 if (!logicalModuleVersion.isEmpty())
1113 writer.writeAttribute(moduleVerAttr, logicalModuleVersion);
1114 }
1115 if (!baseNameAttr.isEmpty() && !qmlFullBaseName.isEmpty())
1116 writer.writeAttribute(baseNameAttr, qmlFullBaseName);
1117 else if (!baseNameAttr.isEmpty()) {
1118 const auto &qmlBase = static_cast<QmlTypeNode *>(node)->qmlBaseName();
1119 writeNonEmpty(writer, baseNameAttr, qmlBase);
1120 }
1121
1122 QString href;
1123 if (!node->isExternalPage()) {
1124 QString fullName = node->fullDocumentName();
1125 if (fullName != objName)
1126 writer.writeAttribute("fullname", fullName);
1127 href = context.documentLocation(node);
1128 } else
1129 href = node->name();
1130 if (node->isQmlNode()) {
1131 Aggregate *p = node->parent();
1132 if (p && p->isQmlType() && p->isAbstract())
1133 href.clear();
1134 }
1135 writeNonEmpty(writer, "href", href);
1136
1137 writer.writeAttribute("status", getStatusString(node->status()));
1138 if (!node->isTextPageNode() && !node->isCollectionNode() && !node->isHeader()) {
1139 writer.writeAttribute("access", getAccessString(node->access()));
1140 if (node->isAbstract())
1141 writer.writeAttribute("abstract", "true");
1142 }
1143 const Location &declLocation = node->declLocation();
1144 writeNonEmpty(writer, "location", declLocation.fileName());
1145 if (context.storeLocationInfo && !declLocation.filePath().isEmpty()) {
1146 writer.writeAttribute("filepath", declLocation.filePath());
1147 writer.writeAttribute("lineno", QString("%1").arg(declLocation.lineNo()));
1148 }
1149
1150 if (node->isRelatedNonmember()) {
1151 writer.writeAttribute("related", QString::number(indexForNode(node, state)));
1152 writeExternalRelates(writer, node);
1153 }
1154
1155 writeNonEmpty(writer, "since", node->since());
1156
1157 if (node->hasDoc())
1158 writer.writeAttribute("documented", "true");
1159
1160 QStringList groups = m_qdb->groupNamesForNode(node);
1161 if (!groups.isEmpty())
1162 writer.writeAttribute("groups", groups.join(QLatin1Char(',')));
1163
1164 if (const auto *metamap = node->doc().metaTagMap(); metamap)
1165 if (const auto sortKey = metamap->value("sortkey"); !sortKey.isEmpty())
1166 writer.writeAttribute("sortkey", sortKey);
1167
1168 // Write attributes for the requisites table.
1169 if (node->isCollectionNode() && node->isModule()) {
1170 auto *cn = static_cast<CollectionNode *>(node);
1171 writeNonEmpty(writer, "cmakepackage", cn->cmakePackage());
1172 writeNonEmpty(writer, "cmakecomponent", cn->cmakeComponent());
1173 writeNonEmpty(writer, "cmaketargetitem", cn->cmakeTargetItem());
1174 writeNonEmpty(writer, "qtvariable", cn->qtVariable());
1175 }
1176
1177 if (node->isAggregate() && node->genus() == Genus::CPP && (!node->parent() || !node->parent()->isClassNode())) {
1178 auto *agg = static_cast<Aggregate *>(node);
1179 if (agg->includeFile())
1180 writer.writeAttribute("includefile", *agg->includeFile());
1181 }
1182
1183 QString brief = node->doc().trimmedBriefText(node->name()).toString();
1184 switch (node->nodeType()) {
1185 case NodeType::Class:
1186 case NodeType::Struct:
1187 case NodeType::Union: {
1188 // Classes contain information about their base classes.
1189 const auto *classNode = static_cast<const ClassNode *>(node);
1190 const QList<RelatedClass> &bases = classNode->baseClasses();
1191 QSet<QString> baseStrings;
1192 for (const auto &related : bases) {
1193 ClassNode *n = related.m_node;
1194 if (n)
1195 baseStrings.insert(n->fullName());
1196 else if (!related.m_path.isEmpty())
1197 baseStrings.insert(related.m_path.join(QLatin1String("::")));
1198 }
1199 if (!baseStrings.isEmpty()) {
1200 QStringList baseStringsAsList = baseStrings.values();
1201 baseStringsAsList.sort();
1202 writer.writeAttribute("bases", baseStringsAsList.join(QLatin1Char(',')));
1203 }
1204 writeNonEmpty(writer, "module", node->physicalModuleName());
1205 writeNonEmpty(writer, "brief", brief);
1206 if (auto category = node->comparisonCategory(); category != ComparisonCategory::None)
1207 writer.writeAttribute("comparison_category", comparisonCategoryAsString(category));
1208 } break;
1209 case NodeType::HeaderFile: {
1210 const auto *headerNode = static_cast<const HeaderNode *>(node);
1211 writeNonEmpty(writer, "module", headerNode->physicalModuleName());
1212 writeNonEmpty(writer, "brief", brief);
1213 writer.writeAttribute("title", headerNode->title());
1214 writer.writeAttribute("fulltitle", headerNode->fullTitle());
1215 writer.writeAttribute("subtitle", headerNode->subtitle());
1216 } break;
1217 case NodeType::Namespace: {
1218 const auto *namespaceNode = static_cast<const NamespaceNode *>(node);
1219 writeNonEmpty(writer, "module", namespaceNode->physicalModuleName());
1220 writeNonEmpty(writer, "brief", brief);
1221 writeNonEmpty(writer, "whereDocumented", namespaceNode->whereDocumented());
1222 } break;
1224 case NodeType::QmlType: {
1225 const auto *qmlTypeNode = static_cast<const QmlTypeNode *>(node);
1226 writeNonEmpty(writer, "title", qmlTypeNode->title());
1227 writeNonEmpty(writer, "fulltitle", qmlTypeNode->fullTitle());
1228 writeNonEmpty(writer, "subtitle", qmlTypeNode->subtitle());
1229 if (qmlTypeNode->isSingleton())
1230 writer.writeAttribute("singleton", "true");
1231 if (qmlTypeNode->isUncreatable())
1232 writer.writeAttribute("uncreatable", "true");
1233 writeNonEmpty(writer, "brief", brief);
1234 if (ClassNode *cn = qmlTypeNode->classNode()) {
1235 writer.writeAttribute("class", cn->fullDocumentName());
1236 }
1237 } break;
1238 case NodeType::Page:
1239 case NodeType::Example:
1241 if (node->isExample())
1242 writer.writeAttribute("subtype", "example");
1243 else if (node->isExternalPage())
1244 writer.writeAttribute("subtype", "externalpage");
1245 else
1246 writer.writeAttribute("subtype", (static_cast<PageNode*>(node)->isAttribution() ? "attribution" : "page"));
1247
1248 const auto *pageNode = static_cast<const PageNode *>(node);
1249 writeNonEmpty(writer, "title", pageNode->title());
1250 writeNonEmpty(writer, "fulltitle", pageNode->fullTitle());
1251 writeNonEmpty(writer, "subtitle", pageNode->subtitle());
1252 writeNonEmpty(writer, "brief", brief);
1253 } break;
1254 case NodeType::Group:
1255 case NodeType::Module:
1257 case NodeType::Concept: {
1258 const auto *collectionNode = static_cast<const CollectionNode *>(node);
1259 writer.writeAttribute("seen", collectionNode->wasSeen() ? "true" : "false");
1260 writeNonEmpty(writer, "title", collectionNode->title());
1261 writeNonEmpty(writer, "subtitle", collectionNode->subtitle());
1262 writeNonEmpty(writer, "module", collectionNode->physicalModuleName());
1263 writeNonEmpty(writer, "brief", brief);
1264 } break;
1265 case NodeType::QmlProperty: {
1266 auto *qmlPropertyNode = static_cast<QmlPropertyNode *>(node);
1267 writer.writeAttribute("type", qmlPropertyNode->dataType());
1268 writer.writeAttribute("attached", qmlPropertyNode->isAttached() ? "true" : "false");
1269 writer.writeAttribute("writable", qmlPropertyNode->isReadOnly() ? "false" : "true");
1270 if (qmlPropertyNode->isRequired())
1271 writer.writeAttribute("required", "true");
1272 writeNonEmpty(writer, "brief", brief);
1273 } break;
1274 case NodeType::Property: {
1275 const auto *propertyNode = static_cast<const PropertyNode *>(node);
1276
1277 if (propertyNode->propertyType() == PropertyNode::PropertyType::BindableProperty)
1278 writer.writeAttribute("bindable", "true");
1279
1280 if (!propertyNode->isWritable())
1281 writer.writeAttribute("writable", "false");
1282
1283 if (propertyNode->isConstant())
1284 writer.writeAttribute("constant", "true");
1285
1286 writer.writeAttribute("dataType", propertyNode->dataType());
1287
1288 writeNonEmpty(writer, "brief", brief);
1289 // Property access function names
1290 for (qsizetype i{0}; i < (qsizetype)PropertyNode::FunctionRole::NumFunctionRoles; ++i) {
1291 auto role{(PropertyNode::FunctionRole)i};
1292 for (const auto *fnNode : propertyNode->functions(role)) {
1293 writer.writeStartElement(PropertyNode::roleName(role));
1294 writer.writeAttribute("name", fnNode->name());
1295 writer.writeEndElement();
1296 }
1297 }
1298 } break;
1299 case NodeType::Variable: {
1300 const auto *variableNode = static_cast<const VariableNode *>(node);
1301 writer.writeAttribute("type", variableNode->dataType());
1302 writer.writeAttribute("static", variableNode->isStatic() ? "true" : "false");
1303 writeNonEmpty(writer, "brief", brief);
1304 } break;
1305 case NodeType::QmlEnum:
1306 case NodeType::Enum: {
1307 const auto *enumNode = static_cast<const EnumNode *>(node);
1308 if (enumNode->isScoped())
1309 writer.writeAttribute("scoped", "true");
1310 if (enumNode->flagsType())
1311 writer.writeAttribute("typedef", enumNode->flagsType()->fullDocumentName());
1312 if (enumNode->isAnonymous())
1313 writer.writeAttribute("anonymous", "true");
1314 const auto &items = enumNode->items();
1315 for (const auto &item : items) {
1316 writer.writeStartElement("value");
1317 writer.writeAttribute("name", item.name());
1318 if (node->isEnumType(Genus::CPP))
1319 writer.writeAttribute("value", item.value());
1320 writeNonEmpty(writer, "since", item.since());
1321 writer.writeEndElement(); // value
1322 }
1323 } break;
1324 case NodeType::Typedef: {
1325 const auto *typedefNode = static_cast<const TypedefNode *>(node);
1326 if (typedefNode->associatedEnum())
1327 writer.writeAttribute("enum", typedefNode->associatedEnum()->fullDocumentName());
1328 } break;
1330 writer.writeAttribute("aliasedtype", static_cast<const TypeAliasNode *>(node)->aliasedType());
1331 break;
1332 case NodeType::Function: // Now processed in generateFunctionSection()
1333 default:
1334 break;
1335 }
1336
1337 writeTargets(writer, node);
1338
1339 /*
1340 Some nodes have a table of contents. For these, we close
1341 the opening tag, create sub-elements for the items in the
1342 table of contents, and then add a closing tag for the
1343 element. Elements for all other nodes are closed in the
1344 opening tag.
1345 */
1346 if (node->isPageNode() || node->isCollectionNode()) {
1348 for (int i = 0; i < node->doc().tableOfContents().size(); ++i) {
1349 Atom *item = node->doc().tableOfContents()[i];
1350 int level = node->doc().tableOfContentsLevels()[i];
1351 QString title = Text::sectionHeading(item).toString();
1352 writer.writeStartElement("contents");
1353 writer.writeAttribute("name", Tree::refForAtom(item));
1354 writer.writeAttribute("title", title);
1355 writer.writeAttribute("level", QString::number(level));
1356 writer.writeEndElement(); // contents
1357 }
1358 }
1359 }
1360 // Some callers serialize example files and images separately.
1361 if (node->isExample()
1363 Q_ASSERT(context.exampleFileLocation);
1364 const auto *exampleNode = static_cast<const ExampleNode *>(node);
1365 const auto &files = exampleNode->files();
1366 const auto &images = exampleNode->images();
1367 for (const QString &file : files) {
1368 writer.writeStartElement("page");
1369 writer.writeAttribute("name", file);
1370 writer.writeAttribute("href", context.exampleFileLocation(file));
1371 writer.writeAttribute("status", "active");
1372 writer.writeAttribute("subtype", "file");
1373 writer.writeAttribute("title", "");
1374 writer.writeAttribute("fulltitle", Utilities::exampleFileTitle(file, Utilities::ExampleFileKind::File));
1375 writer.writeAttribute("subtitle", file);
1376 writer.writeEndElement(); // page
1377 }
1378 for (const QString &file : images) {
1379 writer.writeStartElement("page");
1380 writer.writeAttribute("name", file);
1381 writer.writeAttribute("href", context.exampleFileLocation(file));
1382 writer.writeAttribute("status", "active");
1383 writer.writeAttribute("subtype", "image");
1384 writer.writeAttribute("title", "");
1385 writer.writeAttribute("fulltitle", Utilities::exampleFileTitle(file, Utilities::ExampleFileKind::Image));
1386 writer.writeAttribute("subtitle", file);
1387 writer.writeEndElement(); // page
1388 }
1389 }
1390 // Append to the section if the callback object was set
1391 if (post)
1392 post->append(writer, node);
1393
1394 return true;
1395}
1396
1397/*!
1398 Writes a <function> element for \a fn using \a writer. The \a context
1399 supplies its href and inclusion policy, \a state numbers related nodes,
1400 and \a post, if supplied, extends the element before it closes.
1401 */
1402void QDocIndexFiles::generateFunctionSection(QXmlStreamWriter &writer, FunctionNode *fn,
1403 const IndexSerializationContext &context, WriteState &state,
1404 IndexSectionWriter *post)
1405{
1406 const NodeContext nodeContext = fn->createContext();
1407 if (!InclusionFilter::isPubliclyVisible(context.inclusionPolicy, nodeContext))
1408 return;
1409
1410 const QString objName = fn->name();
1411 writer.writeStartElement("function");
1412 writer.writeAttribute("name", objName);
1413
1414 const QString fullName = fn->fullDocumentName();
1415 if (fullName != objName)
1416 writer.writeAttribute("fullname", fullName);
1417 const QString href = context.documentLocation(fn);
1418 writeNonEmpty(writer, "href", href);
1420 writer.writeAttribute("threadsafety", getThreadSafenessString(fn->threadSafeness()));
1421 writer.writeAttribute("status", getStatusString(fn->status()));
1422 writer.writeAttribute("access", getAccessString(fn->access()));
1423
1424 const Location &declLocation = fn->declLocation();
1425 writeNonEmpty(writer, "location", declLocation.fileName());
1426 if (context.storeLocationInfo && !declLocation.filePath().isEmpty()) {
1427 writer.writeAttribute("filepath", declLocation.filePath());
1428 writer.writeAttribute("lineno", QString("%1").arg(declLocation.lineNo()));
1429 }
1430
1431 if (fn->hasDoc())
1432 writer.writeAttribute("documented", "true");
1433 if (fn->hasDoc() && fn->doc().isAutoGenerated())
1434 writer.writeAttribute("auto-generated", "true");
1435 if (fn->isRelatedNonmember()) {
1436 writer.writeAttribute("related", QString::number(indexForNode(fn, state)));
1437 writeExternalRelates(writer, fn);
1438 }
1439 writeNonEmpty(writer, "since", fn->since());
1440
1441 const QString brief = fn->doc().trimmedBriefText(fn->name()).toString();
1442 writer.writeAttribute("meta", fn->metanessString());
1443 if (fn->isCppNode()) {
1444 if (!fn->isNonvirtual())
1445 writer.writeAttribute("virtual", fn->virtualness());
1446
1447 if (fn->isConst())
1448 writer.writeAttribute("const", "true");
1449 if (fn->isStatic())
1450 writer.writeAttribute("static", "true");
1451 if (fn->isFinal())
1452 writer.writeAttribute("final", "true");
1453 if (fn->isOverride())
1454 writer.writeAttribute("override", "true");
1455 if (fn->isExplicit())
1456 writer.writeAttribute("explicit", "true");
1457 if (fn->isConstexpr())
1458 writer.writeAttribute("constexpr", "true");
1460 writer.writeAttribute("explicitly-defaulted", "true");
1462 writer.writeAttribute("deleted", "true");
1463 if (fn->isHiddenFriend())
1464 writer.writeAttribute("hidden-friend", "true");
1465
1466 if (auto noexcept_info = fn->getNoexcept()) {
1467 writer.writeAttribute("noexcept", "true");
1468 writeNonEmpty(writer, "noexcept_expression", *noexcept_info);
1469 }
1470
1471 if (const auto &trailing_requires = fn->trailingRequiresClause(); trailing_requires && !trailing_requires->isEmpty())
1472 writer.writeAttribute("trailing_requires", *trailing_requires);
1473
1474 /*
1475 This ensures that for functions that have overloads,
1476 the first function written is the one that is not an
1477 overload, and the overloads follow it immediately in
1478 the index file numbered from 1 to n.
1479 */
1480 if (fn->isOverload() && (fn->overloadNumber() > 0)) {
1481 writer.writeAttribute("overload", "true");
1482 writer.writeAttribute("overload-number", QString::number(fn->overloadNumber()));
1483 }
1484 if (fn->isRef())
1485 writer.writeAttribute("refness", QString::number(1));
1486 else if (fn->isRefRef())
1487 writer.writeAttribute("refness", QString::number(2));
1489 QStringList associatedProperties;
1490 for (const auto *node : fn->associatedProperties()) {
1491 associatedProperties << node->name();
1492 }
1493 associatedProperties.sort();
1494 writer.writeAttribute("associated-property",
1495 associatedProperties.join(QLatin1Char(',')));
1496 }
1497 } else {
1498 if (fn->isAttached())
1499 writer.writeAttribute("attached", "true");
1500 }
1501
1502 const auto &return_type = fn->returnType();
1503 if (!return_type.isEmpty())
1504 writer.writeAttribute("type", std::move(return_type));
1505
1506 const auto &declared_return_type = fn->declaredReturnType();
1507 if (declared_return_type.has_value())
1508 writer.writeAttribute("declaredtype", declared_return_type.value());
1509
1510 if (fn->isCppNode()) {
1511 writeNonEmpty(writer, "brief", brief);
1512
1513 /*
1514 Note: The "signature" attribute is written to the
1515 index file, but it is not read back in by qdoc. However,
1516 we need it for the webxml generator.
1517 */
1518 const QString signature = appendAttributesToSignature(fn);
1519 writer.writeAttribute("signature", signature);
1520
1521 QStringList groups = m_qdb->groupNamesForNode(fn);
1522 if (!groups.isEmpty())
1523 writer.writeAttribute("groups", groups.join(QLatin1Char(',')));
1524 }
1525
1526 for (int i = 0; i < fn->parameters().count(); ++i) {
1527 const Parameter &parameter = fn->parameters().at(i);
1528 writer.writeStartElement("parameter");
1529 writer.writeAttribute("type", parameter.type());
1530 writer.writeAttribute("name", parameter.name());
1531 writer.writeAttribute("default", parameter.defaultValue());
1532 writer.writeEndElement(); // parameter
1533 }
1534
1535 writeTargets(writer, fn);
1536
1537 // Append to the section if the callback object was set
1538 if (post)
1539 post->append(writer, fn);
1540
1541 writer.writeEndElement(); // function
1542}
1543
1544/*!
1545 \internal
1546
1547 Constructs the signature to be written to an index file for the function
1548 represented by FunctionNode \a fn.
1549
1550 'const' is already part of FunctionNode::signature(), which forms the basis
1551 for the signature returned by this method. The method adds, where
1552 applicable, the C++ keywords "final", "override", "= 0", or trailing
1553 requires clauses to the signature carried by the FunctionNode itself.
1554 */
1555QString QDocIndexFiles::appendAttributesToSignature(const FunctionNode *fn) const noexcept
1556{
1557 QString signature = fn->signature(Node::SignatureReturnType);
1558
1559 if (fn->isFinal())
1560 signature += " final";
1561 if (fn->isOverride())
1562 signature += " override";
1563 if (fn->isPureVirtual())
1564 signature += " = 0";
1565 if (const auto &req = fn->trailingRequiresClause(); req && !req->isEmpty())
1566 signature += " requires " + *req;
1567
1568 return signature;
1569}
1570
1571/*!
1572 Outputs a <function> element to the index for each FunctionNode in
1573 an \a aggregate, using \a writer.
1574 The \a aggregate has a function map that contains all the
1575 function nodes (a vector of overloads) indexed by function
1576 name.
1577
1578 If a function element represents an overload, it has an
1579 \c overload attribute set to \c true and an \c {overload-number}
1580 attribute set to the function's overload number.
1581
1582 The \a context supplies publication locations and inclusion policy.
1583 The \a state preserves related-node numbering across the aggregate;
1584 \a post, if supplied, extends each function element.
1585 */
1586void QDocIndexFiles::generateFunctionSections(QXmlStreamWriter &writer, Aggregate *aggregate,
1587 const IndexSerializationContext &context, WriteState &state,
1588 IndexSectionWriter *post)
1589{
1590 for (auto functions : std::as_const(aggregate->functionMap())) {
1591 std::for_each(functions.begin(), functions.end(),
1592 [this, &writer, &context, &state, post](FunctionNode *fn) {
1593 generateFunctionSection(writer, fn, context, state, post);
1594 }
1595 );
1596 }
1597}
1598
1600{
1601 auto children = aggregate->nonFunctionChildren();
1602 std::sort(children.begin(), children.end(), Node::nodeLessThan);
1603 return children;
1604}
1605
1606/*!
1607 Generates a section for \a node and recursively serializes its children
1608 using \a writer. The \a context supplies publication locations and
1609 inclusion policy. The \a state preserves related-node numbering and
1610 identifies the primary root whose traversal ends with collection and
1611 proxy sections. If supplied, \a post extends each section.
1612*/
1613void QDocIndexFiles::generateIndexSections(QXmlStreamWriter &writer, Node *node,
1614 const IndexSerializationContext &context, WriteState &state,
1615 IndexSectionWriter *post)
1616{
1617 Q_ASSERT(context.documentLocation);
1618
1619 /*
1620 Note that groups, modules, QML modules, and proxies are written
1621 after all the other nodes.
1622 */
1623 if (node->isCollectionNode() || node->isGroup() || node->isModule() ||
1625 return;
1626
1627 const NodeContext nodeContext = node->createContext();
1628 if (!InclusionFilter::isPubliclyVisible(context.inclusionPolicy, nodeContext))
1629 return;
1630
1631 if (generateIndexSection(writer, node, context, state, post)) {
1632 if (node->isAggregate()) {
1633 auto *aggregate = static_cast<Aggregate *>(node);
1634 // First write the function children, then write the nonfunction children.
1635 generateFunctionSections(writer, aggregate, context, state, post);
1636 auto nonFunctionChildren = sortedNonFunctionChildren(aggregate);
1637 for (auto *node : nonFunctionChildren)
1638 generateIndexSections(writer, node, context, state, post);
1639 }
1640
1641 if (node == state.root) {
1642 /*
1643 We wait until the end of the index file to output the group, module,
1644 QML module, and proxy nodes. By outputting them at the end, when we read
1645 the index file back in, all the group/module/proxy member
1646 nodes will have already been created. It is then only necessary to
1647 create the collection node and add each member to its member list.
1648 */
1649 const CNMap &groups = m_qdb->groups();
1650 if (!groups.isEmpty()) {
1651 for (auto it = groups.constBegin(); it != groups.constEnd(); ++it) {
1652 if (generateIndexSection(writer, it.value(), context, state, post))
1653 writer.writeEndElement();
1654 }
1655 }
1656
1657 const CNMap &modules = m_qdb->modules();
1658 if (!modules.isEmpty()) {
1659 for (auto it = modules.constBegin(); it != modules.constEnd(); ++it) {
1660 if (generateIndexSection(writer, it.value(), context, state, post))
1661 writer.writeEndElement();
1662 }
1663 }
1664
1665 const CNMap &qmlModules = m_qdb->qmlModules();
1666 if (!qmlModules.isEmpty()) {
1667 for (auto it = qmlModules.constBegin(); it != qmlModules.constEnd(); ++it) {
1668 if (generateIndexSection(writer, it.value(), context, state, post))
1669 writer.writeEndElement();
1670 }
1671 }
1672
1673 const CNMap &concepts = m_qdb->concepts();
1674 if (!concepts.isEmpty()) {
1675 for (auto it = concepts.constBegin(); it != concepts.constEnd(); ++it) {
1676 if (generateIndexSection(writer, it.value(), context, state, post))
1677 writer.writeEndElement();
1678 }
1679 }
1680
1681 for (auto *p : m_qdb->primaryTree()->proxies()) {
1682 if (generateIndexSection(writer, p, context, state, post)) {
1683 auto aggregate = static_cast<Aggregate *>(p);
1684 generateFunctionSections(writer, aggregate, context, state, post);
1685 auto nonFunctionChildren = sortedNonFunctionChildren(aggregate);
1686 for (auto *n : nonFunctionChildren)
1687 generateIndexSections(writer, n, context, state, post);
1688 writer.writeEndElement();
1689 }
1690 }
1691 }
1692
1693 writer.writeEndElement();
1694 }
1695}
1696
1697/*!
1698 Writes a qdoc module index in XML to a file named \a fileName.
1699 \a url is the \c url attribute of the <INDEX> element.
1700 \a title is the \c title attribute of the <INDEX> element.
1701 \a context supplies publication locations, the project identity, and
1702 serialization policy. A fresh write state keeps this export's related-node
1703 numbering independent of earlier output.
1704 */
1705void QDocIndexFiles::generateIndex(const QString &fileName, const QString &url,
1706 const QString &title, const IndexSerializationContext &context)
1707{
1708 Q_ASSERT(context.documentLocation);
1709
1710 QFile file(fileName);
1711 if (!file.open(QFile::WriteOnly | QFile::Text))
1712 return;
1713
1714 qCDebug(lcQdoc) << "Writing index file:" << fileName;
1715
1716 // Related-node numbering belongs to this export, not earlier WebXML output.
1717 WriteState state;
1718 state.root = m_qdb->primaryTreeRoot();
1719
1720 QXmlStreamWriter writer(&file);
1721 writer.setAutoFormatting(true);
1722 writer.writeStartDocument();
1723 writer.writeDTD("<!DOCTYPE QDOCINDEX>");
1724
1725 writer.writeStartElement("INDEX");
1726 writer.writeAttribute("url", url);
1727 writer.writeAttribute("title", title);
1728 writer.writeAttribute("version", m_qdb->version());
1729 writer.writeAttribute("project", context.project);
1730
1731 writeNonEmpty(writer, "indexTitle", state.root->tree()->indexTitle());
1732
1733 generateIndexSections(writer, state.root, context, state);
1734
1735 writer.writeEndElement(); // INDEX
1736 writer.writeEndElement(); // QDOCINDEX
1737 writer.writeEndDocument();
1738 file.close();
1739}
1740
1741QT_END_NAMESPACE
NodeList nonFunctionChildren() const
Returns a copy of the child nodes of this aggregate that are not function nodes, in the order they ap...
void adoptChild(Node *child)
This Aggregate becomes the adoptive parent of child.
The Atom class is the fundamental unit for representing documents internally.
Definition atom.h:19
The ClassNode represents a C++ class.
Definition classnode.h:23
Definition doc.h:32
bool hasTableOfContents() const
Definition doc.cpp:292
bool hasKeywords() const
Definition doc.cpp:297
bool hasTargets() const
Definition doc.cpp:302
void markAutoGenerated()
Marks this documentation as auto-generated by QDoc.
Definition doc.cpp:257
QStringMultiMap * metaTagMap() const
Definition doc.cpp:347
void constructExtra() const
Definition doc.cpp:357
void setFlagsType(TypedefNode *typedefNode)
Definition enumnode.cpp:81
void addItem(const EnumItem &item)
Add item to the enum type's item list.
Definition enumnode.cpp:23
void setAnonymous(bool anonymous)
Definition enumnode.h:43
The ExternalPageNode represents an external documentation page.
This node is used to represent any kind of function being documented.
signed short overloadNumber() const
Returns the overload number for this function.
bool isOverride() const
bool isPureVirtual() const override
bool isConstexpr() const
bool isRef() const
bool isNonvirtual() const
bool isHiddenFriend() const
bool isExplicit() const
bool isOverload() const
bool isConst() const
bool isRefRef() const
bool isAttached() const override
Returns true if the QML property or QML method node is marked as attached.
bool isDeletedAsWritten() const
bool isStatic() const override
Returns true if the FunctionNode represents a static function.
bool isFinal() const
bool isExplicitlyDefaulted() const
Parameters & parameters()
bool hasAssociatedProperties() const
static bool isPubliclyVisible(const InclusionPolicy &policy, const NodeContext &context)
virtual void append(QXmlStreamWriter &writer, Node *node)=0
The Location class provides a way to mark a location in a file.
Definition location.h:20
int lineNo() const
Returns the current line number.
Definition location.h:50
void setLineNo(int no)
Definition location.h:42
Location & operator=(const Location &other)
The assignment operator does a deep copy of the entire state of other into this Location.
Definition location.cpp:79
This class represents a C++ namespace.
Tree * tree() const override
Returns a pointer to the Tree that contains this NamespaceNode.
A PageNode is a Node that generates a documentation page.
Definition pagenode.h:19
void markAttribution()
Definition pagenode.h:50
The Parameter class describes one function parameter.
Definition parameter.h:14
This class describes one instance of using the Q_PROPERTY macro.
A class for representing an Aggregate that is documented in a different module.
Definition proxynode.h:14
This class provides exclusive access to the qdoc database, which consists of a forrest of trees and a...
static QDocDatabase * qdocDB()
Creates the singleton.
const CNMap & qmlModules()
Returns a const reference to the collection of all QML module nodes in the primary tree.
NamespaceNode * primaryTreeRoot()
Returns a pointer to the root node of the primary tree.
const CNMap & modules()
Returns a const reference to the collection of all module nodes in the primary tree.
const CNMap & concepts()
const CNMap & groups()
Returns a const reference to the collection of all group nodes in the primary tree.
This class imports QDoc index files and serializes index sections for module indexes and WebXML outpu...
Status
Specifies the status of the QQmlIncubator.
bool isPropertyGroup() const override
Returns true if the node is a SharedCommentNode for documenting multiple C++ properties or multiple Q...
void append(Node *node)
Definition text.h:12
static Text sectionHeading(const Atom *sectionBegin)
Definition text.cpp:157
static std::string comparisonCategoryAsString(ComparisonCategory category)
#define CONFIG_URL
Definition config.h:468
NodeType
Definition genustypes.h:165
@ SharedComment
Definition genustypes.h:188
Metaness
Specifies the kind of function a FunctionNode represents.
Definition genustypes.h:242
Combined button and popup list for selecting options.
QList< Node * > NodeList
Definition node.h:45
QMap< QString, CollectionNode * > CNMap
Definition node.h:52
static QString getAccessString(Access t)
static NodeList sortedNonFunctionChildren(const Aggregate *aggregate)
static void writeExternalRelates(QXmlStreamWriter &writer, Node *node)
Writes the relatedto attribute for node using the writer, if node is related to aggregates in other m...
static QString getThreadSafenessString(Node::ThreadSafeness t)
static QString getStatusString(Status t)
@ QDocAttrFile
@ QDocAttrAttribution
@ QDocAttrImage
@ QDocAttrExternalPage
@ QDocAttrExample
@ QDocAttrNone
@ QDocAttrDocument
static void writeNonEmpty(QXmlStreamWriter &writer, const QString &name, const QString &value)
Write an attribute to the current element using the writer for the attribute with the given name if t...
@ Deprecated
Definition status.h:12
@ Active
Definition status.h:14
@ Preliminary
Definition status.h:13
@ InternalAuto
Definition status.h:16
@ DontDocument
Definition status.h:17
@ Internal
Definition status.h:15
The Node class is the base class for all the nodes in QDoc's parse tree.
bool isExternalPage() const
Returns true if the node type is ExternalPage.
Definition node.h:100
const Doc & doc() const
Returns a reference to the node's Doc data member.
Definition node.h:239
bool isQmlNode() const
Returns true if this node's Genus value is QML.
Definition node.h:121
void setHadDoc()
Definition node.h:185
bool isGroup() const
Returns true if the node type is Group.
Definition node.h:105
void setAccess(Access t)
Sets the node's access type to t.
Definition node.h:172
void setIndexNodeFlag(bool isIndexNode=true)
Sets a flag in this Node that indicates the node was created for something in an index file.
Definition node.h:184
virtual bool isAbstract() const
Returns true if the ClassNode or QmlTypeNode is marked abstract.
Definition node.h:137
SharedCommentNode * sharedCommentNode()
Definition node.h:252
ComparisonCategory comparisonCategory() const
Definition node.h:187
bool isQmlType() const
Returns true if the node type is QmlType or QmlValueType.
Definition node.h:123
bool isHeader() const
Returns true if the node type is HeaderFile.
Definition node.h:106
NodeType nodeType() const override
Returns this node's type.
Definition node.h:82
Genus genus() const override
Returns this node's Genus.
Definition node.h:85
virtual bool isPageNode() const
Returns true if this node represents something that generates a documentation page.
Definition node.h:150
bool isEnumType() const
Returns true if the node type is Enum.
Definition node.h:94
virtual bool isTextPageNode() const
Returns true if the node is a PageNode but not an Aggregate.
Definition node.h:155
Aggregate * parent() const
Returns the node's parent pointer, that is, the aggregate under which the node is documented.
Definition node.h:211
void setLocation(const Location &t)
Sets the node's declaration location, its definition location, or both, depending on the suffix of th...
Definition node.cpp:909
virtual bool isAggregate() const
Returns true if this node is an aggregate, which means it inherits Aggregate and can therefore have c...
Definition node.h:138
virtual void setRelatedNonmember(bool b)
Sets a flag in the node indicating whether this node is a related nonmember of something.
Definition node.h:188
void setComparisonCategory(const ComparisonCategory &category)
Definition node.h:186
bool isProxyNode() const
Returns true if the node type is Proxy.
Definition node.h:115
ThreadSafeness threadSafeness() const
Returns the thread safeness value for whatever this node represents.
Definition node.cpp:845
virtual Tree * tree() const
Returns a pointer to the Tree this node is in.
Definition node.cpp:899
const Location & declLocation() const
Returns the Location where this node's declaration was seen.
Definition node.h:233
NodeContext createContext() const
Definition node.cpp:175
void setDoc(const Doc &doc, bool replace=false)
Sets this Node's Doc to doc.
Definition node.cpp:560
bool isModule() const
Returns true if the node type is Module.
Definition node.h:108
virtual bool isPropertyGroup() const
Returns true if the node is a SharedCommentNode for documenting multiple C++ properties or multiple Q...
Definition node.h:153
ThreadSafeness
An unsigned char that specifies the degree of thread-safeness of the element.
Definition node.h:58
@ ThreadSafe
Definition node.h:62
@ NonReentrant
Definition node.h:60
@ UnspecifiedSafeness
Definition node.h:59
@ Reentrant
Definition node.h:61
bool isSharingComment() const
This function returns true if the node is sharing a comment with other nodes.
Definition node.h:250
virtual void setAbstract(bool)
If this node is a ClassNode or a QmlTypeNode, the node's abstract flag data member is set to b.
Definition node.h:192
bool hasDoc() const
Returns true if this node is documented, or it represents a documented node read from the index ('had...
Definition node.cpp:942
bool isRelatedNonmember() const
Returns true if this is a related nonmember of something.
Definition node.h:124
virtual bool isClassNode() const
Returns true if this is an instance of ClassNode.
Definition node.h:145
bool isCppNode() const
Returns true if this node's Genus value is CPP.
Definition node.h:92
virtual void setStatus(Status t)
Sets the node's status to t.
Definition node.cpp:574
virtual bool isCollectionNode() const
Returns true if this is an instance of CollectionNode.
Definition node.h:146
void setThreadSafeness(ThreadSafeness t)
Sets the node's thread safeness to t.
Definition node.h:176
bool isQmlModule() const
Returns true if the node type is QmlModule.
Definition node.h:120
@ SignatureReturnType
Definition node.h:68
bool isExample() const
Returns true if the node type is Example.
Definition node.h:99
bool isIndexNode() const
Returns true if this node was created from something in an index file.
Definition node.h:107
static bool nodeLessThan(const Node *first, const Node *second)
Returns true if the node n1 is less than node n2.
Definition node.cpp:79
const Parameter & at(int i) const
Definition parameters.h:36
int count() const
Definition parameters.h:34
A record of a linkable target within the documentation.
Definition tree.h:28
TargetType
A type of a linkable target record.
Definition tree.h:30
@ Keyword
Definition tree.h:30
@ Target
Definition tree.h:30
@ Contents
Definition tree.h:30