19#include <QtCore/qregularexpression.h>
24using namespace Qt::StringLiterals;
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
65
66
67
68
69
70
73 for (
auto *entry : m_searchOrder)
76 m_searchOrder.clear();
77 m_indexSearchOrder.clear();
78 m_moduleNames.clear();
79 m_primaryTree =
nullptr;
83
84
85
86
90 return (!searchOrder().isEmpty() ? searchOrder()[0] :
nullptr);
94
95
96
97
101 return (m_currentIndex < searchOrder().size() ? searchOrder()[m_currentIndex] :
nullptr);
105
106
107
108
111
112
113
114
115
116
117
118
119void QDocForest::setPrimaryTree(
const QString &t)
121 QString T = t.toLower();
122 m_primaryTree = findTree(T);
124 if (m_primaryTree ==
nullptr)
125 qCCritical(lcQdoc) <<
"Error: Could not set primary tree to" << t;
129
130
131
132void QDocForest::setSearchOrder(
const QStringList &t)
134 if (!m_searchOrder.isEmpty())
138 m_searchOrder.reserve(m_forest.size() + 1);
139 m_searchOrder.clear();
140 m_moduleNames.reserve(m_forest.size() + 1);
141 m_moduleNames.clear();
144 QString primaryName = primaryTree()->physicalModuleName();
145 m_searchOrder.append(m_primaryTree);
146 m_moduleNames.append(primaryName);
147 m_forest.remove(primaryName);
149 for (
const QString &m : t) {
150 if (primaryName != m) {
151 auto it = m_forest.find(m);
152 if (it != m_forest.end()) {
153 m_searchOrder.append(it.value());
154 m_moduleNames.append(m);
160
161
162
163
164 if (!m_forest.isEmpty()) {
165 for (
auto it = m_forest.begin(); it != m_forest.end(); ++it) {
166 m_searchOrder.append(it.value());
167 m_moduleNames.append(it.key());
173
174
175
176
177
178
179
180 for (
int i = 0; i < m_searchOrder.size(); ++i) {
181 if (!m_forest.contains(m_moduleNames.at(i))) {
182 m_forest.insert(m_moduleNames.at(i), m_searchOrder.at(i));
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
214 if (m_searchOrder.isEmpty())
215 return indexSearchOrder();
216 return m_searchOrder;
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234const QList<Tree *> &
QDocForest::indexSearchOrder()
236 if (m_forest.size() > m_indexSearchOrder.size())
237 m_indexSearchOrder.prepend(m_primaryTree);
238 return m_indexSearchOrder;
242
243
244
245
248 m_primaryTree =
new Tree(module, m_qdb);
249 m_forest.insert(module.toLower(), m_primaryTree);
250 return m_primaryTree->root();
254
255
256
257void QDocForest::newPrimaryTree(
const QString &module)
259 m_primaryTree =
new Tree(module, m_qdb);
263
264
265
266
267
268
269
270
271
272
273
274
275
276const Node *
QDocForest::findNodeForTarget(QStringList &targetPath,
const Node *relative,
277 Genus genus, QString &ref,
int findFlags)
281 QString entity = targetPath.takeFirst();
282 QStringList entityPath = entity.split(
"::");
285 if (!targetPath.isEmpty())
286 target = targetPath.takeFirst();
289 const Node *tocNode =
nullptr;
290 for (
const auto *tree : searchOrder()) {
291 const Node *n = tree->findNodeForTarget(entityPath, target, relative, flags, genus, ref, &type);
294 if (type != TargetRec::Contents)
305
306
307
308
309
310
311
312
313
318 for (
const auto *tree : searchOrder()) {
319 const FunctionNode *fn = tree->findFunctionNode(path, parameters, relative, genus);
328
329
330
331
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
370
371
372
375 if (s_qdocDB ==
nullptr) {
383
384
387 if (s_qdocDB !=
nullptr) {
394
395
396
397
398
399
400
401
402
403
404
405
406
409 s_typeNodeMap.insert(
"accepted",
nullptr);
410 s_typeNodeMap.insert(
"actionPerformed",
nullptr);
411 s_typeNodeMap.insert(
"activated",
nullptr);
412 s_typeNodeMap.insert(
"alias",
nullptr);
413 s_typeNodeMap.insert(
"anchors",
nullptr);
414 s_typeNodeMap.insert(
"any",
nullptr);
415 s_typeNodeMap.insert(
"array",
nullptr);
416 s_typeNodeMap.insert(
"autoSearch",
nullptr);
417 s_typeNodeMap.insert(
"axis",
nullptr);
418 s_typeNodeMap.insert(
"backClicked",
nullptr);
419 s_typeNodeMap.insert(
"boomTime",
nullptr);
420 s_typeNodeMap.insert(
"border",
nullptr);
421 s_typeNodeMap.insert(
"buttonClicked",
nullptr);
422 s_typeNodeMap.insert(
"callback",
nullptr);
423 s_typeNodeMap.insert(
"char",
nullptr);
424 s_typeNodeMap.insert(
"clicked",
nullptr);
425 s_typeNodeMap.insert(
"close",
nullptr);
426 s_typeNodeMap.insert(
"closed",
nullptr);
427 s_typeNodeMap.insert(
"cond",
nullptr);
428 s_typeNodeMap.insert(
"data",
nullptr);
429 s_typeNodeMap.insert(
"dataReady",
nullptr);
430 s_typeNodeMap.insert(
"dateString",
nullptr);
431 s_typeNodeMap.insert(
"dateTimeString",
nullptr);
432 s_typeNodeMap.insert(
"datetime",
nullptr);
433 s_typeNodeMap.insert(
"day",
nullptr);
434 s_typeNodeMap.insert(
"deactivated",
nullptr);
435 s_typeNodeMap.insert(
"drag",
nullptr);
436 s_typeNodeMap.insert(
"easing",
nullptr);
437 s_typeNodeMap.insert(
"error",
nullptr);
438 s_typeNodeMap.insert(
"exposure",
nullptr);
439 s_typeNodeMap.insert(
"fatalError",
nullptr);
440 s_typeNodeMap.insert(
"fileSelected",
nullptr);
441 s_typeNodeMap.insert(
"flags",
nullptr);
442 s_typeNodeMap.insert(
"float",
nullptr);
443 s_typeNodeMap.insert(
"focus",
nullptr);
444 s_typeNodeMap.insert(
"focusZone",
nullptr);
445 s_typeNodeMap.insert(
"format",
nullptr);
446 s_typeNodeMap.insert(
"framePainted",
nullptr);
447 s_typeNodeMap.insert(
"from",
nullptr);
448 s_typeNodeMap.insert(
"frontClicked",
nullptr);
449 s_typeNodeMap.insert(
"function",
nullptr);
450 s_typeNodeMap.insert(
"hasOpened",
nullptr);
451 s_typeNodeMap.insert(
"hovered",
nullptr);
452 s_typeNodeMap.insert(
"hoveredTitle",
nullptr);
453 s_typeNodeMap.insert(
"hoveredUrl",
nullptr);
454 s_typeNodeMap.insert(
"imageCapture",
nullptr);
455 s_typeNodeMap.insert(
"imageProcessing",
nullptr);
456 s_typeNodeMap.insert(
"index",
nullptr);
457 s_typeNodeMap.insert(
"initialized",
nullptr);
458 s_typeNodeMap.insert(
"isLoaded",
nullptr);
459 s_typeNodeMap.insert(
"item",
nullptr);
460 s_typeNodeMap.insert(
"key",
nullptr);
461 s_typeNodeMap.insert(
"keysequence",
nullptr);
462 s_typeNodeMap.insert(
"listViewClicked",
nullptr);
463 s_typeNodeMap.insert(
"loadRequest",
nullptr);
464 s_typeNodeMap.insert(
"locale",
nullptr);
465 s_typeNodeMap.insert(
"location",
nullptr);
466 s_typeNodeMap.insert(
"long",
nullptr);
467 s_typeNodeMap.insert(
"message",
nullptr);
468 s_typeNodeMap.insert(
"messageReceived",
nullptr);
469 s_typeNodeMap.insert(
"mode",
nullptr);
470 s_typeNodeMap.insert(
"month",
nullptr);
471 s_typeNodeMap.insert(
"name",
nullptr);
472 s_typeNodeMap.insert(
"number",
nullptr);
473 s_typeNodeMap.insert(
"object",
nullptr);
474 s_typeNodeMap.insert(
"offset",
nullptr);
475 s_typeNodeMap.insert(
"ok",
nullptr);
476 s_typeNodeMap.insert(
"openCamera",
nullptr);
477 s_typeNodeMap.insert(
"openImage",
nullptr);
478 s_typeNodeMap.insert(
"openVideo",
nullptr);
479 s_typeNodeMap.insert(
"padding",
nullptr);
480 s_typeNodeMap.insert(
"parent",
nullptr);
481 s_typeNodeMap.insert(
"path",
nullptr);
482 s_typeNodeMap.insert(
"photoModeSelected",
nullptr);
483 s_typeNodeMap.insert(
"position",
nullptr);
484 s_typeNodeMap.insert(
"precision",
nullptr);
485 s_typeNodeMap.insert(
"presetClicked",
nullptr);
486 s_typeNodeMap.insert(
"preview",
nullptr);
487 s_typeNodeMap.insert(
"previewSelected",
nullptr);
488 s_typeNodeMap.insert(
"progress",
nullptr);
489 s_typeNodeMap.insert(
"puzzleLost",
nullptr);
490 s_typeNodeMap.insert(
"qmlSignal",
nullptr);
491 s_typeNodeMap.insert(
"rectangle",
nullptr);
492 s_typeNodeMap.insert(
"request",
nullptr);
493 s_typeNodeMap.insert(
"requestId",
nullptr);
494 s_typeNodeMap.insert(
"section",
nullptr);
495 s_typeNodeMap.insert(
"selected",
nullptr);
496 s_typeNodeMap.insert(
"send",
nullptr);
497 s_typeNodeMap.insert(
"settingsClicked",
nullptr);
498 s_typeNodeMap.insert(
"shoe",
nullptr);
499 s_typeNodeMap.insert(
"short",
nullptr);
500 s_typeNodeMap.insert(
"signed",
nullptr);
501 s_typeNodeMap.insert(
"sizeChanged",
nullptr);
502 s_typeNodeMap.insert(
"size_t",
nullptr);
503 s_typeNodeMap.insert(
"sockaddr",
nullptr);
504 s_typeNodeMap.insert(
"someOtherSignal",
nullptr);
505 s_typeNodeMap.insert(
"sourceSize",
nullptr);
506 s_typeNodeMap.insert(
"startButtonClicked",
nullptr);
507 s_typeNodeMap.insert(
"state",
nullptr);
508 s_typeNodeMap.insert(
"std::initializer_list",
nullptr);
509 s_typeNodeMap.insert(
"std::list",
nullptr);
510 s_typeNodeMap.insert(
"std::map",
nullptr);
511 s_typeNodeMap.insert(
"std::pair",
nullptr);
512 s_typeNodeMap.insert(
"std::string",
nullptr);
513 s_typeNodeMap.insert(
"std::vector",
nullptr);
514 s_typeNodeMap.insert(
"stringlist",
nullptr);
515 s_typeNodeMap.insert(
"swapPlayers",
nullptr);
516 s_typeNodeMap.insert(
"symbol",
nullptr);
517 s_typeNodeMap.insert(
"t",
nullptr);
518 s_typeNodeMap.insert(
"T",
nullptr);
519 s_typeNodeMap.insert(
"tagChanged",
nullptr);
520 s_typeNodeMap.insert(
"timeString",
nullptr);
521 s_typeNodeMap.insert(
"timeout",
nullptr);
522 s_typeNodeMap.insert(
"to",
nullptr);
523 s_typeNodeMap.insert(
"toggled",
nullptr);
524 s_typeNodeMap.insert(
"type",
nullptr);
525 s_typeNodeMap.insert(
"unsigned",
nullptr);
526 s_typeNodeMap.insert(
"urllist",
nullptr);
527 s_typeNodeMap.insert(
"va_list",
nullptr);
528 s_typeNodeMap.insert(
"value",
nullptr);
529 s_typeNodeMap.insert(
"valueEmitted",
nullptr);
530 s_typeNodeMap.insert(
"videoFramePainted",
nullptr);
531 s_typeNodeMap.insert(
"videoModeSelected",
nullptr);
532 s_typeNodeMap.insert(
"videoRecorder",
nullptr);
533 s_typeNodeMap.insert(
"void",
nullptr);
534 s_typeNodeMap.insert(
"volatile",
nullptr);
535 s_typeNodeMap.insert(
"wchar_t",
nullptr);
536 s_typeNodeMap.insert(
"x",
nullptr);
537 s_typeNodeMap.insert(
"y",
nullptr);
538 s_typeNodeMap.insert(
"zoom",
nullptr);
539 s_typeNodeMap.insert(
"zoomTo",
nullptr);
543
544
547
548
549
550
553
554
555
556
559
560
561
562
565
566
567
568
569
570
571
574
575
576
577
578
579
580
583
584
585
586
587
588
591
592
593
594
595
596
599
600
601
602
603
604
607
608
609
610
611
612
613
614
617
618
619
620
621
622
625
626
627
628
631
632
633
636
637
638
639
640
641
642
643
644
645
649 if (!qmid.isEmpty()) {
651 ? tree->lookupQmlType(qmid + u"::"_s + name, relative)
652 : m_forest.lookupQmlType(qmid + u"::"_s + name, relative);
659 ? tree->lookupQmlType(name, relative)
660 : m_forest.lookupQmlType(name, relative);
665 QStringList path(name);
667 ? tree->findNodeByNameAndType(path, &Node::isQmlType)
668 : findNodeByNameAndType(path, &Node::isQmlType);
669 return static_cast<QmlTypeNode *>(node);
673
674
675
676
686 if (!record.m_importId.isEmpty()) {
687 const QString namespacePrefix{
"%1."_L1.arg(record.m_importId)};
688 if (!type.startsWith(namespacePrefix))
690 type.remove(0, namespacePrefix.size());
693 const QString qmName = record.m_importUri.isEmpty() ? record.m_moduleName : record.m_importUri;
694 return m_forest.lookupQmlType(qmName + u"::"_s + type, relative);
698
699
700
701
702
703
712
713
714
715
716
717
730
731
732
733
734
737 Tree *t = m_forest.firstTree();
739 if (!m_completedFindFunctions.values(t).contains(func)) {
740 (
this->*(func))(t->root());
741 m_completedFindFunctions.insert(t, func);
743 t = m_forest.nextTree();
748
749
753 return m_legaleseTexts;
757
758
762 return s_classesWithObsoleteMembers;
766
767
771 return s_obsoleteQmlTypes;
775
776
780 return s_qmlTypesWithObsoleteMembers;
784
785
789 return s_qmlBasicTypes;
793
794
802
803
811
812
816 return m_attributions;
820
821
825 return s_obsoleteClasses;
829
830
838
839
840
844 return m_functionIndex;
848
849
850
853 for (
const auto &childNode : node->childNodes()) {
854 if (childNode->isPrivate())
856 if (!childNode->doc().legaleseText().isEmpty())
857 m_legaleseTexts.insert(childNode->doc().legaleseText(), childNode);
858 if (childNode->isAggregate())
859 findAllLegaleseTexts(
static_cast<Aggregate *>(childNode));
864
865
866
867
868
869
872
873
874
875
876
877
878
879
880
883
884
885
886
887
888
889
892
893
894
895
899 auto it = s_newClassMaps.constFind(key);
904
905
906
907
911 auto it = s_newQmlTypeMaps.constFind(key);
916
917
918
919
923 auto it = s_newSinceMaps.constFind(key);
928
929
930
931
932
933
934
935
938 const auto &config = Config::instance();
939 if (config.dualExec() || config.preparing()) {
956 if (config.singleExec() && config.generating()) {
964 if (!config.preparing()) {
970 if (config.dualExec())
976 Tree *t = m_forest.firstTree();
978 t->resolveBaseClasses(t->root());
981 t = m_forest.nextTree();
986
987
988
989
990
994 for (
const auto &name : td->referenced_concepts)
995 refs.append(QString::fromStdString(name));
998 const auto *fn =
static_cast<
const FunctionNode *>(node);
999 refs += fn->referencedConcepts();
1004
1005
1006
1007
1008
1009
1012 for (
auto *child : std::as_const(parent->childNodes())) {
1018 const bool registerChild =
1019 !child->isPrivate() && !child->isInternal() && !child->isDontDocument();
1021 if (registerChild) {
1023 collectConceptReferences(child, refs);
1025 refs.removeDuplicates();
1027 for (
const QString &conceptName : std::as_const(refs)) {
1040 if (
auto *cn = db.findMutableCollectionNode(conceptName, NodeType::Concept))
1041 cn->addMember(child);
1045 if (child->isAggregate())
1046 registerConceptUsersUnder(
static_cast<Aggregate *>(child), db);
1051
1052
1053
1054
1055
1056
1057
1058
1065
1066
1067
1068
1069
1073 return m_namespaceIndex;
1077
1078
1079
1080
1081
1082
1083
1086 if (!m_namespaceIndex.isEmpty())
1091 Tree *t = m_forest.firstTree();
1094 t = m_forest.nextTree();
1096 const QList<QString> keys = namespaceMultimap.uniqueKeys();
1097 for (
const QString &key : keys) {
1098 NamespaceNode *ns =
nullptr;
1099 NamespaceNode *indexNamespace =
nullptr;
1100 const NodeList namespaces = namespaceMultimap.values(key);
1101 qsizetype count = namespaceMultimap.remove(key);
1103 for (
auto *node : namespaces) {
1104 ns =
static_cast<NamespaceNode *>(node);
1105 if (ns->isDocumentedHere())
1107 else if (ns->hadDoc())
1108 indexNamespace = ns;
1112 for (
auto *node : namespaces) {
1113 auto *nsNode =
static_cast<NamespaceNode *>(node);
1114 if (nsNode->hadDoc() && nsNode != ns) {
1115 ns->doc().location().warning(
1116 QStringLiteral(
"Namespace %1 documented more than once")
1117 .arg(nsNode->name()), QStringLiteral(
"also seen here: %1")
1118 .arg(nsNode->doc().location().toString()));
1121 }
else if (!indexNamespace) {
1126 for (
auto *node : namespaces) {
1127 if (!node->isIndexNode())
1128 static_cast<NamespaceNode *>(node)->reportDocumentedChildrenInUndocumentedNamespace();
1132 for (
auto *node : namespaces) {
1133 auto *nsNode =
static_cast<NamespaceNode *>(node);
1134 if (nsNode != indexNamespace)
1135 nsNode->setDocNode(indexNamespace);
1140
1141
1142
1143
1144
1145 if (ns && count > 1) {
1146 for (
auto *node : namespaces) {
1147 auto *nameSpaceNode =
static_cast<NamespaceNode *>(node);
1148 if (nameSpaceNode != ns) {
1149 for (
auto it = nameSpaceNode->constBegin(); it != nameSpaceNode->constEnd();
1151 Node *anotherNs = *it;
1152 if (anotherNs && anotherNs->isPublic() && !anotherNs->isInternal())
1153 ns->includeChild(anotherNs);
1159
1160
1161
1163 ns = indexNamespace ? indexNamespace :
static_cast<NamespaceNode *>(namespaces.last());
1164 m_namespaceIndex.insert(ns->name(), ns);
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1190 Tree *t = m_forest.firstTree();
1191 t = m_forest.nextTree();
1194 if (!proxies.isEmpty()) {
1195 for (
auto *node : proxies) {
1196 const auto *pn =
static_cast<ProxyNode *>(node);
1197 if (pn->count() > 0) {
1198 Aggregate *aggregate = primaryTree()->findAggregate(pn->name());
1199 if (aggregate !=
nullptr)
1200 aggregate->appendToRelatedByProxy(pn->childNodes());
1204 const auto &externalRelates = t->externalRelates();
1205 for (
auto it = externalRelates.cbegin(); it != externalRelates.cend(); ++it) {
1210 t = m_forest.nextTree();
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1230 QString function = target;
1231 const QString signature = Parameters::extractParameters(function);
1232 const Parameters parameters(signature.trimmed());
1236 const QStringList path = function.split(
"::"_L1);
1237 return m_forest.findFunctionNode(path, parameters, relative, genus);
1241
1242
1243
1244
1245
1246
1247
1248
1249
1253 if ((genus == Genus::QML || (relative && relative
->genus() == Genus::QML)) &&
1254 type.contains(
'.') && !type.contains(
"::")) {
1256 const QmlTypeNode *qmlType =
static_cast<
const QmlTypeNode*>(relative);
1259 for (
const auto &import : imports) {
1260 if (QmlTypeNode *found = findQmlType(import, type)) {
1267 QStringList path = type.split(
".");
1268 if ((path.size() == 1) && (path.at(0)[0].isLower() || path.at(0) == QString(
"T"))) {
1269 auto it = s_typeNodeMap.find(path.at(0));
1270 if (it != s_typeNodeMap.end())
1275 const Node *node = m_forest.findTypeNode(path, relative, genus);
1282 if (path.size() > 1) {
1283 const Node *lastSegmentNode = m_forest.findTypeNode(QStringList{path.last()}, relative, genus);
1285 return lastSegmentNode;
1292 QStringList path = type.split(
"::");
1293 if ((path.size() == 1) && (path.at(0)[0].isLower() || path.at(0) == QString(
"T"))) {
1294 auto it = s_typeNodeMap.find(path.at(0));
1295 if (it != s_typeNodeMap.end())
1298 return m_forest.findTypeNode(path, relative, genus);
1302
1303
1304
1305
1306
1309 const Node *node =
nullptr;
1310 if (target.isEmpty())
1312 else if (target.endsWith(
".html"))
1313 node = findNodeByNameAndType(QStringList(target), &Node::isPageNode);
1315 QStringList path = target.split(
"::");
1317 for (
const auto *tree : searchOrder()) {
1318 const Node *n = tree->findNode(path, relative, flags, Genus::DontCare);
1323 node = findPageNodeByTitle(target);
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1360 Genus genus,
const QString &moduleName,
1361 QString *ref, LinkReferenceOrigin origin,
1364 if (target.isEmpty())
1367 Tree *domain = moduleName.isEmpty() ?
nullptr : findTree(moduleName);
1370 const Node *qmlContext = relative;
1373 if (!parent || parent
->genus() != Genus::QML)
1375 qmlContext = parent;
1378 QStringList targetPath = Utilities::pathAndFragment(target);
1379 const QString first = targetPath.first().trimmed();
1380 QString qmlName = first;
1381 Parameters::extractParameters(qmlName);
1383 const bool qmlDotPath =
1384 origin == LinkReferenceOrigin::Explicit
1385 && (genus == Genus::DontCare || genus == Genus::QML)
1386 && qmlName.contains(
'.'_L1)
1387 && !qmlName.contains(
"::"_L1)
1388 && !qmlName.contains(
"://"_L1)
1389 && !qmlName.contains(
' '_L1)
1390 && !qmlName.endsWith(
".html"_L1);
1392 auto withFragment = [targetPath, ref](
const Node *node) ->
const Node * {
1394 node = setReferenceFromFragment(targetPath.value(1), node, localRef);
1400 auto findQmlDotPathNode = [
this, qmlContext, domain, &withFragment, genus, flags](
const QString &path)
1403 const Node *node = findQmlNode(path, qmlContext, FindFlags::fromInt(flags), domain);
1406 const QmlTypeNode *qmlRelative =
static_cast<
const QmlTypeNode *>(qmlContext);
1407 const QStringList pieces = path.split(
'.'_L1);
1408 if (pieces.size() >= 2) {
1409 for (
const ImportRec &import : qmlRelative->importList()) {
1410 if (import.m_importId.isEmpty() || import.m_importId != pieces.first())
1412 const QString qmid = import.m_importUri.isEmpty()
1413 ? import.m_moduleName
1414 : import.m_importUri;
1415 const QString qualifiedPath = qmid + path.mid(pieces.first().size());
1416 node = findQmlNode(qualifiedPath, qmlContext, FindFlags::fromInt(flags),
1424 if (!node && genus == Genus::QML)
1425 node = findTypeNode(path, qmlContext, genus);
1428 if (node && domain && node
->tree() != domain)
1430 return withFragment(node);
1434 const Node *node =
nullptr;
1435 if (target.endsWith(
".html"_L1)) {
1436 node = domain->findNodeByNameAndType(QStringList(target), &
Node::isPageNode);
1437 }
else if (target.endsWith(
')'_L1)) {
1438 QString function = target;
1439 const QString signature = Parameters::extractParameters(function);
1440 const Parameters parameters(signature.trimmed());
1442 const QStringList path = function.split(
"::"_L1);
1444 node = domain->findFunctionNode(path, parameters,
nullptr, genus);
1450 if (
const Node *qmlNode = findQmlDotPathNode(first))
1454 QStringList nodePath = target.split(
"::"_L1);
1455 if (relative && relative
->tree()->physicalModuleName() != domain->physicalModuleName())
1458 const Node *result =
1459 domain->findNodeForTarget(nodePath, {}, relative, flags, genus, localRef);
1465 if (target.endsWith(
".html"_L1))
1466 return findNodeByNameAndType(QStringList(target), &Node::isPageNode);
1468 if (target.endsWith(
')'_L1)) {
1469 const Node *node = findFunctionNode(target, relative, genus);
1475 if (
const Node *qmlNode = findQmlDotPathNode(first))
1480 const Node *node = findNodeForTarget(targetPath, relative, genus, localRef, flags);
1487 return findPageNodeByTitle(target);
1498 for (
auto it = m->cbegin(); it != m->cend(); ++it)
1499 if (it.value()->members().contains(node))
1506
1507
1510 QStringList filesToRead;
1511 for (
const QString &file : indexFiles) {
1512 QString fn = file.mid(file.lastIndexOf(QChar(
'/')) + 1);
1514 filesToRead << file;
1516 qCCritical(lcQdoc) <<
"Index file" << file <<
"is already in memory.";
1522
1523
1524
1525
1526
1530 QString t = fileName.mid(fileName.lastIndexOf(QChar(
'/')) + 1);
1532 QDocIndexFiles::qdocIndexFiles()->generateIndex(fileName, url, title, context);
1537
1538
1539
1540
1549 moduleName = relative->physicalModuleName();
1553 moduleName = relative->logicalModuleName();
1558 if (moduleName.isEmpty())
1561 return primaryTree()->getCollection(moduleName, moduleType);
1565
1566
1567
1568
1573 for (
auto *tree : searchOrder()) {
1574 CNMap *m = tree->getCollectionMap(type);
1575 if (m && !m->isEmpty()) {
1576 for (
auto it = m->cbegin(); it != m->cend(); ++it) {
1577 if (!it.value()->isInternal())
1578 cnmm.insert(it.key(), it.value());
1584 static const QRegularExpression singleDigit(
"\\b([0-9])\\b");
1585 const QStringList keys = cnmm.uniqueKeys();
1586 for (
const auto &key : keys) {
1587 const QList<CollectionNode *> values = cnmm.values(key);
1588 CollectionNode *n =
nullptr;
1589 for (
auto *value : values) {
1590 if (value && value->wasSeen() && value != relative) {
1596 if (values.size() > 1) {
1597 for (CollectionNode *value : values) {
1600 if ((n->isQmlModule())
1601 && n->logicalModuleIdentifier() != value->logicalModuleIdentifier()) {
1602 if (value->wasSeen() && value != relative)
1603 cnm.insert(value->fullTitle().toLower(), value);
1606 for (Node *t : value->members())
1611 QString sortKey = n->fullTitle().toLower();
1612 if (sortKey.startsWith(
"the "))
1613 sortKey.remove(0, 4);
1614 sortKey.replace(singleDigit,
"0\\1");
1615 cnm.insert(sortKey, n);
1621
1622
1623
1624
1625
1626
1627
1628
1673 for (
auto *tree : searchOrder()) {
1674 CollectionNode *cn = tree->getCollection(c->name(), c->nodeType());
1675 if (cn && cn != c) {
1676 if ((cn->isQmlModule())
1677 && cn->logicalModuleIdentifier() != c->logicalModuleIdentifier())
1680 for (
auto *node : cn->members())
1740 if (!c->wasSeen() && cn->wasSeen()) {
1742 c->setTitle(cn->title());
1743 c->setUrl(cn->url());
1744 c->setResolvedPhysicalModuleName(cn->tree()->physicalModuleName());
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1768 QString qmlPath = path;
1769 const QString signature = Parameters::extractParameters(qmlPath);
1770 const bool findFunction = !signature.isNull();
1772 for (
const QString &piece : qmlPath.split(
'.'_L1))
1773 pieces.append(piece.split(
"::"_L1));
1776 QString candidateName;
1777 const Node *moduleNode =
nullptr;
1778 qsizetype modulePrefixSize = 0;
1779 for (; modulePrefixSize < pieces.size(); ++modulePrefixSize) {
1780 candidateName += pieces.at(modulePrefixSize);
1781 const Node *node = tree
1782 ? tree->findNodeByNameAndType({candidateName}, &Node::isQmlModule)
1783 : findNodeByNameAndType({candidateName}, &Node::isQmlModule);
1788 candidateName +=
'.'_L1;
1791 if (modulePrefixSize == pieces.size())
1792 return findFunction ?
nullptr : moduleNode;
1796 pieces.remove(0, modulePrefixSize);
1797 qmlType = findQmlType(moduleNode->name(), pieces.takeFirst(), relative, tree);
1799 qmlType = findQmlType(pieces.takeFirst(), relative, tree);
1801 if (!qmlType || pieces.isEmpty())
1802 return findFunction ?
nullptr : qmlType;
1806 const auto findProperty = [searchType](
const QmlTypeNode *type,
const QString &name)
1808 const QmlPropertyNode *property = type->hasQmlProperty(name, searchType);
1816 while (pieces.size() > 1) {
1817 const QmlPropertyNode *property = findProperty(qmlType, pieces.first());
1822 ? findQmlType(moduleNode->name(), property->dataType(), relative, tree)
1823 : findQmlType(property->dataType(), relative, tree);
1828 pieces.removeFirst();
1834 const Parameters parameters(signature.trimmed());
1840 const QString memberName = pieces.join(
'.'_L1);
1841 if (
const QmlPropertyNode *property = findProperty(qmlType, memberName))
1846 return qmlType->findChildNode(memberName, Genus::QML);
1850
1851
1852
1853
1857 if (!node || fragment.isEmpty())
1860 ref = node
->tree()->getRef(fragment, node);
1861 return ref.isEmpty() ?
nullptr : node;
1865
1866
1867
1868
1869
1870
1871
1872
1876 const Node *node =
nullptr;
1878 Atom *atom =
const_cast<
Atom *>(a);
1879 QStringList targetPath = Utilities::pathAndFragment(atom->string());
1880 QString first = targetPath.first().trimmed();
1881 const QString fragment = targetPath.value(1);
1883 Tree *domain =
nullptr;
1887 domain = atomDomain;
1891 QString qmlName = first;
1892 Parameters::extractParameters(qmlName);
1893 if (!qmlName.contains(
"://"_L1) && !qmlName.contains(
' '_L1)
1894 && !qmlName.endsWith(
".html"_L1) && qmlName.contains(
'.'_L1)) {
1895 const auto flags = FindFlags::fromInt(a->flags());
1896 if (
const Node *found = findQmlNode(first, relative, flags))
1897 return setReferenceFromFragment(fragment, found, ref);
1901 if (first.isEmpty())
1904 if (first.endsWith(
".html"))
1905 node = domain->findNodeByNameAndType(QStringList(first), &
Node::isPageNode);
1906 else if (first.endsWith(QChar(
')'))) {
1907 QString function = first;
1908 const QString signature = Parameters::extractParameters(function);
1909 const Parameters parameters(signature.trimmed());
1911 const QStringList path = function.split(
"::"_L1);
1913 node = domain->findFunctionNode(path, parameters,
nullptr, genus);
1915 if (node ==
nullptr) {
1917 QStringList nodePath = first.split(
"::");
1919 targetPath.removeFirst();
1920 if (!targetPath.isEmpty())
1921 target = targetPath.takeFirst();
1922 if (relative && relative
->tree()->physicalModuleName() != domain->physicalModuleName())
1924 return domain->findNodeForTarget(nodePath, target, relative, flags, genus, ref);
1927 if (first.endsWith(
".html"))
1928 node = findNodeByNameAndType(QStringList(first), &Node::isPageNode);
1929 else if (first.endsWith(QChar(
')')))
1930 node = findFunctionNode(first, relative, genus);
1931 if (node ==
nullptr) {
1933 if (genus == Genus::QML && first.contains(
'.') && !first.contains(
"::")) {
1935 node = findTypeNode(first, relative, genus);
1937 return setReferenceFromFragment(fragment, node, ref);
1939 return findNodeForTarget(targetPath, relative, genus, ref, atom->flags());
1943 if (node !=
nullptr && ref.isEmpty()) {
1944 if (!node->url().isEmpty())
1946 targetPath.removeFirst();
1947 if (!targetPath.isEmpty()) {
1957
1958
1959
1960
1961
1962
1963
1964
1968 QList<Tree *> searchOrder =
this->searchOrder();
1987 bool inclusive{Config::instance().get(
1991 const auto tocTitles{Config::instance().get(configVar).asStringList()};
1993 for (
const auto &tocTitle : tocTitles) {
1994 if (
const auto candidateTarget = findNodeForTarget(tocTitle,
nullptr); candidateTarget && candidateTarget->isPageNode()) {
1995 auto tocPage{
static_cast<
const PageNode*>(candidateTarget)};
1997 Text body = tocPage->doc().body();
1999 auto *atom = body.firstAtom();
2001 std::pair<PageNode *, QString> prev {
nullptr, QString() };
2003 std::stack<
const PageNode *> tocStack;
2004 tocStack.push(inclusive ? tocPage :
nullptr);
2006 bool inItem =
false;
2013 switch (atom->type()) {
2014 case Atom::ListItemLeft:
2016 tocStack.push(
nullptr);
2019 case Atom::ListItemRight:
2059 auto candidatePage =
const_cast<Node *>(findNodeForAtom(atom,
nullptr, unused));
2060 if (!candidatePage || !candidatePage->isPageNode())
break;
2062 auto page{
static_cast<PageNode*>(candidatePage)};
2065 if (page == prev.first)
break;
2068 prev.first->setLink(
2109 prev.first->title(),
2114 if (page == tocPage)
2119 qsizetype popped = 0;
2120 while (tocStack.size() > 1 && !tocStack.top()) {
2125 page->setNavigationParent(tocStack.empty() ?
nullptr : tocStack.top());
2127 while (--popped > 0)
2128 tocStack.push(
nullptr);
2130 tocStack.push(page);
2132 prev = { page, atom->linkText() };
2136 case Atom::AnnotatedList:
2137 case Atom::GeneratedList: {
2138 if (
const auto *cn = getCollectionNode(atom->string(), NodeType::Group)) {
2139 const auto sortOrder{Generator::sortOrder(atom->strings().last())};
2140 NodeList members{cn->members()};
2143 members.erase(std::remove_if(members.begin(), members.end(),
2145 return n->isIndexNode() || !n->isPageNode() || n->isExternalPage();
2147 if (members.isEmpty())
2150 if (sortOrder == Qt::DescendingOrder)
2151 std::sort(members.rbegin(), members.rend(), Node::nodeSortKeyOrNameLessThan);
2153 std::sort(members.begin(), members.end(), Node::nodeSortKeyOrNameLessThan);
2158 for (
auto *m : members) {
2159 auto *page =
static_cast<PageNode *>(m);
2161 prev.first->setLink(Node::NextLink, page->title(), page->fullName());
2162 page->setLink(Node::PreviousLink, prev.first->title(), prev.second);
2164 prev = { page, page->fullName() };
2174 atom = atom->next();
2177 Config::instance().get(configVar).location()
2178 .warning(QStringLiteral(
"Failed to find table of contents with title '%1'")
2184 setSearchOrder(searchOrder);
void appendToRelatedByProxy(const NodeList &t)
Appends the list of node pointers to the list of elements that are related to this Aggregate but are ...
void resolveRelates()
Adopts each non-aggregate C++ node (function/macro, typedef, enum, variable, or a shared comment node...
void resolveQmlInheritance()
Resolves the inheritance information for all QML type children of this aggregate.
void normalizeOverloads()
Sorts the lists of overloads in the function map and assigns overload numbers.
NodeList & relatedByProxy()
void findAllNamespaces(NodeMultiMap &namespaces)
For each child of this node, if the child is a namespace node, insert the child into the namespaces m...
void markUndocumentedChildrenInternal()
Mark all child nodes that have no documentation as having internal status.
FunctionNode * findFunctionChild(const FunctionNode *clone)
Returns the function node that is a child of this node, such that the function described has the same...
The Atom class is the fundamental unit for representing documents internally.
AtomType type() const
Return the type of this atom.
virtual bool isLinkAtom() const
A class for holding the members of a collection of doc pages.
This node is used to represent any kind of function being documented.
This class represents a C++ namespace.
This class provides exclusive access to the qdoc database, which consists of a forrest of trees and a...
const Node * findTypeNode(const QString &type, const Node *relative, Genus genus)
This function is called for autolinking to a type, which could be a function return type or a paramet...
NodeMapMap & getFunctionIndex()
Returns the function index.
const NodeMultiMap & getClassMap(const QString &key)
Find the key in the map of new class maps, and return a reference to the value, which is a NodeMap.
QmlTypeNode * findQmlType(const QString &qmid, const QString &name, const Node *relative=nullptr, Tree *tree=nullptr)
Returns the QML type node identified by the QML module id qmid and QML type name, or nullptr if no ty...
const Node * findQmlNode(const QString &path, const Node *relative, FindFlags flags, Tree *tree=nullptr)
Returns the node to a piece of QML API documentation that corresponds to the given path,...
const NodeMultiMap & getQmlTypeMap(const QString &key)
Find the key in the map of new QML type maps, and return a reference to the value,...
void resolveNamespaces()
Multiple namespace nodes for namespace X can exist in the qdoc database in different trees.
TextToNodeMap & getLegaleseTexts()
Returns a reference to the collection of legalese texts.
const Node * findNodeForTarget(const QString &target, const Node *relative, Genus genus, const QString &moduleName, QString *ref=nullptr, LinkReferenceOrigin origin=LinkReferenceOrigin::Auto, int searchFlags=0)
Finds the node for target relative to relative, with genus and module scoping.
NodeMultiMap & getAttributions()
Returns a reference to the multimap of attribution nodes.
static void destroyQdocDB()
Destroys the singleton.
NodeMultiMap & getQmlTypesWithObsoleteMembers()
Returns a reference to the map of QML types with obsolete members.
NodeMultiMap & getObsoleteQmlTypes()
Returns a reference to the map of obsolete QML types.
QmlTypeNode * findQmlType(const ImportRec &import, const QString &name, const Node *relative=nullptr)
const FunctionNode * findFunctionNode(const QString &target, const Node *relative, Genus genus)
Finds the function node for the qualified function path in target and returns a pointer to it.
static QDocDatabase * qdocDB()
Creates the singleton.
void generateIndex(const QString &fileName, const QString &url, const QString &title, const IndexSerializationContext &context)
Generates a qdoc index file and writes it to fileName.
void resolveBaseClasses()
NodeMultiMap & getQmlTypes()
Returns a reference to the multimap of QML types.
NodeMultiMap & getClassesWithObsoleteMembers()
Returns a reference to the map of C++ classes with obsolete members.
NodeMultiMap & getQmlValueTypes()
Returns a reference to the map of QML basic types.
NodeMultiMap & getCppClasses()
Returns a reference to the map of all C++ classes.
QStringList groupNamesForNode(Node *node)
NamespaceNode * primaryTreeRoot()
Returns a pointer to the root node of the primary tree.
void readIndexes(const QStringList &indexFiles)
Reads and parses the qdoc index files listed in indexFiles.
void resolveConceptUsers()
Builds the concept-to-users reverse index after parsing finishes and before any generator runs.
const Node * findNodeForTarget(const QString &target, const Node *relative)
Finds the node that will generate the documentation that contains the target and returns a pointer to...
const Node * findNodeForAtom(const Atom *atom, const Node *relative, QString &ref, Genus genus=Genus::DontCare)
Searches for the node that matches the path in atom and the specified genus.
void mergeCollections(NodeType type, CNMap &cnm, const Node *relative)
Finds all the collection nodes of the specified type and merges them into the collection node map cnm...
NodeMultiMap & getNamespaces()
Returns a reference to the namespace map.
QmlTypeNode * findQmlTypeInPrimaryTree(const QString &qmid, const QString &name)
Returns the QML node identified by the QML module id qmid and name, searching in the primary tree onl...
const NodeMultiMap & getSinceMap(const QString &key)
Find the key in the map of new {since} maps, and return a reference to the value, which is a NodeMult...
NodeMultiMap & getExamples()
Returns a reference to the multimap of example nodes.
void processForest()
This function calls a set of functions for each tree in the forest that has not already been analyzed...
void(QDocDatabase::*)(Aggregate *) FindFunctionPtr
void updateNavigation()
Updates navigation (previous/next page links and the navigation parent) for pages listed in the TOC,...
void resolveStuff()
Performs several housekeeping tasks prior to generating the documentation.
NodeMultiMap & getObsoleteClasses()
Returns a reference to the map of obsolete C++ clases.
const CollectionNode * getModuleNode(const Node *relative)
Returns the collection node representing the module that relative node belongs to,...
void resolveProxies()
Each instance of class Tree that represents an index file must be traversed to find all instances of ...
void mergeCollections(CollectionNode *c)
Finds all the collection nodes with the same name and type as c and merges their members into the mem...
A class representing a forest of Tree objects.
This class imports QDoc index files and serializes index sections for module indexes and WebXML outpu...
const ImportList & importList() const
This class constructs and maintains a tree of instances of the subclasses of Node.
void markDontDocumentNodes()
The {don't document} map has been loaded with the names of classes and structs in the current module ...
void resolveProperties()
Resolves access functions associated with each PropertyNode stored in m_unresolvedPropertyMap,...
#define CONFIG_NOLINKERRORS
#define CONFIG_NAVIGATION
QMultiMap< QString, CollectionNode * > CNMultiMap
QMap< QString, NodeMultiMap > NodeMultiMapMap
QMap< QString, Node * > NodeMap
QMap< QString, NodeMap > NodeMapMap
QMap< QString, CollectionNode * > CNMap
static void collectConceptReferences(const Node *node, QStringList &refs)
Gathers the fully-qualified concept names referenced by node.
static void registerConceptUsersUnder(Aggregate *parent, QDocDatabase &db)
Walks every documented node under parent and registers each constrained item as a member of the conce...
static NodeMultiMap emptyNodeMultiMap_
QT_BEGIN_NAMESPACE typedef QMultiMap< Text, const Node * > TextToNodeMap
QList< ImportRec > ImportList
The Node class is the base class for all the nodes in QDoc's parse tree.
bool isQmlType() const
Returns true if the node type is QmlType or QmlValueType.
Genus genus() const override
Returns this node's Genus.
virtual bool isPageNode() const
Returns true if this node represents something that generates a documentation page.
Aggregate * parent() const
Returns the node's parent pointer, that is, the aggregate under which the node is documented.
const std::optional< RelaxedTemplateDeclaration > & templateDecl() const
bool isFunction(Genus g=Genus::DontCare) const
Returns true if this is a FunctionNode and its Genus is set to g.
virtual Tree * tree() const
Returns a pointer to the Tree this node is in.
A class for parsing and managing a function parameter list.
A record of a linkable target within the documentation.
TargetType
A type of a linkable target record.