34#include <QtCore/qlist.h>
35#include <QtCore/qmap.h>
36#include <QtCore/quuid.h>
37#include <QtCore/qurl.h>
38#include <QtCore/qregularexpression.h>
39#include <QtCore/qversionnumber.h>
47using namespace Qt::StringLiterals;
49static const char dbNamespace[] =
"http://docbook.org/ns/docbook";
57 m_writer->writeCharacters(
"\n");
65 m_writer->writeAttribute(
"xml:id", registerRef(id,
true));
78 QString id = Generator::cleanRef(refForNode(node),
true);
80 m_writer->writeAttribute(
"xml:id", id);
87 m_writer->writeStartElement(dbNamespace,
"section");
90 m_writer->writeStartElement(dbNamespace,
"title");
95 m_writer->writeStartElement(dbNamespace,
"section");
98 m_writer->writeStartElement(dbNamespace,
"title");
103 m_writer->writeEndElement();
109 startSectionBegin(id);
110 m_writer->writeCharacters(title);
116 startSectionBegin(node);
117 m_writer->writeCharacters(title);
124 startSection(
"", title);
129 m_writer->writeEndElement();
138 m_writer->writeEmptyElement(dbNamespace,
"anchor");
144
145
146
151 m_config = &Config::instance();
157 if (m_projectDescription.isEmpty() && !m_project.isEmpty())
158 m_projectDescription = m_project + QLatin1String(
" Reference Documentation");
161 if (m_naturalLanguage.isEmpty())
162 m_naturalLanguage = QLatin1String(
"en");
166 m_config->get(format() + Config::dot +
"usedocbookextensions").asBool();
167 m_useITS = m_config->get(format() + Config::dot +
"its").asBool();
176
177
184
185
186
187
202 QString rewritten = code;
203 static const QRegularExpression re(
"(<@[^>&]*>)|(<\\/@[^&>]*>)");
204 rewritten.replace(re,
"");
209
210
216 qsizetype skipAhead = 0;
217 Genus genus = Genus::DontCare;
225 if (!m_inLink && !m_inContents && !m_inSectionHeading) {
226 const Node *node =
nullptr;
227 QString link = getAutoLink(atom, relative, &node, genus);
232 if (link.isEmpty()) {
233 m_writer->writeCharacters(atom->string());
235 beginLink(link, node, relative);
240 m_writer->writeCharacters(atom->string());
255 m_writer->writeStartElement(dbNamespace,
"para");
261 m_writer->writeEndElement();
271 m_writer->writeCharacters(plainCode(atom->string()));
273 m_writer->writeTextElement(dbNamespace,
"code", plainCode(atom->string()));
275 case Atom::CaptionLeft:
276 m_writer->writeStartElement(dbNamespace,
"title");
280 m_writer->writeEndElement();
284 m_writer->writeStartElement(dbNamespace,
"programlisting");
285 m_writer->writeAttribute(
"language",
"qml");
287 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
288 m_writer->writeCharacters(plainCode(removeCodeMarkers(atom->string())));
289 m_writer->writeEndElement();
293 m_writer->writeStartElement(dbNamespace,
"programlisting");
295 if (atom->strings().count() == 2)
296 m_writer->writeAttribute(
"language", atom->string(1));
298 m_writer->writeAttribute(
"language",
"cpp");
300 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
301 m_writer->writeCharacters(plainCode(removeCodeMarkers(atom->string())));
302 m_writer->writeEndElement();
306 m_writer->writeStartElement(dbNamespace,
"programlisting");
307 m_writer->writeAttribute(
"language",
"cpp");
308 m_writer->writeAttribute(
"role",
"bad");
310 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
311 m_writer->writeCharacters(plainCode(removeCodeMarkers(atom->string())));
312 m_writer->writeEndElement();
319 qsizetype offset{ 0 };
328 case Atom::FootnoteLeft:
329 m_writer->writeStartElement(dbNamespace,
"footnote");
331 m_writer->writeStartElement(dbNamespace,
"para");
334 case Atom::FootnoteRight:
335 m_writer->writeEndElement();
338 m_writer->writeEndElement();
346 m_writer->writeStartElement(dbNamespace,
"emphasis");
347 m_writer->writeAttribute(
"role",
"bold");
349 m_writer->writeStartElement(dbNamespace,
"emphasis");
351 m_writer->writeStartElement(dbNamespace,
"emphasis");
352 m_writer->writeAttribute(
"role",
"underline");
354 m_writer->writeStartElement(dbNamespace,
"subscript");
356 m_writer->writeStartElement(dbNamespace,
"superscript");
359 m_writer->writeStartElement(dbNamespace,
"code");
361 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
364 m_writer->writeAttribute(
"role",
"parameter");
368 m_writer->writeStartElement(dbNamespace,
"guilabel");
370 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
372 m_writer->writeStartElement(dbNamespace,
373 appendTrademark(atom->find(Atom::FormattingRight)) ?
374 "trademark" :
"phrase");
376 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
378 m_writer->writeStartElement(dbNamespace,
"phrase");
380 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
382 relative
->location().warning(QStringLiteral(
"Unsupported formatting: %1").arg(atom->string()));
395 m_writer->writeEndElement();
398 m_inTeletype =
false;
401 relative
->location().warning(QStringLiteral(
"Unsupported formatting: %1").arg(atom->string()));
405 if (
const CollectionNode *cn = m_qdb->getCollectionNode(atom->string(), NodeType::Group))
406 generateList(cn, atom->string(), Generator::sortOrder(atom->strings().last()));
409 const auto sortOrder{Generator::sortOrder(atom->strings().last())};
410 bool hasGeneratedSomething =
false;
411 if (atom->string() == QLatin1String(
"annotatedclasses")
412 || atom->string() == QLatin1String(
"attributions")
413 || atom->string() == QLatin1String(
"namespaces")) {
414 const NodeMultiMap things = atom->string() == QLatin1String(
"annotatedclasses")
415 ? m_qdb->getCppClasses()
416 : atom->string() == QLatin1String(
"attributions") ? m_qdb->getAttributions()
417 : m_qdb->getNamespaces();
418 generateAnnotatedList(relative, things.values(), atom->string(), Auto, sortOrder);
419 hasGeneratedSomething = !things.isEmpty();
420 }
else if (atom->string() == QLatin1String(
"annotatedexamples")
421 || atom->string() == QLatin1String(
"annotatedattributions")) {
422 const NodeMultiMap things = atom->string() == QLatin1String(
"annotatedexamples")
423 ? m_qdb->getExamples()
424 : m_qdb->getAttributions();
425 generateAnnotatedLists(relative, things, atom->string());
426 hasGeneratedSomething = !things.isEmpty();
427 }
else if (atom->string() == QLatin1String(
"classes")
428 || atom->string() == QLatin1String(
"qmlbasictypes")
429 || atom->string() == QLatin1String(
"qmlvaluetypes")
430 || atom->string() == QLatin1String(
"qmltypes")) {
431 const NodeMultiMap things = atom->string() == QLatin1String(
"classes")
432 ? m_qdb->getCppClasses()
433 : (atom->string() == QLatin1String(
"qmlvaluetypes")
434 || atom->string() == QLatin1String(
"qmlbasictypes"))
435 ? m_qdb->getQmlValueTypes()
436 : m_qdb->getQmlTypes();
437 generateCompactList(relative, things,
true, QString(), atom->string());
438 hasGeneratedSomething = !things.isEmpty();
439 }
else if (atom->string().contains(
"classes ")) {
440 QString rootName = atom->string().mid(atom->string().indexOf(
"classes") + 7).trimmed();
443 hasGeneratedSomething = !things.isEmpty();
444 generateCompactList(relative, things,
true, rootName, atom->string());
445 }
else if ((idx = atom->string().indexOf(QStringLiteral(
"bymodule"))) != -1) {
446 QString moduleName = atom->string().mid(idx + 8).trimmed();
449 if (
const CollectionNode *cn = qdb->getCollectionNode(moduleName, moduleType)) {
451 switch (moduleType) {
457 if (atom->string().contains(QLatin1String(
"qmlvaluetypes")))
463 generateAnnotatedList(relative, cn->members(), atom->string(), Auto, sortOrder);
467 if (!map.isEmpty()) {
468 generateAnnotatedList(relative, map.values(), atom->string(), Auto, sortOrder);
469 hasGeneratedSomething =
true;
472 }
else if (atom->string() == QLatin1String(
"classhierarchy")) {
473 generateClassHierarchy(relative, m_qdb->getCppClasses());
474 hasGeneratedSomething = !m_qdb->getCppClasses().isEmpty();
475 }
else if (atom->string().startsWith(
"obsolete")) {
476 QString prefix = atom->string().contains(
"cpp") ? QStringLiteral(
"Q") : QString();
477 const NodeMultiMap &things = atom->string() == QLatin1String(
"obsoleteclasses")
478 ? m_qdb->getObsoleteClasses()
479 : atom->string() == QLatin1String(
"obsoleteqmltypes")
480 ? m_qdb->getObsoleteQmlTypes()
481 : atom->string() == QLatin1String(
"obsoletecppmembers")
482 ? m_qdb->getClassesWithObsoleteMembers()
483 : m_qdb->getQmlTypesWithObsoleteMembers();
484 generateCompactList(relative, things,
false, prefix, atom->string());
485 hasGeneratedSomething = !things.isEmpty();
486 }
else if (atom->string() == QLatin1String(
"functionindex")) {
487 generateFunctionIndex(relative);
488 hasGeneratedSomething = !m_qdb->getFunctionIndex().isEmpty();
489 }
else if (atom->string() == QLatin1String(
"legalese")) {
490 generateLegaleseList(relative);
491 hasGeneratedSomething = !m_qdb->getLegaleseTexts().isEmpty();
492 }
else if (atom->string() == QLatin1String(
"overviews")
493 || atom->string() == QLatin1String(
"cpp-modules")
494 || atom->string() == QLatin1String(
"qml-modules")
495 || atom->string() == QLatin1String(
"related")) {
496 generateList(relative, atom->string());
497 hasGeneratedSomething =
true;
499 }
else if (
const auto *cn = m_qdb->getCollectionNode(atom->string(), NodeType::Group); cn) {
500 generateAnnotatedList(cn, cn->members(), atom->string(), ItemizedList, sortOrder);
501 hasGeneratedSomething =
true;
506 if (!hasGeneratedSomething && !m_inPara) {
507 m_writer->writeEmptyElement(dbNamespace,
"para");
539 m_writer->writeStartElement(dbNamespace,
"figure");
546 generateAtom(current, relative,
nullptr);
551 generateAtom(current, relative,
nullptr);
557 generateAtom(current, relative,
nullptr);
561 m_closeFigureWrapper =
true;
572 m_writer->writeStartElement(dbNamespace,
"figure");
579 generateAtom(current, relative,
nullptr);
584 generateAtom(current, relative,
nullptr);
590 generateAtom(current, relative,
nullptr);
594 m_closeFigureWrapper =
true;
617 m_writer->writeStartElement(dbNamespace, tag);
620 auto maybe_resolved_file{file_resolver.resolve(atom->string())};
621 if (!maybe_resolved_file) {
623 relative
->location().warning(QStringLiteral(
"Missing image: %1").arg(atom->string()));
625 m_writer->writeStartElement(dbNamespace,
"textobject");
627 m_writer->writeStartElement(dbNamespace,
"para");
628 m_writer->writeTextElement(dbNamespace,
"emphasis",
629 "[Missing image " + atom->string() +
"]");
630 m_writer->writeEndElement();
632 m_writer->writeEndElement();
636 QString file_name{QFileInfo{file.get_path()}.fileName()};
640 "%1/%2"_L1.arg(outputDir(), imagesOutputDir()));
644 m_writer->writeTextElement(dbNamespace,
"alt", atom->next()->string());
648 m_writer->writeStartElement(dbNamespace,
"imageobject");
650 m_writer->writeEmptyElement(dbNamespace,
"imagedata");
651 const auto &imgPath =
"%1/%2"_L1.arg(imagesOutputDir(), file_name);
653 m_writer->writeAttribute(
"fileref", imgPath);
655 m_writer->writeEndElement();
659 setImageFileName(relative, imgPath);
662 m_writer->writeEndElement();
666 if (m_closeFigureWrapper) {
667 m_writer->writeEndElement();
669 m_closeFigureWrapper =
false;
677 QString admonType = atom->typeString().toLower();
680 m_writer->writeStartElement(dbNamespace, admonType);
682 m_writer->writeStartElement(dbNamespace,
"para");
685 case Atom::ImportantRight:
686 case Atom::NoteRight:
687 case Atom::WarningRight:
688 m_writer->writeEndElement();
691 m_writer->writeEndElement();
699 const Node *node =
nullptr;
700 QString link = getLink(atom, relative, &node);
701 beginLink(link, node, relative);
705 const Node *node =
static_cast<
const Node*>(Utilities::nodeForString(atom->string()));
706 beginLink(linkForNode(node, relative), node, relative);
716 m_writer->writeEndElement();
722 m_writer->writeStartElement(dbNamespace,
"itemizedlist");
725 m_writer->writeStartElement(dbNamespace,
"variablelist");
728 m_writer->writeStartElement(dbNamespace,
"informaltable");
730 m_writer->writeStartElement(dbNamespace,
"thead");
732 m_writer->writeStartElement(dbNamespace,
"tr");
734 m_writer->writeTextElement(dbNamespace,
"th",
"Constant");
737 m_threeColumnEnumValueTable = isThreeColumnEnumValueTable(atom);
738 if (m_threeColumnEnumValueTable && relative->isEnumType(Genus::CPP)) {
740 m_writer->writeTextElement(dbNamespace,
"th",
"Value");
745 m_writer->writeTextElement(dbNamespace,
"th",
"Description");
749 m_writer->writeEndElement();
751 m_writer->writeEndElement();
754 m_writer->writeStartElement(dbNamespace,
"orderedlist");
756 if (atom->next() !=
nullptr && atom->next()->string().toInt() != 1)
757 m_writer->writeAttribute(
"startingnumber", atom->next()->string());
760 m_writer->writeAttribute(
"numeration",
"upperalpha");
762 m_writer->writeAttribute(
"numeration",
"loweralpha");
764 m_writer->writeAttribute(
"numeration",
"upperroman");
766 m_writer->writeAttribute(
"numeration",
"lowerroman");
768 m_writer->writeAttribute(
"numeration",
"arabic");
778 m_writer->writeStartElement(dbNamespace,
"varlistentry");
780 m_writer->writeStartElement(dbNamespace,
"item");
782 std::pair<QString,
int> pair = getAtomListValue(atom);
783 skipAhead = pair.second;
785 m_writer->writeStartElement(dbNamespace,
"tr");
787 m_writer->writeStartElement(dbNamespace,
"td");
789 m_writer->writeStartElement(dbNamespace,
"para");
791 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
792 generateEnumValue(pair.first, relative);
793 m_writer->writeEndElement();
795 m_writer->writeEndElement();
799 const auto enume =
static_cast<
const EnumNode *>(relative);
800 QString itemValue = enume->itemValue(atom
->next()->string());
802 m_writer->writeStartElement(dbNamespace,
"td");
803 if (itemValue.isEmpty())
804 m_writer->writeCharacters(
"?");
806 m_writer->writeStartElement(dbNamespace,
"code");
808 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
809 m_writer->writeCharacters(itemValue);
810 m_writer->writeEndElement();
812 m_writer->writeEndElement();
820 m_writer->writeEndElement();
826 m_writer->writeEndElement();
833 m_inListItemLineOpen =
false;
835 m_writer->writeStartElement(dbNamespace,
"listitem");
837 m_writer->writeStartElement(dbNamespace,
"para");
840 if (m_threeColumnEnumValueTable) {
842 m_writer->writeEmptyElement(dbNamespace,
"td");
844 m_inListItemLineOpen =
false;
846 m_writer->writeStartElement(dbNamespace,
"td");
848 m_inListItemLineOpen =
true;
852 m_writer->writeStartElement(dbNamespace,
"listitem");
861 m_writer->writeEndElement();
864 m_writer->writeEndElement();
866 m_writer->writeEndElement();
869 if (m_inListItemLineOpen) {
870 m_writer->writeEndElement();
872 m_inListItemLineOpen =
false;
874 m_writer->writeEndElement();
877 m_writer->writeEndElement();
882 case Atom::ListRight:
888 m_writer->writeEndElement();
895 m_writer->writeStartElement(dbNamespace,
"para");
901 m_writer->writeEndElement();
906 case Atom::QuotationLeft:
907 m_writer->writeStartElement(dbNamespace,
"blockquote");
908 m_inBlockquote =
true;
910 case Atom::QuotationRight:
911 m_writer->writeEndElement();
913 m_inBlockquote =
false;
916 m_writer->device()->write(atom->string().toUtf8());
922 currentSectionLevel = atom->string().toInt() +
hOffset(relative
);
924 if (currentSectionLevel > 1) {
927 while (!sectionLevels.empty() && sectionLevels.top() >= currentSectionLevel) {
929 m_writer->writeEndElement();
933 sectionLevels.push(currentSectionLevel);
935 m_writer->writeStartElement(dbNamespace,
"section");
936 writeXmlId(Tree::refForAtom(atom));
949 generateAtom(atom->next(), relative,
nullptr);
950 generateAtom(atom->next()->next(), relative,
nullptr);
951 generateAtom(atom->next()->next()->next(), relative,
nullptr);
953 m_closeSectionAfterGeneratedList =
true;
960 m_writer->writeTextElement(dbNamespace,
"title",
"");
969 if (currentSectionLevel > 1) {
970 m_writer->writeStartElement(dbNamespace,
"title");
971 m_inSectionHeading =
true;
976 if (currentSectionLevel > 1) {
977 m_writer->writeEndElement();
979 m_inSectionHeading =
false;
982 case Atom::SidebarLeft:
983 m_writer->writeStartElement(dbNamespace,
"sidebar");
985 case Atom::SidebarRight:
986 m_writer->writeEndElement();
990 if (m_inLink && !m_inContents && !m_inSectionHeading)
993 m_writer->writeCharacters(atom->string());
996 std::pair<QString, QString> pair = getTableWidthAttr(atom);
997 QString attr = pair.second;
998 QString width = pair.first;
1001 m_writer->writeEndElement();
1006 m_tableHeaderAlreadyOutput =
false;
1008 m_writer->writeStartElement(dbNamespace,
"informaltable");
1009 m_writer->writeAttribute(
"style", attr);
1010 if (!width.isEmpty())
1011 m_writer->writeAttribute(
"width", width);
1014 case Atom::TableRight:
1015 m_tableWidthAttr = {
"",
""};
1016 m_writer->writeEndElement();
1025 if (m_tableHeaderAlreadyOutput) {
1028 m_writer->writeEndElement();
1031 const QString &attr = m_tableWidthAttr.second;
1032 const QString &width = m_tableWidthAttr.first;
1034 m_writer->writeStartElement(dbNamespace,
"informaltable");
1035 m_writer->writeAttribute(
"style", attr);
1036 if (!width.isEmpty())
1037 m_writer->writeAttribute(
"width", width);
1040 m_tableHeaderAlreadyOutput =
true;
1046 id = TextUtils::asAsciiPrintable(next->string());
1051 m_writer->writeStartElement(dbNamespace,
"thead");
1053 m_writer->writeStartElement(dbNamespace,
"tr");
1056 m_inTableHeader =
true;
1059 m_closeTableCell =
true;
1060 m_writer->writeStartElement(dbNamespace,
"td");
1066 if (m_closeTableCell) {
1067 m_closeTableCell =
false;
1068 m_writer->writeEndElement();
1072 m_writer->writeEndElement();
1076 m_writer->writeStartElement(dbNamespace,
"tr");
1079 m_writer->writeEndElement();
1081 m_inTableHeader =
false;
1091 bool hasTarget {
false};
1093 id = TextUtils::asAsciiPrintable(atom
->next()->string());
1098 m_writer->writeStartElement(dbNamespace,
"tr");
1101 if (atom->string().isEmpty()) {
1102 m_writer->writeAttribute(
"valign",
"top");
1107 QStringList args = atom->string().split(
"\"", Qt::SkipEmptyParts);
1110 const int nArgs = args.size();
1115 QStringLiteral(
"Error when parsing attributes for the table: got \"%1\"")
1116 .arg(atom->string()));
1118 for (
int i = 0; i + 1 < nArgs; i += 2) {
1121 const QString &attr = args.at(i).chopped(1);
1124 writeXmlId(args.at(i + 1));
1126 m_writer->writeAttribute(attr, args.at(i + 1));
1142 m_closeTableRow =
true;
1143 m_writer->writeEndElement();
1149 if (m_closeTableRow) {
1150 m_closeTableRow =
false;
1151 m_writer->writeEndElement();
1155 m_writer->writeEndElement();
1158 case Atom::TableItemLeft:
1159 m_writer->writeStartElement(dbNamespace, m_inTableHeader ?
"th" :
"td");
1161 for (
int i = 0; i < atom->count(); ++i) {
1162 const QString &p = atom->string(i);
1163 if (p.contains(
'=')) {
1164 QStringList lp = p.split(QLatin1Char(
'='));
1165 m_writer->writeAttribute(lp.at(0), lp.at(1));
1167 QStringList spans = p.split(QLatin1Char(
','));
1168 if (spans.size() == 2) {
1169 if (spans.at(0) !=
"1")
1170 m_writer->writeAttribute(
"colspan", spans.at(0).trimmed());
1171 if (spans.at(1) !=
"1")
1172 m_writer->writeAttribute(
"rowspan", spans.at(1).trimmed());
1179 case Atom::TableItemRight:
1180 m_writer->writeEndElement();
1192 QString nextId = TextUtils::asAsciiPrintable(
1194 QString ownId = TextUtils::asAsciiPrintable(atom->string());
1195 if (nextId == ownId)
1199 writeAnchor(TextUtils::asAsciiPrintable(atom->string()));
1201 case Atom::UnhandledFormat:
1202 m_writer->writeStartElement(dbNamespace,
"emphasis");
1203 m_writer->writeAttribute(
"role",
"bold");
1204 m_writer->writeCharacters(
"<Missing DocBook>");
1205 m_writer->writeEndElement();
1207 case Atom::UnknownCommand:
1208 m_writer->writeStartElement(dbNamespace,
"emphasis");
1209 m_writer->writeAttribute(
"role",
"bold");
1211 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
1212 m_writer->writeCharacters(
"<Unknown command>");
1213 m_writer->writeStartElement(dbNamespace,
"code");
1214 m_writer->writeCharacters(atom->string());
1215 m_writer->writeEndElement();
1216 m_writer->writeEndElement();
1236 if (classMap.isEmpty())
1239 std::function<
void(
ClassNode *)> generateClassAndChildren
1240 = [
this, &relative, &generateClassAndChildren](ClassNode * classe) {
1241 m_writer->writeStartElement(dbNamespace,
"listitem");
1245 m_writer->writeStartElement(dbNamespace,
"para");
1246 generateFullName(classe, relative);
1247 m_writer->writeEndElement();
1251 bool hasChild =
false;
1252 for (
const RelatedClass &relatedClass : classe->derivedClasses()) {
1253 if (relatedClass.m_node && relatedClass.m_node->isInAPI()) {
1260 m_writer->writeStartElement(dbNamespace,
"itemizedlist");
1263 for (
const RelatedClass &relatedClass: classe->derivedClasses()) {
1264 if (relatedClass.m_node && relatedClass.m_node->isInAPI()) {
1265 generateClassAndChildren(relatedClass.m_node);
1269 m_writer->writeEndElement();
1274 m_writer->writeEndElement();
1278 m_writer->writeStartElement(dbNamespace,
"itemizedlist");
1281 for (
const auto &it : classMap) {
1282 auto *classe =
static_cast<ClassNode *>(it);
1283 if (classe->baseClasses().isEmpty())
1284 generateClassAndChildren(classe);
1287 m_writer->writeEndElement();
1296 if (m_linkNode && m_linkNode->isFunction()) {
1298 if (match.hasMatch()) {
1300 qsizetype leftParenLoc = match.capturedStart(1);
1301 m_writer->writeCharacters(atom->string().left(leftParenLoc));
1303 m_writer->writeCharacters(atom->string().mid(leftParenLoc));
1307 m_writer->writeCharacters(atom->string());
1311
1312
1313
1317 m_writer->writeStartElement(dbNamespace,
"link");
1318 m_writer->writeAttribute(xlinkNamespace,
"href", link);
1319 if (node && !(relative && node->status() == relative->status())
1320 && node->isDeprecated())
1321 m_writer->writeAttribute(
"role",
"deprecated");
1330 m_writer->writeEndElement();
1332 m_linkNode =
nullptr;
1336 Qt::SortOrder sortOrder)
1341 if (selector == QLatin1String(
"overviews"))
1343 else if (selector == QLatin1String(
"cpp-modules"))
1345 else if (selector == QLatin1String(
"qml-modules"))
1350 m_qdb->mergeCollections(type, cnm, relative);
1351 const QList<CollectionNode *> collectionList = cnm.values();
1352 nodeList.reserve(collectionList.size());
1353 for (
auto *collectionNode : collectionList)
1354 nodeList.append(collectionNode);
1355 generateAnnotatedList(relative, nodeList, selector, Auto, sortOrder);
1358
1359
1360
1361 Node *n =
const_cast<
Node *>(relative);
1362 auto *cn =
static_cast<CollectionNode *>(n);
1363 m_qdb->mergeCollections(cn);
1364 generateAnnotatedList(cn, cn->members(), selector, Auto, sortOrder);
1369
1370
1371
1373 const QString &selector, GeneratedListType type,
1374 Qt::SortOrder sortOrder)
1376 if (nodeList.isEmpty())
1380 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
1381 if (
std::all_of(nodeList.cbegin(), nodeList.cend(), [&policy](
const Node *n) {
1383 return !InclusionFilter::isIncluded(policy, context) || n->isDeprecated();
1390 bool noItemsHaveTitle =
1391 type == ItemizedList ||
std::all_of(nodeList.begin(), nodeList.end(),
1392 [](
const Node* node) {
1393 return node->doc().briefText().toString().isEmpty();
1397 if (type == AutoSection && m_hasSection)
1398 startSection(
"",
"Contents");
1401 if (!nodeList.isEmpty()) {
1402 m_writer->writeStartElement(dbNamespace, noItemsHaveTitle ?
"itemizedlist" :
"variablelist");
1403 m_writer->writeAttribute(
"role", selector);
1407 members.reserve(nodeList.size());
1408 std::copy_if(nodeList.cbegin(), nodeList.cend(),
std::back_inserter(members),
1409 [&policy](
const Node *n) {
1411 return InclusionFilter::isIncluded(policy, context) && !n->isDeprecated();
1414 if (sortOrder == Qt::DescendingOrder)
1420 auto sameLocation = [
this](
const Node *a,
const Node *b) {
1421 return fullDocumentLocation(a) == fullDocumentLocation(b);
1423 members.erase(
std::unique(members.begin(), members.end(), sameLocation), members.end());
1425 for (
const auto &node : std::as_const(members)) {
1426 if (noItemsHaveTitle) {
1427 m_writer->writeStartElement(dbNamespace,
"listitem");
1429 m_writer->writeStartElement(dbNamespace,
"para");
1431 m_writer->writeStartElement(dbNamespace,
"varlistentry");
1433 m_writer->writeStartElement(dbNamespace,
"term");
1435 generateFullName(node, relative);
1436 if (noItemsHaveTitle) {
1437 m_writer->writeEndElement();
1439 m_writer->writeEndElement();
1441 m_writer->writeEndElement();
1443 m_writer->writeStartElement(dbNamespace,
"listitem");
1445 m_writer->writeStartElement(dbNamespace,
"para");
1446 m_writer->writeCharacters(node->doc().briefText().toString());
1447 m_writer->writeEndElement();
1449 m_writer->writeEndElement();
1451 m_writer->writeEndElement();
1456 m_writer->writeEndElement();
1460 if (type == AutoSection && m_hasSection)
1465
1466
1467
1469 const QString &selector)
1472 for (
const QString &name : nmm.uniqueKeys()) {
1473 if (!name.isEmpty())
1474 startSection(name.toLower(), name);
1475 generateAnnotatedList(relative, nmm.values(name), selector);
1476 if (!name.isEmpty())
1482
1483
1484
1485
1486
1487
1488
1489
1490
1492 bool includeAlphabet,
const QString &commonPrefix,
1493 const QString &selector)
1503 const int NumParagraphs = 37;
1504 qsizetype commonPrefixLen = commonPrefix.size();
1507
1508
1509
1510
1511
1513 QString paragraphName[NumParagraphs + 1];
1514 QSet<
char> usedParagraphNames;
1516 for (
auto c = nmm.constBegin(); c != nmm.constEnd(); ++c) {
1517 QStringList pieces = c.key().split(
"::");
1518 int idx = commonPrefixLen;
1519 if (idx > 0 && !pieces.last().startsWith(commonPrefix, Qt::CaseInsensitive))
1521 QString last = pieces.last().toLower();
1522 QString key = last.mid(idx);
1524 int paragraphNr = NumParagraphs - 1;
1526 if (key[0].digitValue() != -1) {
1527 paragraphNr = key[0].digitValue();
1528 }
else if (key[0] >= QLatin1Char(
'a') && key[0] <= QLatin1Char(
'z')) {
1529 paragraphNr = 10 + key[0].unicode() -
'a';
1532 paragraphName[paragraphNr] = key[0].toUpper();
1533 usedParagraphNames.insert(key[0].toLower().cell());
1534 paragraph[paragraphNr].insert(last, c.value());
1538
1539
1540
1541
1542
1543
1544
1545 int paragraphOffset[NumParagraphs + 1];
1546 paragraphOffset[0] = 0;
1547 for (
int i = 0; i < NumParagraphs; i++)
1548 paragraphOffset[i + 1] = paragraphOffset[i] + paragraph[i].size();
1551 if (includeAlphabet && !usedParagraphNames.isEmpty()) {
1552 m_writer->writeStartElement(dbNamespace,
"simplelist");
1555 for (
int i = 0; i < 26; i++) {
1557 if (usedParagraphNames.contains(
char(
'a' + i))) {
1558 m_writer->writeStartElement(dbNamespace,
"member");
1559 generateSimpleLink(ch, ch.toUpper());
1560 m_writer->writeEndElement();
1565 m_writer->writeEndElement();
1570 QHash<QString,
int> nameOccurrences;
1571 for (
const auto &[key, node] : nmm.asKeyValueRange()) {
1572 QStringList pieces{node->fullName(relative).split(
"::"_L1)};
1573 const QString &name{pieces.last()};
1574 nameOccurrences[name]++;
1579 int curParOffset = 0;
1581 m_writer->writeStartElement(dbNamespace,
"variablelist");
1582 m_writer->writeAttribute(
"role", selector);
1585 for (
int i = 0; i < nmm.size(); i++) {
1586 while ((curParNr < NumParagraphs) && (curParOffset == paragraph[curParNr].size())) {
1593 if (curParOffset == 0) {
1595 m_writer->writeEndElement();
1597 m_writer->writeEndElement();
1599 m_writer->writeEndElement();
1603 m_writer->writeStartElement(dbNamespace,
"varlistentry");
1604 if (includeAlphabet)
1605 writeXmlId(paragraphName[curParNr][0].toLower());
1608 m_writer->writeStartElement(dbNamespace,
"term");
1609 m_writer->writeStartElement(dbNamespace,
"emphasis");
1610 m_writer->writeAttribute(
"role",
"bold");
1611 m_writer->writeCharacters(paragraphName[curParNr]);
1612 m_writer->writeEndElement();
1613 m_writer->writeEndElement();
1616 m_writer->writeStartElement(dbNamespace,
"listitem");
1618 m_writer->writeStartElement(dbNamespace,
"itemizedlist");
1623 m_writer->writeStartElement(dbNamespace,
"listitem");
1625 m_writer->writeStartElement(dbNamespace,
"para");
1627 if ((curParNr < NumParagraphs) && !paragraphName[curParNr].isEmpty()) {
1628 NodeMultiMap::Iterator it;
1629 NodeMultiMap::Iterator next;
1630 it = paragraph[curParNr].begin();
1631 for (
int j = 0; j < curParOffset; j++)
1636 QStringList pieces{it.value()->fullName(relative).split(
"::"_L1)};
1637 const auto &name{pieces.last()};
1640 if (nameOccurrences[name] > 1) {
1641 const QString moduleName = it.value()->isQmlNode() ? it.value()->logicalModuleName()
1642 : it.value()->tree()->camelCaseModuleName();
1643 pieces.last().append(
": %1"_L1.arg(moduleName));
1647 m_writer->writeStartElement(dbNamespace,
"link");
1648 m_writer->writeAttribute(xlinkNamespace,
"href", linkForNode(*it, relative));
1649 if (
const QString type = targetType(it.value()); !type.isEmpty())
1650 m_writer->writeAttribute(
"role", type);
1651 m_writer->writeCharacters(pieces.last());
1652 m_writer->writeEndElement();
1655 if (pieces.size() > 1) {
1656 m_writer->writeCharacters(
" (");
1657 generateFullName(it.value()->parent(), relative);
1658 m_writer->writeCharacters(
")");
1662 m_writer->writeEndElement();
1664 m_writer->writeEndElement();
1669 m_writer->writeEndElement();
1671 m_writer->writeEndElement();
1673 m_writer->writeEndElement();
1676 m_writer->writeEndElement();
1685 m_writer->writeStartElement(dbNamespace,
"simplelist");
1686 m_writer->writeAttribute(
"role",
"functionIndex");
1688 for (
int i = 0; i < 26; i++) {
1690 m_writer->writeStartElement(dbNamespace,
"member");
1691 m_writer->writeAttribute(xlinkNamespace,
"href", QString(
"#") + ch);
1692 m_writer->writeCharacters(ch.toUpper());
1693 m_writer->writeEndElement();
1696 m_writer->writeEndElement();
1701 if (m_qdb->getFunctionIndex().isEmpty())
1703 char nextLetter =
'a';
1706 m_writer->writeStartElement(dbNamespace,
"itemizedlist");
1709 NodeMapMap &funcIndex = m_qdb->getFunctionIndex();
1710 QMap<QString, NodeMap>::ConstIterator f = funcIndex.constBegin();
1711 while (f != funcIndex.constEnd()) {
1712 m_writer->writeStartElement(dbNamespace,
"listitem");
1714 m_writer->writeStartElement(dbNamespace,
"para");
1715 m_writer->writeCharacters(f.key() +
": ");
1717 currentLetter = f.key()[0].unicode();
1718 while (islower(currentLetter) && currentLetter >= nextLetter) {
1719 writeAnchor(QString(nextLetter));
1723 NodeMap::ConstIterator s = (*f).constBegin();
1724 while (s != (*f).constEnd()) {
1725 m_writer->writeCharacters(
" ");
1726 generateFullName((*s)->parent(), relative);
1730 m_writer->writeEndElement();
1732 m_writer->writeEndElement();
1736 m_writer->writeEndElement();
1744 for (
auto it = legaleseTexts.cbegin(), end = legaleseTexts.cend(); it != end; ++it) {
1745 Text text = it.key();
1747 m_writer->writeStartElement(dbNamespace,
"itemizedlist");
1750 m_writer->writeStartElement(dbNamespace,
"listitem");
1752 m_writer->writeStartElement(dbNamespace,
"para");
1753 generateFullName(it.value(), relative);
1754 m_writer->writeEndElement();
1756 m_writer->writeEndElement();
1759 }
while (it != legaleseTexts.constEnd() && it.key() == text);
1760 m_writer->writeEndElement();
1775 m_writer->writeStartElement(dbNamespace,
"para");
1777 m_writer->writeEndElement();
1784 if (node->since().isEmpty())
1787 const auto *shared = node->isSharedCommentNode()
1788 ?
static_cast<
const SharedCommentNode *>(node) :
nullptr;
1789 const bool plural = shared && shared->collective().size() > 1;
1790 const Node *described = plural ? shared->collective().first() : node;
1794 m_writer->writeStartElement(dbNamespace,
"para");
1795 m_writer->writeCharacters((plural ?
"These "_L1 :
"This "_L1)
1796 + NodeText::nodeTypeDescription(described, number)
1797 + (plural ?
" were introduced in "_L1 :
" was introduced in "_L1)
1798 + formatSince(node) +
"."_L1);
1799 m_writer->writeEndElement();
1805
1806
1807
1813 if (!subTitle.isEmpty()) {
1814 m_writer->writeStartElement(dbNamespace,
"subtitle");
1815 if (isApiGenus(node->genus()) && m_useITS)
1816 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
1817 m_writer->writeCharacters(subTitle);
1818 m_writer->writeEndElement();
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1841 m_writer->writeStartElement(dbNamespace,
"info");
1843 m_writer->writeStartElement(dbNamespace,
"title");
1844 if (isApiGenus(node->genus()) && m_useITS)
1845 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
1847 m_writer->writeEndElement();
1852
1853
1854
1855
1856
1859 if (!m_productName.isEmpty() || !m_project.isEmpty()) {
1860 m_writer->writeTextElement(dbNamespace,
"productname", m_productName.isEmpty() ?
1861 m_project : m_productName);
1865 if (!m_buildVersion.isEmpty()) {
1866 m_writer->writeTextElement(dbNamespace,
"edition", m_buildVersion);
1870 if (!m_projectDescription.isEmpty()) {
1871 m_writer->writeTextElement(dbNamespace,
"titleabbrev", m_projectDescription);
1879 if (node && !node->links().empty()) {
1880 std::pair<QString, QString> linkPair;
1881 std::pair<QString, QString> anchorPair;
1882 const Node *linkNode;
1886 linkNode = m_qdb->findNodeForTarget(linkPair.first, node);
1887 if (!linkNode || linkNode == node)
1888 anchorPair = linkPair;
1890 anchorPair = anchorForNode(linkNode);
1892 m_writer->writeStartElement(dbNamespace,
"extendedlink");
1893 m_writer->writeAttribute(xlinkNamespace,
"type",
"extended");
1894 m_writer->writeEmptyElement(dbNamespace,
"link");
1895 m_writer->writeAttribute(xlinkNamespace,
"to", anchorPair.first);
1896 m_writer->writeAttribute(xlinkNamespace,
"type",
"arc");
1897 m_writer->writeAttribute(xlinkNamespace,
"arcrole",
"prev");
1898 if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty())
1899 m_writer->writeAttribute(xlinkNamespace,
"title", anchorPair.second);
1901 m_writer->writeAttribute(xlinkNamespace,
"title", linkPair.second);
1902 m_writer->writeEndElement();
1907 linkNode = m_qdb->findNodeForTarget(linkPair.first, node);
1908 if (!linkNode || linkNode == node)
1909 anchorPair = linkPair;
1911 anchorPair = anchorForNode(linkNode);
1913 m_writer->writeStartElement(dbNamespace,
"extendedlink");
1914 m_writer->writeAttribute(xlinkNamespace,
"type",
"extended");
1915 m_writer->writeEmptyElement(dbNamespace,
"link");
1916 m_writer->writeAttribute(xlinkNamespace,
"to", anchorPair.first);
1917 m_writer->writeAttribute(xlinkNamespace,
"type",
"arc");
1918 m_writer->writeAttribute(xlinkNamespace,
"arcrole",
"next");
1919 if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty())
1920 m_writer->writeAttribute(xlinkNamespace,
"title", anchorPair.second);
1922 m_writer->writeAttribute(xlinkNamespace,
"title", linkPair.second);
1923 m_writer->writeEndElement();
1928 linkNode = m_qdb->findNodeForTarget(linkPair.first, node);
1929 if (!linkNode || linkNode == node)
1930 anchorPair = linkPair;
1932 anchorPair = anchorForNode(linkNode);
1934 m_writer->writeStartElement(dbNamespace,
"extendedlink");
1935 m_writer->writeAttribute(xlinkNamespace,
"type",
"extended");
1936 m_writer->writeEmptyElement(dbNamespace,
"link");
1937 m_writer->writeAttribute(xlinkNamespace,
"to", anchorPair.first);
1938 m_writer->writeAttribute(xlinkNamespace,
"type",
"arc");
1939 m_writer->writeAttribute(xlinkNamespace,
"arcrole",
"start");
1940 if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty())
1941 m_writer->writeAttribute(xlinkNamespace,
"title", anchorPair.second);
1943 m_writer->writeAttribute(xlinkNamespace,
"title", linkPair.second);
1944 m_writer->writeEndElement();
1956 m_writer->writeStartElement(dbNamespace,
"abstract");
1959 bool generatedSomething =
false;
1963 node->isNamespace() ?
static_cast<
const NamespaceNode *>(node) :
nullptr;
1966 brief <<
"The " << ns->name()
1967 <<
" namespace includes the following elements from module "
1968 << ns
->tree()->camelCaseModuleName() <<
". The full namespace is "
1969 <<
"documented in module " << NS
->tree()->camelCaseModuleName();
1970 addNodeLink(brief, fullDocumentLocation(NS),
" here.");
1979 m_writer->writeStartElement(dbNamespace,
"para");
1981 m_writer->writeEndElement();
1984 generatedSomething =
true;
1994 if (!generatedSomething)
1995 m_writer->writeTextElement(dbNamespace,
"para", m_projectDescription +
".");
1997 m_writer->writeEndElement();
2002 m_writer->writeEndElement();
2008 while (!sectionLevels.isEmpty()) {
2009 sectionLevels.pop();
2016 if (m_closeSectionAfterGeneratedList) {
2017 m_closeSectionAfterGeneratedList =
false;
2020 if (m_closeSectionAfterRawTitle) {
2021 m_closeSectionAfterRawTitle =
false;
2026 m_writer->writeEndElement();
2029void DocBookGenerator::generateSimpleLink(
const QString &href,
const QString &text)
2031 m_writer->writeStartElement(dbNamespace,
"link");
2032 m_writer->writeAttribute(xlinkNamespace,
"href", href);
2033 m_writer->writeCharacters(text);
2034 m_writer->writeEndElement();
2038
2039
2040
2043 static const QHash<QString, QString> extrefUrls = {
2044 {u"cpp-explicitly-defaulted"_s,
2045 u"https://en.cppreference.com/w/cpp/language/function#Defaulted_functions"_s},
2046 {u"cpp-deleted-functions"_s,
2047 u"https://en.cppreference.com/w/cpp/language/function#Deleted_functions"_s},
2050 static const QRegularExpression extrefRegex(
2051 u"<@extref target=\"([^\"]+)\">([^<]*)</@extref>"_s);
2054 auto it = extrefRegex.globalMatch(extra);
2055 while (it.hasNext()) {
2056 auto match = it.next();
2057 if (match.capturedStart() > pos)
2058 m_writer->writeCharacters(extra.mid(pos, match.capturedStart() - pos));
2060 QString target = match.captured(1);
2061 QString text = match.captured(2);
2062 QString url = extrefUrls.value(target);
2064 generateSimpleLink(url, text);
2066 m_writer->writeCharacters(text);
2068 pos = match.capturedEnd();
2070 if (pos < extra.size())
2071 m_writer->writeCharacters(extra.mid(pos));
2083 startSection(
"obsolete",
"Obsolete Members for " + aggregate->plainFullName());
2085 m_writer->writeStartElement(dbNamespace,
"para");
2086 m_writer->writeStartElement(dbNamespace,
"emphasis");
2087 m_writer->writeAttribute(
"role",
"bold");
2088 m_writer->writeCharacters(
"The following members of class ");
2089 generateSimpleLink(linkForNode(aggregate,
nullptr), aggregate->name());
2090 m_writer->writeCharacters(
" are deprecated.");
2091 m_writer->writeEndElement();
2092 m_writer->writeCharacters(
" We strongly advise against using them in new code.");
2093 m_writer->writeEndElement();
2096 for (
const Section *section : details_spv) {
2097 const QString &title =
"Obsolete " + section->title();
2098 startSection(title.toLower(), title);
2100 const NodeVector &members = section->obsoleteMembers();
2101 NodeVector::ConstIterator m = members.constBegin();
2102 while (m != members.constEnd()) {
2103 if ((*m)->access() != Access::Private)
2104 generateDetailedMember(*m, aggregate);
2115
2116
2117
2118
2119
2120
2121
2131 startSection(
"obsolete",
"Obsolete Members for " + aggregate->name());
2133 m_writer->writeStartElement(dbNamespace,
"para");
2134 m_writer->writeStartElement(dbNamespace,
"emphasis");
2135 m_writer->writeAttribute(
"role",
"bold");
2136 m_writer->writeCharacters(
"The following members of QML type ");
2137 generateSimpleLink(linkForNode(aggregate,
nullptr), aggregate->name());
2138 m_writer->writeCharacters(
" are deprecated.");
2139 m_writer->writeEndElement();
2140 m_writer->writeCharacters(
" We strongly advise against using them in new code.");
2141 m_writer->writeEndElement();
2144 for (
const auto *section : details_spv) {
2145 const QString &title =
"Obsolete " + section->title();
2146 startSection(title.toLower(), title);
2148 const NodeVector &members = section->obsoleteMembers();
2149 NodeVector::ConstIterator m = members.constBegin();
2150 while (m != members.constEnd()) {
2151 if ((*m)->access() != Access::Private)
2152 generateDetailedQmlMember(*m, aggregate);
2166 return QStringLiteral(
"classsynopsis");
2168 return QStringLiteral(
"packagesynopsis");
2174 return QStringLiteral(
"enumsynopsis");
2176 return QStringLiteral(
"typedefsynopsis");
2179 const auto fn =
static_cast<
const FunctionNode *>(node);
2180 if (fn->isCtor() || fn->isCCtor() || fn->isMCtor())
2181 return QStringLiteral(
"constructorsynopsis");
2183 return QStringLiteral(
"destructorsynopsis");
2184 return QStringLiteral(
"methodsynopsis");
2187 return QStringLiteral(
"fieldsynopsis");
2189 node
->doc().location().warning(QString(
"Unknown node tag %1").arg(node->nodeTypeString()));
2190 return QStringLiteral(
"synopsis");
2195 m_writer->writeStartElement(dbNamespace,
"varlistentry");
2197 m_writer->writeTextElement(dbNamespace,
"term", description);
2199 m_writer->writeStartElement(dbNamespace,
"listitem");
2201 m_writer->writeStartElement(dbNamespace,
"para");
2207 m_writer->writeEndElement();
2210 m_writer->writeEndElement();
2212 m_writer->writeEndElement();
2216void DocBookGenerator::generateRequisite(
const QString &description,
const QString &value)
2218 generateStartRequisite(description);
2219 m_writer->writeCharacters(value);
2220 generateEndRequisite();
2224
2225
2226
2227void DocBookGenerator::generateCMakeRequisite(
const QString &findPackage,
const QString &linkLibraries)
2229 const QString description(
"CMake");
2230 generateStartRequisite(description);
2231 m_writer->writeCharacters(findPackage);
2232 m_writer->writeEndElement();
2235 m_writer->writeStartElement(dbNamespace,
"para");
2236 m_writer->writeCharacters(linkLibraries);
2237 generateEndRequisite();
2243 QMap<QString, ClassNode *> classMap;
2244 QList<RelatedClass>::ConstIterator r = rc.constBegin();
2245 while (r != rc.constEnd()) {
2248 && !rcn
->doc().isEmpty()) {
2249 classMap[rcn->plainFullName(cn).toLower()] = rcn;
2254 QStringList classNames = classMap.keys();
2258 for (
const QString &className : classNames) {
2259 generateFullName(classMap.value(className), cn);
2260 m_writer->writeCharacters(TextUtils::comma(index++, classNames.size()));
2268 QMap<QString, Node *> classMap;
2269 QStringList typeNames(knownTypes);
2270 for (
const auto sub : subs)
2271 typeNames << sub->name();
2273 for (
auto sub : subs) {
2274 QString key{sub->plainFullName(base).toLower()};
2276 if (typeNames.count(sub->name()) > 1)
2277 key.append(
": (%1)"_L1.arg(sub->logicalModuleName()));
2278 classMap[key] = sub;
2281 QStringList names = classMap.keys();
2285 for (
const QString &name : names) {
2286 generateFullName(classMap.value(name), base);
2287 if (name.contains(
':'))
2288 m_writer->writeCharacters(name.section(
':', 1));
2289 m_writer->writeCharacters(TextUtils::comma(index++, names.size()));
2294
2295
2304 QXmlStreamWriter* oldWriter = m_writer;
2306 m_writer =
new QXmlStreamWriter(&output);
2309 if (aggregate->includeFile()) generateRequisite(
"Header", *aggregate->includeFile());
2312 if (!aggregate->since().isEmpty())
2313 generateRequisite(
"Since", formatSince(aggregate));
2318 m_qdb->getCollectionNode(aggregate->physicalModuleName(), NodeType::Module);
2320 if (
const auto result = cmakeRequisite(cn)) {
2321 generateCMakeRequisite(result->first, result->second);
2324 if (cn && !cn->qtVariable().isEmpty())
2325 generateRequisite(
"qmake",
"QT += " + cn->qtVariable());
2330 auto *classe =
const_cast<ClassNode *>(
static_cast<
const ClassNode *>(aggregate));
2331 if (classe && classe->isQmlNativeType() && !classe->isInternal()) {
2332 generateStartRequisite(
"In QML");
2335 QList<QmlTypeNode *> nativeTypes { classe->qmlNativeTypes().cbegin(), classe->qmlNativeTypes().cend()};
2338 for (
const auto &item : std::as_const(nativeTypes)) {
2339 generateFullName(item, classe);
2340 m_writer->writeCharacters(
2341 TextUtils::comma(idx++, nativeTypes.size()));
2343 generateEndRequisite();
2347 QList<RelatedClass>::ConstIterator r;
2348 const auto *metaTags = classe ? classe->doc().metaTagMap() :
nullptr;
2349 bool suppressInherits = metaTags && metaTags->contains(u"qdoc-suppress-inheritance"_s);
2350 if (classe && !suppressInherits && !classe->baseClasses().isEmpty()) {
2351 generateStartRequisite(
"Inherits");
2353 r = classe->baseClasses().constBegin();
2355 while (r != classe->baseClasses().constEnd()) {
2357 generateFullName((*r).m_node, classe);
2359 if ((*r).m_access == Access::Protected)
2360 m_writer->writeCharacters(
" (protected)");
2361 else if ((*r).m_access == Access::Private)
2362 m_writer->writeCharacters(
" (private)");
2363 m_writer->writeCharacters(
2364 TextUtils::comma(index++, classe->baseClasses().size()));
2369 generateEndRequisite();
2373 if (!classe->derivedClasses().isEmpty()) {
2374 generateStartRequisite(
"Inherited By");
2375 generateSortedNames(classe, classe->derivedClasses());
2376 generateEndRequisite();
2381 if (!aggregate->groupNames().empty()) {
2382 generateStartRequisite(
"Group");
2384 generateEndRequisite();
2388 if (
auto status = formatStatus(aggregate, m_qdb); status)
2389 generateRequisite(
"Status", status.value());
2393 m_writer = oldWriter;
2395 if (!output.isEmpty()) {
2398 static const QRegularExpression xmlTag(R"(<(/?)n\d+:)");
2399 static const QRegularExpression xmlnsDocBookDefinition(R"( xmlns:n\d+=")" + QString{dbNamespace} +
"\"");
2400 static const QRegularExpression xmlnsXLinkDefinition(R"( xmlns:n\d+=")" + QString{xlinkNamespace} +
"\"");
2401 static const QRegularExpression xmlAttr(R"( n\d+:)");
2403 const QString cleanOutput = output.replace(xmlTag, R"(<\1db:)")
2404 .replace(xmlnsDocBookDefinition,
"")
2405 .replace(xmlnsXLinkDefinition,
"")
2406 .replace(xmlAttr,
" xlink:");
2408 m_writer->writeStartElement(dbNamespace,
"variablelist");
2410 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
2413 m_writer->device()->write(cleanOutput.toUtf8());
2415 m_writer->writeEndElement();
2421
2422
2430 const QString importText =
"Import Statement";
2431 const QString sinceText =
"Since";
2432 const QString inheritedByText =
"Inherited By";
2433 const QString inheritsText =
"Inherits";
2434 const QString nativeTypeText =
"In C++";
2435 const QString groupText =
"Group";
2436 const QString statusText =
"Status";
2444 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
2453 bool generate_import_statement = !qcn->logicalModuleName().isEmpty();
2454 if (generate_import_statement && collection) {
2459 const bool generates_something = generate_import_statement || !qcn->since().isEmpty() || !subs.isEmpty() || base;
2461 if (!generates_something)
2464 QStringList knownTypeNames{qcn->name()};
2466 knownTypeNames << base->name();
2469 m_writer->writeStartElement(dbNamespace,
"variablelist");
2471 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
2474 if (generate_import_statement) {
2475 QStringList parts = QStringList() <<
"import" << qcn->logicalModuleName() << qcn->logicalModuleVersion();
2476 generateRequisite(importText, parts.join(
' ').trimmed());
2480 if (!qcn->since().isEmpty())
2481 generateRequisite(sinceText, formatSince(qcn));
2486 generateStartRequisite(nativeTypeText);
2487 generateSimpleLink(fullDocumentLocation(cn), cn->name());
2488 generateEndRequisite();
2493 generateStartRequisite(inheritsText);
2494 generateSimpleLink(fullDocumentLocation(base), base->name());
2496 for (
const auto sub : std::as_const(subs)) {
2497 if (knownTypeNames.contains(sub->name())) {
2498 m_writer->writeCharacters(
" (%1)"_L1.arg(base->logicalModuleName()));
2502 generateEndRequisite();
2506 if (!subs.isEmpty()) {
2507 generateStartRequisite(inheritedByText);
2508 generateSortedQmlNames(qcn, knownTypeNames, subs);
2509 generateEndRequisite();
2513 if (!qcn->groupNames().empty()) {
2514 generateStartRequisite(groupText);
2516 generateEndRequisite();
2520 if (
auto status = formatStatus(qcn, m_qdb); status)
2521 generateRequisite(statusText, status.value());
2523 m_writer->writeEndElement();
2530 const auto *shared = node->isSharedCommentNode()
2531 ?
static_cast<
const SharedCommentNode *>(node) :
nullptr;
2532 const bool plural = shared && !shared->isPropertyGroup() && shared->collective().size() > 1;
2533 const QString subject = plural
2534 ?
"These "_L1 + NodeText::nodeTypeDescription(shared->collective().first(), NodeText::GrammaticalNumber::Plural) +
" are"_L1
2535 :
"This "_L1 + NodeText::nodeTypeDescription(node) +
" is"_L1;
2541 const QString &state =
static_cast<
const CollectionNode*>(node)->state();
2542 if (!state.isEmpty()) {
2543 m_writer->writeStartElement(dbNamespace,
"para");
2544 m_writer->writeCharacters(
"This " + NodeText::nodeTypeDescription(node) +
" is in ");
2545 m_writer->writeStartElement(dbNamespace,
"emphasis");
2546 m_writer->writeCharacters(state);
2547 m_writer->writeEndElement();
2548 m_writer->writeCharacters(
" state.");
2549 m_writer->writeEndElement();
2554 if (
const auto &version = node->deprecatedSince(); !version.isEmpty()) {
2555 m_writer->writeStartElement(dbNamespace,
"para");
2556 m_writer->writeCharacters(subject
2557 +
" scheduled for deprecation in version "
2560 m_writer->writeCharacters(
" "_L1);
2563 m_writer->writeEndElement();
2568 case Status::Preliminary:
2569 m_writer->writeStartElement(dbNamespace,
"para");
2570 m_writer->writeStartElement(dbNamespace,
"emphasis");
2571 m_writer->writeAttribute(
"role",
"bold");
2572 m_writer->writeCharacters(
2576 .replace(
'\1'_L1, NodeText::nodeTypeDescription(node)));
2577 m_writer->writeEndElement();
2578 m_writer->writeEndElement();
2581 case Status::Deprecated:
2582 m_writer->writeStartElement(dbNamespace,
"para");
2584 m_writer->writeStartElement(dbNamespace,
"emphasis");
2585 m_writer->writeAttribute(
"role",
"bold");
2587 m_writer->writeCharacters(subject +
" deprecated");
2588 if (
const QString &version = node->deprecatedSince(); !version.isEmpty()) {
2589 m_writer->writeCharacters(
" since ");
2590 if (node->isQmlNode() && !node->logicalModuleName().isEmpty())
2591 m_writer->writeCharacters(node->logicalModuleName() +
" ");
2592 m_writer->writeCharacters(version);
2594 m_writer->writeCharacters(
". We strongly advise against using "
2595 + (plural ?
"them"_L1 :
"it"_L1) +
" in new code.");
2596 if (node->isAggregate())
2597 m_writer->writeEndElement();
2599 m_writer->writeCharacters(
" "_L1);
2602 m_writer->writeEndElement();
2613
2614
2615
2619 m_writer->writeStartElement(dbNamespace,
"itemizedlist");
2622 NodeList::ConstIterator n = nodes.constBegin();
2623 while (n != nodes.constEnd()) {
2624 m_writer->writeStartElement(dbNamespace,
"listitem");
2626 m_writer->writeStartElement(dbNamespace,
"para");
2628 generateSimpleLink(currentGenerator()->fullDocumentLocation(*n),
2629 (*n)->signature(Node::SignaturePlain));
2631 m_writer->writeEndElement();
2633 m_writer->writeEndElement();
2638 m_writer->writeEndElement();
2643
2644
2645
2652 const auto aggregate =
static_cast<
const Aggregate *>(node);
2654 const QStringList &groups_names{aggregate->groupNames()};
2655 if (!groups_names.empty()) {
2656 m_writer->writeCharacters(aggregate->name() +
" is part of ");
2657 m_writer->writeStartElement(dbNamespace,
"simplelist");
2659 for (qsizetype index{0}; index < groups_names.size(); ++index) {
2661 m_qdb->mergeCollections(group);
2663 m_writer->writeStartElement(dbNamespace,
"member");
2664 if (QString target{linkForNode(group,
nullptr)}; !target.isEmpty())
2665 generateSimpleLink(target, group->fullTitle());
2667 m_writer->writeCharacters(group->name());
2668 m_writer->writeEndElement();
2671 m_writer->writeEndElement();
2677
2678
2679
2685 const Node *reentrantNode;
2687 QString linkReentrant = getAutoLink(&reentrantAtom, node, &reentrantNode);
2688 const Node *threadSafeNode;
2690 QString linkThreadSafe = getAutoLink(&threadSafeAtom, node, &threadSafeNode);
2693 m_writer->writeStartElement(dbNamespace,
"warning");
2695 m_writer->writeStartElement(dbNamespace,
"para");
2696 m_writer->writeCharacters(
"This " + NodeText::nodeTypeDescription(node) +
" is not ");
2697 generateSimpleLink(linkReentrant,
"reentrant");
2698 m_writer->writeCharacters(
".");
2699 m_writer->writeEndElement();
2701 m_writer->writeEndElement();
2705 m_writer->writeStartElement(dbNamespace,
"note");
2707 m_writer->writeStartElement(dbNamespace,
"para");
2710 m_writer->writeCharacters(
"All functions in this " + NodeText::nodeTypeDescription(node) +
" are ");
2711 if (ts == Node::ThreadSafe)
2712 generateSimpleLink(linkThreadSafe,
"thread-safe");
2714 generateSimpleLink(linkReentrant,
"reentrant");
2719 bool exceptions = hasExceptions(node, reentrant, threadsafe, nonreentrant);
2720 if (!exceptions || (ts ==
Node::Reentrant && !threadsafe.isEmpty())) {
2721 m_writer->writeCharacters(
".");
2722 m_writer->writeEndElement();
2725 m_writer->writeCharacters(
" with the following exceptions:");
2726 m_writer->writeEndElement();
2728 m_writer->writeStartElement(dbNamespace,
"para");
2731 if (!nonreentrant.isEmpty()) {
2732 m_writer->writeCharacters(
"These functions are not ");
2733 generateSimpleLink(linkReentrant,
"reentrant");
2734 m_writer->writeCharacters(
":");
2735 m_writer->writeEndElement();
2737 generateSignatureList(nonreentrant);
2739 if (!threadsafe.isEmpty()) {
2740 m_writer->writeCharacters(
"These functions are also ");
2741 generateSimpleLink(linkThreadSafe,
"thread-safe");
2742 m_writer->writeCharacters(
":");
2743 m_writer->writeEndElement();
2745 generateSignatureList(threadsafe);
2748 if (!reentrant.isEmpty()) {
2749 m_writer->writeCharacters(
"These functions are only ");
2750 generateSimpleLink(linkReentrant,
"reentrant");
2751 m_writer->writeCharacters(
":");
2752 m_writer->writeEndElement();
2754 generateSignatureList(reentrant);
2756 if (!nonreentrant.isEmpty()) {
2757 m_writer->writeCharacters(
"These functions are not ");
2758 generateSimpleLink(linkReentrant,
"reentrant");
2759 m_writer->writeCharacters(
":");
2760 m_writer->writeEndElement();
2762 generateSignatureList(nonreentrant);
2767 m_writer->writeCharacters(
"This " + NodeText::nodeTypeDescription(node) +
" is ");
2768 if (ts == Node::ThreadSafe)
2769 generateSimpleLink(linkThreadSafe,
"thread-safe");
2771 generateSimpleLink(linkReentrant,
"reentrant");
2772 m_writer->writeCharacters(
".");
2773 m_writer->writeEndElement();
2776 m_writer->writeEndElement();
2786
2787
2788
2792 const FunctionNode *fn = node->isFunction() ?
static_cast<
const FunctionNode *>(node) :
nullptr;
2796
2797
2798
2802 t =
"Destroys the instance of " + fn
->parent()->name() +
".";
2804 t +=
" The destructor is virtual.";
2806 t =
"Default constructs an instance of " + fn
->parent()->name() +
".";
2808 t =
"Copy constructor.";
2810 t =
"Move-copy constructor.";
2812 t =
"Copy-assignment constructor.";
2814 t =
"Move-assignment constructor.";
2818 m_writer->writeTextElement(dbNamespace,
"para", t);
2822 if (fn && !fn->overridesThis().isEmpty())
2823 generateReimplementsClause(fn);
2825 if (
static_cast<
const PropertyNode *>(node)->propertyType() != PropertyNode::PropertyType::StandardProperty)
2854 generateRequiredLinks(node);
2858
2859
2860
2861
2862
2869 const auto en =
static_cast<
const ExampleNode *>(node);
2872 if (exampleUrl.isEmpty()) {
2873 if (!en->noAutoList()) {
2874 generateFileList(en,
false);
2875 generateFileList(en,
true);
2878 generateLinkToExample(en, exampleUrl);
2883
2884
2885
2886
2887
2891 QString exampleUrl(baseUrl);
2893#ifndef QT_BOOTSTRAPPED
2894 link = QUrl(exampleUrl).host();
2896 if (!link.isEmpty())
2897 link.prepend(
" @ ");
2898 link.prepend(
"Example project");
2900 const QLatin1Char separator(
'/');
2901 const QLatin1Char placeholder(
'\1');
2902 if (!exampleUrl.contains(placeholder)) {
2903 if (!exampleUrl.endsWith(separator))
2904 exampleUrl += separator;
2905 exampleUrl += placeholder;
2909 QStringList path = QStringList()
2911 path.removeAll(QString());
2915 startSection(
"Example project");
2917 m_writer->writeStartElement(dbNamespace,
"para");
2918 generateSimpleLink(exampleUrl.replace(placeholder, path.join(separator)), link);
2919 m_writer->writeEndElement();
2928
2929
2930
2931
2932
2933
2949 paths = en->images();
2952 paths = en->files();
2955 std::sort(paths.begin(), paths.end(), Generator::comparePaths);
2957 if (paths.isEmpty())
2960 startSection(
"",
"List of Files");
2962 m_writer->writeStartElement(dbNamespace,
"para");
2963 m_writer->writeCharacters(tag);
2964 m_writer->writeEndElement();
2967 startSection(
"List of Files");
2969 m_writer->writeStartElement(dbNamespace,
"itemizedlist");
2972 for (
const auto &path : std::as_const(paths)) {
2973 auto maybe_resolved_file{file_resolver.resolve(path)};
2974 if (!maybe_resolved_file) {
2976 QString details = std::transform_reduce(
2977 file_resolver.get_search_directories().cbegin(),
2978 file_resolver.get_search_directories().cend(),
2979 u"Searched directories:"_s,
2981 [](
const DirectoryPath &directory_path) -> QString {
return u' ' + directory_path.value(); }
2984 en->location().warning(u"Cannot find file to quote from: %1"_s.arg(path), details);
2989 const auto &file{*maybe_resolved_file};
2990 if (images) addImageToCopy(en, file);
2991 else generateExampleFilePage(en, file);
2993 m_writer->writeStartElement(dbNamespace,
"listitem");
2995 m_writer->writeStartElement(dbNamespace,
"para");
2996 generateSimpleLink(file.get_query(), file.get_query());
2997 m_writer->writeEndElement();
2998 m_writer->writeEndElement();
3002 m_writer->writeEndElement();
3009
3010
3020 const auto en =
static_cast<
const ExampleNode *>(node);
3023 QXmlStreamWriter *currentWriter = m_writer;
3024 m_writer = startDocument(en, resolved_file.get_query());
3030 QString code = quoter.quoteTo(en->location(), QString(), QString());
3031 CodeMarker *codeMarker = CodeMarker::markerForFileName(resolved_file.get_path());
3037 m_writer = currentWriter;
3043 if (fn->overridesThis().isEmpty() || !fn
->parent()->isClassNode())
3048 if (
const FunctionNode *overrides = cn->findOverriddenFunction(fn);
3051 m_writer->writeStartElement(dbNamespace,
"para");
3052 m_writer->writeCharacters(
"Reimplements: ");
3055 generateFullName(overrides
->parent(), fullName, overrides);
3056 m_writer->writeCharacters(
".");
3057 m_writer->writeEndElement();
3063 if (
const PropertyNode *sameName = cn->findOverriddenProperty(fn); sameName && sameName
->hasDoc()) {
3064 m_writer->writeStartElement(dbNamespace,
"para");
3065 m_writer->writeCharacters(
"Reimplements an access function for property: ");
3066 QString fullName = sameName
->parent()->name() +
"::" + sameName->name();
3067 generateFullName(sameName
->parent(), fullName, sameName);
3068 m_writer->writeCharacters(
".");
3069 m_writer->writeEndElement();
3078 QList<Text> alsoList = node
->doc().alsoList();
3079 supplementAlsoList(node, alsoList);
3081 if (!alsoList.isEmpty()) {
3082 startSection(
"See Also");
3084 m_writer->writeStartElement(dbNamespace,
"para");
3085 m_writer->writeStartElement(dbNamespace,
"emphasis");
3086 m_writer->writeCharacters(
"See also ");
3087 m_writer->writeEndElement();
3090 m_writer->writeStartElement(dbNamespace,
"simplelist");
3091 m_writer->writeAttribute(
"type",
"vert");
3092 m_writer->writeAttribute(
"role",
"see-also");
3095 for (
const Text &text : alsoList) {
3096 m_writer->writeStartElement(dbNamespace,
"member");
3097 generateText(text, node);
3098 m_writer->writeEndElement();
3102 m_writer->writeEndElement();
3105 m_writer->writeEndElement();
3113
3114
3115
3116QXmlStreamWriter *
DocBookGenerator::startGenericDocument(
const Node *node,
const QString &fileName)
3119 QFile *outFile = openSubPageFile(
static_cast<
const PageNode*>(node), fileName);
3120 m_writer =
new QXmlStreamWriter(outFile);
3121 m_writer->setAutoFormatting(
false);
3123 m_writer->writeStartDocument();
3125 m_writer->writeNamespace(dbNamespace,
"db");
3126 m_writer->writeNamespace(xlinkNamespace,
"xlink");
3128 m_writer->writeNamespace(itsNamespace,
"its");
3129 m_writer->writeStartElement(dbNamespace,
"article");
3130 m_writer->writeAttribute(
"version",
"5.2");
3131 if (!m_naturalLanguage.isEmpty())
3132 m_writer->writeAttribute(
"xml:lang", m_naturalLanguage);
3136 sectionLevels.resize(0);
3145 m_hasSection =
false;
3148 QString fileName = Generator::fileName(node, fileExtension());
3149 return startGenericDocument(node, fileName);
3154 m_hasSection =
false;
3156 QString fileName = linkForExampleFile(file);
3157 return startGenericDocument(en, fileName);
3162 m_writer->writeEndElement();
3163 m_writer->writeEndDocument();
3165 m_writer->device()->close();
3166 delete m_writer->device();
3172
3173
3174
3179 const auto aggregate =
static_cast<
const Aggregate *>(node);
3183 const QString typeWord{aggregate->typeWord(
true)};
3184 if (aggregate->isNamespace()) {
3185 title =
"%1 %2"_L1.arg(aggregate->plainFullName(), typeWord);
3186 }
else if (aggregate->isClass()) {
3187 title =
"%1 %2"_L1.arg(aggregate->plainFullName(), typeWord);
3188 }
else if (aggregate->isHeader()) {
3189 title = aggregate->fullTitle();
3190 if (!aggregate->doc().title().isEmpty())
3191 titleText << aggregate->name() <<
" - "_L1 << aggregate->doc().title();
3195 m_writer = startDocument(node);
3201 if (aggregate->isClass()) {
3202 if (
auto templateDecl = node->templateDecl()) {
3208 m_writer->writeStartElement(dbNamespace,
"subtitle");
3209 if (isApiGenus(aggregate->genus()) && m_useITS)
3210 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
3211 generateTemplateDecl(&*templateDecl, aggregate);
3212 m_writer->writeCharacters(
" "_L1 + aggregate->typeWord(
false) +
" "_L1
3213 + aggregate->plainFullName());
3214 m_writer->writeEndElement();
3238 if (!aggregate->doc().isEmpty()) {
3239 startSection(
"details",
"Detailed Description");
3241 generateBody(aggregate);
3249 for (
const Section §ion : sectionVector) {
3250 if (section.members().isEmpty())
3253 startSection(section.title().toLower(), section.title());
3255 for (
const Node *member : section.members()) {
3256 if (member->nodeType() != NodeType::Class) {
3258 generateDetailedMember(member, aggregate);
3260 startSectionBegin();
3261 m_writer->writeCharacters(
"class ");
3262 generateFullName(member, aggregate);
3265 generateBrief(member);
3274 generateObsoleteMembers(sections);
3279void DocBookGenerator::generateSynopsisInfo(
const QString &key,
const QString &value)
3281 m_writer->writeStartElement(dbNamespace,
"synopsisinfo");
3282 m_writer->writeAttribute(
"role", key);
3283 m_writer->writeCharacters(value);
3284 m_writer->writeEndElement();
3290 m_writer->writeTextElement(dbNamespace,
"modifier", value);
3295
3296
3306 if (!m_useDocBook52)
3316 node->isAggregate() ?
static_cast<
const Aggregate *>(node) :
nullptr;
3317 const ClassNode *classNode = node->isClass() ?
static_cast<
const ClassNode *>(node) :
nullptr;
3319 node->isFunction() ?
static_cast<
const FunctionNode *>(node) :
nullptr;
3321 node->isProperty() ?
static_cast<
const PropertyNode *>(node) :
nullptr;
3323 node->isVariable() ?
static_cast<
const VariableNode *>(node) :
nullptr;
3324 const EnumNode *enumNode = node->isEnumType() ?
static_cast<
const EnumNode *>(node) :
nullptr;
3326 node->isQmlProperty() ?
static_cast<
const QmlPropertyNode *>(node) :
nullptr;
3327 const QmlTypeNode *qcn = node->isQmlType() ?
static_cast<
const QmlTypeNode *>(node) :
nullptr;
3333 QString synopsisTag = nodeToSynopsisTag(node);
3334 m_writer->writeStartElement(dbNamespace, synopsisTag);
3339 m_writer->writeStartElement(dbNamespace,
"ooclass");
3340 m_writer->writeTextElement(dbNamespace,
"classname", node->plainName());
3341 m_writer->writeEndElement();
3344 m_writer->writeTextElement(dbNamespace,
"namespacename", node->plainName());
3347 m_writer->writeStartElement(dbNamespace,
"ooclass");
3348 m_writer->writeTextElement(dbNamespace,
"classname", node->plainName());
3349 m_writer->writeEndElement();
3351 if (!qcn->groupNames().isEmpty())
3352 m_writer->writeAttribute(
"groups", qcn->groupNames().join(QLatin1Char(
',')));
3354 m_writer->writeTextElement(dbNamespace,
"modifier",
"(Qt property)");
3356 m_writer->writeTextElement(dbNamespace,
"type", propertyNode->dataType());
3358 m_writer->writeTextElement(dbNamespace,
"varname", node->plainName());
3362 m_writer->writeTextElement(dbNamespace,
"modifier",
"static");
3365 m_writer->writeTextElement(dbNamespace,
"type", variableNode->dataType());
3367 m_writer->writeTextElement(dbNamespace,
"varname", node->plainName());
3371 m_writer->writeTextElement(dbNamespace,
"enumname", node->plainName());
3375 QString name = node->name();
3377 name.prepend(qpn->element() + QLatin1Char(
'.'));
3379 m_writer->writeTextElement(dbNamespace,
"type", qpn->dataType());
3381 m_writer->writeTextElement(dbNamespace,
"varname", name);
3389 m_writer->writeTextElement(dbNamespace,
"modifier",
"attached");
3393 m_writer->writeTextElement(dbNamespace,
"modifier",
"writable");
3397 m_writer->writeTextElement(dbNamespace,
"modifier",
"required");
3402 generateModifier(
"[read-only]");
3406 generateModifier(
"[default]");
3410 if (functionNode->virtualness() !=
"non")
3411 generateModifier(
"virtual");
3412 if (functionNode->isConst())
3413 generateModifier(
"const");
3414 if (functionNode->isStatic())
3415 generateModifier(
"static");
3420 if (functionNode->returnType() ==
"void")
3421 m_writer->writeEmptyElement(dbNamespace,
"void");
3423 m_writer->writeTextElement(dbNamespace,
"type", functionNode->returnTypeString());
3428 QString name = node->plainName();
3429 if (name.endsWith(
"()"))
3431 m_writer->writeTextElement(dbNamespace,
"methodname", name);
3435 m_writer->writeEmptyElement(dbNamespace,
"void");
3440 for (
int i = 0; i < lp
.count(); ++i) {
3442 m_writer->writeStartElement(dbNamespace,
"methodparam");
3444 m_writer->writeTextElement(dbNamespace,
"type", parameter.type());
3446 m_writer->writeTextElement(dbNamespace,
"parameter", parameter.name());
3448 if (!parameter.defaultValue().isEmpty()) {
3449 m_writer->writeTextElement(dbNamespace,
"initializer", parameter.defaultValue());
3452 m_writer->writeEndElement();
3456 if (functionNode->isImplicitlyGenerated())
3457 generateModifier(
"implicit");
3458 else if (functionNode->isExplicitlyDefaulted())
3459 generateModifier(
"default");
3460 else if (functionNode->isDeletedAsWritten())
3461 generateModifier(
"delete");
3462 if (functionNode->isFinal())
3463 generateModifier(
"final");
3464 if (functionNode->isOverride())
3465 generateModifier(
"override");
3467 m_writer->writeTextElement(dbNamespace,
"typedefname", node->plainName());
3471 QStringLiteral(
"Unexpected node type in generateDocBookSynopsis: %1")
3472 .arg(node->nodeTypeString()));
3478 for (
const EnumItem &item : enumNode->items()) {
3479 m_writer->writeStartElement(dbNamespace,
"enumitem");
3481 m_writer->writeTextElement(dbNamespace,
"enumidentifier", item.name());
3483 m_writer->writeTextElement(dbNamespace,
"enumvalue", item.value());
3485 m_writer->writeEndElement();
3489 if (enumNode->items().isEmpty()) {
3492 m_writer->writeStartElement(dbNamespace,
"enumitem");
3494 m_writer->writeEmptyElement(dbNamespace,
"enumidentifier");
3496 m_writer->writeEndElement();
3507 generateSynopsisInfo(
"meta", functionNode->metanessString());
3510 generateSynopsisInfo(
"overload",
"overload");
3511 generateSynopsisInfo(
"overload-number",
3512 QString::number(functionNode->overloadNumber()));
3515 if (functionNode->isRef())
3516 generateSynopsisInfo(
"refness", QString::number(1));
3517 else if (functionNode->isRefRef())
3518 generateSynopsisInfo(
"refness", QString::number(2));
3521 QStringList associatedProperties;
3522 const auto &nodes = functionNode->associatedProperties();
3523 for (
const Node *n : nodes) {
3524 const auto pn =
static_cast<
const PropertyNode *>(n);
3525 associatedProperties << pn->name();
3527 associatedProperties.sort();
3528 generateSynopsisInfo(
"associated-property",
3529 associatedProperties.join(QLatin1Char(
',')));
3535 signature +=
" final";
3537 signature +=
" override";
3539 signature +=
" = 0";
3541 signature +=
" = default";
3543 signature +=
" = delete";
3544 if (
const auto &req = functionNode->trailingRequiresClause(); req && !req->isEmpty())
3545 signature +=
" requires " + *req;
3546 generateSynopsisInfo(
"signature", signature);
3552 case Access::Public:
3553 generateSynopsisInfo(
"access",
"public");
3555 case Access::Protected:
3556 generateSynopsisInfo(
"access",
"protected");
3558 case Access::Private:
3559 generateSynopsisInfo(
"access",
"private");
3564 if (node->isAbstract())
3565 generateSynopsisInfo(
"abstract",
"true");
3570 case Status::Active:
3571 generateSynopsisInfo(
"status",
"active");
3573 case Status::Preliminary:
3574 generateSynopsisInfo(
"status",
3577 case Status::Deprecated:
3578 generateSynopsisInfo(
"status",
"deprecated");
3580 case Status::Internal:
3581 case Status::InternalAuto:
3582 generateSynopsisInfo(
"status",
"internal");
3585 generateSynopsisInfo(
"status",
"main");
3592 if (aggregate->includeFile()) generateSynopsisInfo(
"headers", *aggregate->includeFile());
3595 if (!aggregate->since().isEmpty())
3596 generateSynopsisInfo(
"since", formatSince(aggregate));
3600 if (!aggregate->physicalModuleName().isEmpty()) {
3602 m_qdb->getCollectionNode(aggregate->physicalModuleName(), NodeType::Module);
3604 if (
const auto result = cmakeRequisite(cn)) {
3605 generateSynopsisInfo(
"cmake-find-package", result->first);
3606 generateSynopsisInfo(
"cmake-target-link-libraries", result->second);
3609 if (cn && !cn->qtVariable().isEmpty())
3610 generateSynopsisInfo(
"qmake",
"QT += " + cn->qtVariable());
3616 auto *classe =
const_cast<ClassNode *>(
static_cast<
const ClassNode *>(aggregate));
3617 if (classe && classe->isQmlNativeType() && !classe->isInternal()) {
3618 m_writer->writeStartElement(dbNamespace,
"synopsisinfo");
3619 m_writer->writeAttribute(
"role",
"nativeTypeFor");
3621 QList<QmlTypeNode *> nativeTypes { classe->qmlNativeTypes().cbegin(), classe->qmlNativeTypes().cend()};
3624 for (
auto item : std::as_const(nativeTypes)) {
3625 const Node *otherNode{
nullptr};
3626 Atom a = Atom(Atom::LinkNode, Utilities::stringForNode(item));
3627 const QString &link = getAutoLink(&a, aggregate, &otherNode);
3628 generateSimpleLink(link, item->name());
3631 m_writer->writeEndElement();
3635 QList<RelatedClass>::ConstIterator r;
3636 if (!classe->baseClasses().isEmpty()) {
3637 m_writer->writeStartElement(dbNamespace,
"synopsisinfo");
3638 m_writer->writeAttribute(
"role",
"inherits");
3640 r = classe->baseClasses().constBegin();
3642 while (r != classe->baseClasses().constEnd()) {
3644 generateFullName((*r).m_node, classe);
3646 if ((*r).m_access == Access::Protected) {
3647 m_writer->writeCharacters(
" (protected)");
3648 }
else if ((*r).m_access == Access::Private) {
3649 m_writer->writeCharacters(
" (private)");
3651 m_writer->writeCharacters(
3652 TextUtils::comma(index++, classe->baseClasses().size()));
3657 m_writer->writeEndElement();
3662 if (!classe->derivedClasses().isEmpty()) {
3663 m_writer->writeStartElement(dbNamespace,
"synopsisinfo");
3664 m_writer->writeAttribute(
"role",
"inheritedBy");
3665 generateSortedNames(classe, classe->derivedClasses());
3666 m_writer->writeEndElement();
3675 QString logicalModuleVersion;
3677 m_qdb->getCollectionNode(qcn->logicalModuleName(), qcn->nodeType());
3679 logicalModuleVersion = collection->logicalModuleVersion();
3681 logicalModuleVersion = qcn->logicalModuleVersion();
3683 QStringList importText;
3684 importText <<
"import " + qcn->logicalModuleName();
3685 if (!logicalModuleVersion.isEmpty())
3686 importText << logicalModuleVersion;
3687 generateSynopsisInfo(
"import", importText.join(
' '));
3690 if (!qcn->since().isEmpty())
3691 generateSynopsisInfo(
"since", formatSince(qcn));
3694 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
3702 QStringList knownTypeNames{qcn->name()};
3704 knownTypeNames << base->name();
3709 if (!subs.isEmpty()) {
3710 m_writer->writeTextElement(dbNamespace,
"synopsisinfo");
3711 m_writer->writeAttribute(
"role",
"inheritedBy");
3712 generateSortedQmlNames(qcn, knownTypeNames, subs);
3713 m_writer->writeEndElement();
3719 const Node *otherNode =
nullptr;
3721 QString link = getAutoLink(&a, base, &otherNode);
3723 m_writer->writeTextElement(dbNamespace,
"synopsisinfo");
3724 m_writer->writeAttribute(
"role",
"inherits");
3725 generateSimpleLink(link, base->name());
3727 for (
const auto sub : std::as_const(subs)) {
3728 if (knownTypeNames.contains(sub->name())) {
3729 m_writer->writeCharacters(
" (%1)"_L1.arg(base->logicalModuleName()));
3733 m_writer->writeEndElement();
3741 const Node *otherNode =
nullptr;
3743 QString link = getAutoLink(&a, cn, &otherNode);
3745 m_writer->writeTextElement(dbNamespace,
"synopsisinfo");
3746 m_writer->writeAttribute(
"role",
"nativeType");
3747 generateSimpleLink(link, cn->name());
3748 m_writer->writeEndElement();
3755 case Node::UnspecifiedSafeness:
3756 generateSynopsisInfo(
"threadsafeness",
"unspecified");
3758 case Node::NonReentrant:
3759 generateSynopsisInfo(
"threadsafeness",
"non-reentrant");
3761 case Node::Reentrant:
3762 generateSynopsisInfo(
"threadsafeness",
"reentrant");
3764 case Node::ThreadSafe:
3765 generateSynopsisInfo(
"threadsafeness",
"thread safe");
3768 generateSynopsisInfo(
"threadsafeness",
"unspecified");
3773 if (!node->physicalModuleName().isEmpty())
3774 generateSynopsisInfo(
"module", node->physicalModuleName());
3777 if (classNode && !classNode->groupNames().isEmpty()) {
3778 generateSynopsisInfo(
"groups", classNode->groupNames().join(QLatin1Char(
',')));
3779 }
else if (qcn && !qcn->groupNames().isEmpty()) {
3780 generateSynopsisInfo(
"groups", qcn->groupNames().join(QLatin1Char(
',')));
3785 for (
const Node *fnNode : propertyNode->getters()) {
3787 const auto funcNode =
static_cast<
const FunctionNode *>(fnNode);
3788 generateSynopsisInfo(
"getter", funcNode->name());
3791 for (
const Node *fnNode : propertyNode->setters()) {
3793 const auto funcNode =
static_cast<
const FunctionNode *>(fnNode);
3794 generateSynopsisInfo(
"setter", funcNode->name());
3797 for (
const Node *fnNode : propertyNode->resetters()) {
3799 const auto funcNode =
static_cast<
const FunctionNode *>(fnNode);
3800 generateSynopsisInfo(
"resetter", funcNode->name());
3803 for (
const Node *fnNode : propertyNode->notifiers()) {
3805 const auto funcNode =
static_cast<
const FunctionNode *>(fnNode);
3806 generateSynopsisInfo(
"notifier", funcNode->name());
3811 m_writer->writeEndElement();
3817 m_writer->writeStartElement(dbNamespace,
"typedefsynopsis");
3820 m_writer->writeTextElement(dbNamespace,
"typedefname",
3821 enumNode->flagsType()->fullDocumentName());
3824 m_writer->writeEndElement();
3835 return node->name().mid(4);
3836 return node->name();
3840
3841
3842
3843void DocBookGenerator::typified(
const QString &string,
const Node *relative,
bool trailingSpace,
3848 QString pendingWord;
3850 for (
int i = 0; i <= string.size(); ++i) {
3852 if (i != string.size())
3855 QChar lower = ch.toLower();
3856 if ((lower >= QLatin1Char(
'a') && lower <= QLatin1Char(
'z')) || ch.digitValue() >= 0
3857 || ch == QLatin1Char(
'_') || ch == QLatin1Char(
':')) {
3860 if (!pendingWord.isEmpty()) {
3861 bool isProbablyType = (pendingWord != QLatin1String(
"const"));
3862 if (generateType && isProbablyType) {
3864 m_writer->writeCharacters(result);
3868 const Node *n = m_qdb->findTypeNode(pendingWord, relative, Genus::DontCare);
3873 href = linkForNode(n, relative);
3876 m_writer->writeStartElement(dbNamespace,
"type");
3878 m_writer->writeCharacters(pendingWord);
3880 generateSimpleLink(href, pendingWord);
3881 m_writer->writeEndElement();
3883 result += pendingWord;
3886 pendingWord.clear();
3888 if (ch.unicode() !=
'\0')
3893 if (trailingSpace && string.size()) {
3894 if (!string.endsWith(QLatin1Char(
'*')) && !string.endsWith(QLatin1Char(
'&')))
3895 result += QLatin1Char(
' ');
3898 m_writer->writeCharacters(result);
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3918 const QStringList &concepts,
3919 const Node *relative)
3921 if (concepts.isEmpty()) {
3922 m_writer->writeCharacters(text);
3926 QStringList sorted = concepts;
3927 std::sort(sorted.begin(), sorted.end(),
3928 [](
const QString &a,
const QString &b) {
return a.size() > b.size(); });
3934 struct Match { qsizetype offset; qsizetype length; QString name; QString target; };
3935 QList<Match> matches;
3936 QList<
bool> occupied(text.size(),
false);
3938 for (
const QString &concept_name : sorted) {
3939 const QString unqualified = concept_name.section(
"::"_L1, -1);
3940 const QRegularExpression re(
"\\b"_L1
3941 + QRegularExpression::escape(unqualified) +
"\\b"_L1);
3942 auto it = re.globalMatch(text);
3943 while (it.hasNext()) {
3944 const auto m = it.next();
3945 const qsizetype start = m.capturedStart();
3946 const qsizetype len = m.capturedLength();
3948 for (qsizetype i = start; i < start + len; ++i) {
3956 for (qsizetype i = start; i < start + len; ++i)
3958 matches.append({start, len, unqualified, concept_name});
3962 std::sort(matches.begin(), matches.end(),
3963 [](
const Match &a,
const Match &b) {
return a.offset < b.offset; });
3966 for (
const auto &m : matches) {
3968 m_writer->writeCharacters(text.mid(pos, m.offset - pos));
3969 const Node *n = m_qdb->findConceptNode(m.target);
3971 generateSimpleLink(linkForNode(n, relative), m.name);
3973 m_writer->writeCharacters(m.name);
3974 pos = m.offset + m.length;
3976 if (pos < text.size())
3977 m_writer->writeCharacters(text.mid(pos));
3981
3982
3983
3984
3985
3986
3987
3988
3989
3991 const Node *relative)
3995 if (param.template_declaration) {
4000 m_writer->writeCharacters(
"template <"_L1);
4002 for (
const auto &sub : param.template_declaration->parameters) {
4003 if (sub.sfinae_constraint)
4006 m_writer->writeCharacters(
", "_L1);
4007 generateTemplateParameter(sub, relative);
4010 m_writer->writeCharacters(
"> "_L1);
4013 switch (param
.kind) {
4015 if (param.concept_name) {
4016 const QString fq = QString::fromStdString(*param.concept_name);
4017 const QString unqualified = fq.section(
"::"_L1, -1);
4018 const Node *n = m_qdb->findConceptNode(fq);
4020 generateSimpleLink(linkForNode(n, relative), unqualified);
4024 m_writer->writeCharacters(fq);
4026 m_writer->writeCharacters(
"typename"_L1);
4029 case RelaxedTemplateParameter::Kind::NonTypeTemplateParameter:
4030 if (!decl.type.empty())
4031 typified(QString::fromStdString(decl.type), relative,
false,
true);
4033 case RelaxedTemplateParameter::Kind::TemplateTemplateParameter:
4034 m_writer->writeCharacters(
"typename"_L1);
4038 if (param.is_parameter_pack)
4039 m_writer->writeCharacters(
"..."_L1);
4041 if (!decl
.name.empty()) {
4042 m_writer->writeCharacters(
" "_L1);
4043 m_writer->writeCharacters(QString::fromStdString(decl.name));
4047 m_writer->writeCharacters(
" = "_L1);
4050 typified(QString::fromStdString(decl.initializer), relative,
false,
true);
4052 m_writer->writeCharacters(QString::fromStdString(decl.initializer));
4058
4059
4060
4061
4062
4063
4064
4065
4066
4068 const Node *relative)
4076 m_writer->writeCharacters(
"template <"_L1);
4078 m_writer->writeCharacters(
"\n"_L1);
4081 for (
const auto ¶m : templateDecl->parameters) {
4082 if (param.sfinae_constraint)
4085 m_writer->writeCharacters(multiline ?
",\n"_L1 :
", "_L1);
4087 m_writer->writeCharacters(
" "_L1);
4088 generateTemplateParameter(param, relative);
4093 m_writer->writeCharacters(
"\n"_L1);
4094 m_writer->writeCharacters(
">"_L1);
4096 if (templateDecl->requires_clause && !templateDecl->requires_clause->empty()) {
4097 m_writer->writeCharacters(
" requires "_L1);
4098 QStringList concepts;
4099 concepts.reserve(
int(templateDecl->referenced_concepts.size()));
4100 for (
const auto &s : templateDecl->referenced_concepts)
4101 concepts.append(QString::fromStdString(s));
4102 generateRequiresClauseText(QString::fromStdString(*templateDecl->requires_clause),
4103 concepts, relative);
4108 bool generateNameLink)
4112 QString name = taggedNode(node);
4114 if (!generateNameLink) {
4115 m_writer->writeCharacters(name);
4119 m_writer->writeStartElement(dbNamespace,
"emphasis");
4120 m_writer->writeAttribute(
"role",
"bold");
4121 generateSimpleLink(linkForNode(node, relative), name);
4122 m_writer->writeEndElement();
4126 bool generateExtra,
bool generateType)
4128 const QString &pname = parameter.name();
4129 const QString &ptype = parameter.type();
4131 qsizetype insertPos = !pname.isEmpty() ? parameter.nameInsertionPoint() : -1;
4132 if (!pname.isEmpty()) {
4133 if (insertPos >= 0) {
4135 typified(ptype.left(insertPos), relative,
false, generateType);
4137 typified(ptype, relative,
true, generateType);
4144 if (generateExtra || pname.isEmpty()) {
4145 m_writer->writeStartElement(dbNamespace,
"emphasis");
4146 m_writer->writeCharacters(paramName);
4147 m_writer->writeEndElement();
4151 typified(ptype.mid(insertPos), relative,
false, generateType);
4153 const QString &pvalue = parameter.defaultValue();
4154 if (generateExtra && !pvalue.isEmpty())
4155 m_writer->writeCharacters(
" = " + pvalue);
4167 const int MaxEnumValues = 6;
4169 if (generateExtra) {
4170 if (
auto extra = CodeMarker::extraSynopsis(node, style); !extra.isEmpty()) {
4171 generateExtraSynopsis(extra);
4172 m_writer->writeCharacters(u" "_s);
4177 QString namePrefix {};
4181 namePrefix = taggedNode(node->parent()) +
"::";
4186 case NodeType::Namespace:
4187 m_writer->writeCharacters(
"namespace ");
4188 m_writer->writeCharacters(namePrefix);
4189 generateSynopsisName(node, relative, generateNameLink);
4191 case NodeType::Class:
4192 m_writer->writeCharacters(
"class ");
4193 m_writer->writeCharacters(namePrefix);
4194 generateSynopsisName(node, relative, generateNameLink);
4200 if (
auto templateDecl = func->templateDecl()) {
4201 generateTemplateDecl(&*templateDecl, relative);
4202 if (templateDecl->visibleParameterCount() > QDoc::MultilineTemplateParamThreshold)
4203 m_writer->writeCharacters(
"\n"_L1);
4205 m_writer->writeCharacters(
" "_L1);
4211 if (!func->isNonvirtual())
4212 m_writer->writeCharacters(QStringLiteral(
"virtual "));
4216 if (style != Section::AllMembers && !func->returnType().isEmpty())
4217 typified(func->returnTypeString(), relative,
true, generateType);
4218 m_writer->writeCharacters(namePrefix);
4219 generateSynopsisName(node, relative, generateNameLink);
4222 m_writer->writeCharacters(QStringLiteral(
"("));
4225 for (
int i = 0; i < parameters
.count(); i++) {
4227 m_writer->writeCharacters(QStringLiteral(
", "));
4228 generateParameter(parameters
.at(i
), relative, generateExtra, generateType);
4231 m_writer->writeCharacters(QStringLiteral(
")"));
4234 if (func->isConst())
4235 m_writer->writeCharacters(QStringLiteral(
" const"));
4241 synopsis += QStringLiteral(
" final");
4243 synopsis += QStringLiteral(
" override");
4245 synopsis += QStringLiteral(
" = 0");
4247 synopsis += QStringLiteral(
" &");
4249 synopsis += QStringLiteral(
" &&");
4250 m_writer->writeCharacters(synopsis);
4252 if (!func->returnType().isEmpty() && func->returnType() !=
"void") {
4253 m_writer->writeCharacters(QStringLiteral(
" : "));
4254 typified(func->returnTypeString(), relative,
false, generateType);
4259 synopsis +=
" &"_L1;
4261 synopsis +=
" &&"_L1;
4262 m_writer->writeCharacters(synopsis);
4264 if (
const auto &req = func->trailingRequiresClause(); req && !req->isEmpty()) {
4265 m_writer->writeCharacters(
" requires "_L1);
4266 generateRequiresClauseText(*req, func->referencedConcepts(), relative);
4271 const auto enume =
static_cast<
const EnumNode *>(node);
4272 if (!enume->isAnonymous()) {
4273 m_writer->writeCharacters(
"enum "_L1);
4274 m_writer->writeCharacters(namePrefix);
4275 generateSynopsisName(node, relative, generateNameLink);
4276 }
else if (generateNameLink) {
4277 m_writer->writeStartElement(dbNamespace,
"emphasis");
4278 m_writer->writeAttribute(
"role",
"bold");
4279 generateSimpleLink(linkForNode(node, relative),
"enum");
4280 m_writer->writeEndElement();
4282 m_writer->writeCharacters(
"enum"_L1);
4289 QStringList documentedItems = enume->doc().enumItemNames();
4290 if (documentedItems.isEmpty()) {
4291 const auto &enumItems = enume->items();
4292 for (
const auto &item : enumItems)
4293 documentedItems << item.name();
4295 const QStringList omitItems = enume->doc().omitEnumItemNames();
4296 for (
const auto &item : omitItems)
4297 documentedItems.removeAll(item);
4299 if (documentedItems.size() > MaxEnumValues) {
4301 const QString last = documentedItems.last();
4302 documentedItems = documentedItems.mid(0, MaxEnumValues - 1);
4303 documentedItems +=
"…";
4304 documentedItems += last;
4306 synopsis += documentedItems.join(QLatin1String(
", "));
4308 if (!documentedItems.isEmpty())
4309 synopsis += QLatin1Char(
' ');
4310 synopsis += QLatin1Char(
'}');
4312 m_writer->writeCharacters(synopsis);
4316 if (
auto templateDecl = node->templateDecl()) {
4317 generateTemplateDecl(&*templateDecl, relative);
4318 if (templateDecl->visibleParameterCount() > QDoc::MultilineTemplateParamThreshold)
4319 m_writer->writeCharacters(
"\n"_L1);
4321 m_writer->writeCharacters(
" "_L1);
4324 m_writer->writeCharacters(namePrefix);
4325 generateSynopsisName(node, relative, generateNameLink);
4328 if (
static_cast<
const TypedefNode *>(node)->associatedEnum())
4329 m_writer->writeCharacters(
"flags ");
4330 m_writer->writeCharacters(namePrefix);
4331 generateSynopsisName(node, relative, generateNameLink);
4334 const auto property =
static_cast<
const PropertyNode *>(node);
4335 m_writer->writeCharacters(namePrefix);
4336 generateSynopsisName(node, relative, generateNameLink);
4337 m_writer->writeCharacters(
" : ");
4338 typified(property->qualifiedDataType(), relative,
false, generateType);
4341 const auto variable =
static_cast<
const VariableNode *>(node);
4343 generateSynopsisName(node, relative, generateNameLink);
4344 m_writer->writeCharacters(
" : ");
4345 typified(variable->dataType(), relative,
false, generateType);
4347 typified(variable->leftType(), relative,
false, generateType);
4348 m_writer->writeCharacters(
" ");
4349 m_writer->writeCharacters(namePrefix);
4350 generateSynopsisName(node, relative, generateNameLink);
4351 m_writer->writeCharacters(variable->rightType());
4355 m_writer->writeCharacters(namePrefix);
4356 generateSynopsisName(node, relative, generateNameLink);
4375 if (nativeEnum && nativeEnum
->enumNode() && !enumValue.startsWith(
"%1."_L1.arg(nativeEnum->prefix()))) {
4376 m_writer->writeCharacters(
"%1.%2"_L1.arg(nativeEnum->prefix(), enumValue));
4382 && enumValue.section(
' ', 0, 0).contains(
'.'_L1))) {
4383 m_writer->writeCharacters(enumValue);
4387 QList<
const Node *> parents;
4389 parents.prepend(node);
4394 if (
static_cast<
const EnumNode *>(relative)->isScoped())
4395 parents << relative;
4397 m_writer->writeStartElement(dbNamespace,
"code");
4398 for (
auto parent : parents) {
4399 generateSynopsisName(parent, relative,
true);
4400 m_writer->writeCharacters((relative->genus() == Genus::QML) ?
"."_L1 :
"::"_L1);
4403 m_writer->writeCharacters(enumValue);
4404 m_writer->writeEndElement();
4408
4409
4410
4415 Q_ASSERT(node && !node->name().isEmpty());
4421 m_writer->writeStartElement(dbNamespace,
"note");
4428 m_writer->writeStartElement(dbNamespace,
"para");
4429 m_writer->writeCharacters(
4430 "This function can be invoked via the meta-object system and from QML. See ");
4431 generateSimpleLink(node->url(),
"Q_INVOKABLE");
4432 m_writer->writeCharacters(
".");
4433 m_writer->writeEndElement();
4437 m_writer->writeTextElement(
4438 dbNamespace,
"para",
4439 "This is a private signal. It can be used in signal connections but "
4440 "cannot be emitted by the user.");
4444 QString handler(node->name());
4445 int prefixLocation = handler.lastIndexOf(
'.', -2) + 1;
4446 handler[prefixLocation] = handler[prefixLocation].toTitleCase();
4447 handler.insert(prefixLocation, QLatin1String(
"on"));
4448 m_writer->writeStartElement(dbNamespace,
"para");
4449 m_writer->writeCharacters(
"The corresponding handler is ");
4450 m_writer->writeTextElement(dbNamespace,
"code", handler);
4451 m_writer->writeCharacters(
".");
4452 m_writer->writeEndElement();
4460 const auto *fn =
static_cast<
const FunctionNode *>(node);
4461 auto nodes = fn->associatedProperties();
4462 if (nodes.isEmpty())
4467 QMap<PropertyNode::FunctionRole, QList<
const PropertyNode *>> roleGroups;
4468 for (
const auto *n : std::as_const(nodes)) {
4469 const auto *pn =
static_cast<
const PropertyNode *>(n);
4470 PropertyNode::FunctionRole role = pn->role(fn);
4471 roleGroups[role].append(pn);
4483 for (
auto role : roleOrder) {
4484 const auto it = roleGroups.constFind(role);
4485 if (it == roleGroups.cend())
4488 const auto &properties = it.value();
4493 msg = QStringLiteral(
"Getter function");
4496 msg = QStringLiteral(
"Setter function");
4499 msg = QStringLiteral(
"Resetter function");
4502 msg = QStringLiteral(
"Notifier signal");
4505 msg = QStringLiteral(
"Bindable function");
4511 m_writer->writeStartElement(dbNamespace,
"para");
4512 if (properties.size() == 1) {
4513 const auto *pn = properties.first();
4514 m_writer->writeCharacters(msg +
" for property ");
4515 generateSimpleLink(linkForNode(pn,
nullptr), pn->name());
4516 m_writer->writeCharacters(
". ");
4518 m_writer->writeCharacters(msg +
" for properties ");
4519 for (qsizetype i = 0; i < properties.size(); ++i) {
4520 const auto *pn = properties.at(i);
4521 generateSimpleLink(linkForNode(pn,
nullptr), pn->name());
4522 m_writer->writeCharacters(TextUtils::separator(i, properties.size()));
4524 m_writer->writeCharacters(
" ");
4526 m_writer->writeEndElement();
4533 const Node *linkNode;
4535 QString link = getAutoLink(&linkAtom, node, &linkNode);
4536 m_writer->writeStartElement(dbNamespace,
"para");
4537 m_writer->writeCharacters(
"This property supports ");
4538 generateSimpleLink(link,
"QProperty");
4539 m_writer->writeCharacters(
" bindings.");
4540 m_writer->writeEndElement();
4545 const auto *func =
static_cast<
const FunctionNode *>(node);
4548 if (func->isPrimaryOverload())
4551 m_writer->writeStartElement(dbNamespace,
"para");
4553 if (func->isSignal() || func->isSlot()) {
4554 auto writeDocBookLink = [&](
const QString &target,
const QString &label) {
4555 const Node *linkNode =
nullptr;
4557 const QString &link = getAutoLink(&linkAtom, node, &linkNode);
4559 m_writer->writeStartElement(dbNamespace,
"link");
4560 if (!link.isEmpty() && linkNode) {
4561 m_writer->writeAttribute(xlinkNamespace,
"href", link);
4563 m_writer->writeAttribute(dbNamespace,
"linkend", target);
4565 m_writer->writeCharacters(label);
4566 m_writer->writeEndElement();
4569 const QString &functionType = func->isSignal() ?
"signal" :
"slot";
4570 const QString &configKey = func->isSignal() ?
"overloadedsignalstarget" :
"overloadedslotstarget";
4571 const QString &defaultTarget = func->isSignal() ?
"connecting-overloaded-signals" :
"connecting-overloaded-slots";
4572 const QString &linkTarget = Config::instance().get(configKey).asString(defaultTarget);
4574 m_writer->writeCharacters(
"This " + functionType +
" is overloaded. ");
4576 QString snippet = generateOverloadSnippet(func);
4577 if (!snippet.isEmpty()) {
4578 m_writer->writeCharacters(
"To connect to this " + functionType +
":");
4579 m_writer->writeEndElement();
4581 m_writer->writeStartElement(dbNamespace,
"programlisting");
4582 m_writer->writeCharacters(snippet);
4583 m_writer->writeEndElement();
4588 m_writer->writeStartElement(dbNamespace,
"para");
4589 if (!linkTarget.isEmpty()) {
4590 m_writer->writeCharacters(
"For more examples and approaches, see ");
4591 writeDocBookLink(linkTarget,
"connecting to overloaded " + functionType +
"s");
4592 m_writer->writeCharacters(
".");
4594 }
else if (!linkTarget.isEmpty()) {
4595 m_writer->writeCharacters(
"For more examples and approaches, see ");
4596 writeDocBookLink(linkTarget,
"connecting to overloaded " + functionType +
"s");
4597 m_writer->writeCharacters(
".");
4601 const auto &args = node
->doc().overloadList();
4602 if (args.first().first.isEmpty()) {
4603 m_writer->writeCharacters(
"This is an overloaded function.");
4605 QString target = args.first().first;
4608 if (!target.contains(
"::")) {
4611 target = parent->name() +
"::" + target;
4614 m_writer->writeCharacters(
"This function overloads ");
4616 const Node *linkNode =
nullptr;
4618 QString link = getAutoLink(&linkAtom, node, &linkNode);
4619 if (!link.isEmpty() && linkNode)
4620 generateSimpleLink(link, target);
4622 m_writer->writeCharacters(target);
4623 m_writer->writeCharacters(
".");
4627 m_writer->writeEndElement();
4636 m_writer->writeEndElement();
4644 bool closeSupplementarySection =
false;
4648 const QList<Node *> &collective = scn->collective();
4650 bool firstFunction =
true;
4651 for (
const auto *sharedNode : collective) {
4652 if (firstFunction) {
4653 startSectionBegin(sharedNode);
4655 m_writer->writeStartElement(dbNamespace,
"bridgehead");
4656 m_writer->writeAttribute(
"renderas",
"sect2");
4657 writeXmlId(sharedNode);
4660 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
4662 generateSynopsis(sharedNode, relative, Section::Details);
4664 if (firstFunction) {
4666 firstFunction =
false;
4668 m_writer->writeEndElement();
4674 if (node->isEnumType(Genus::CPP) && (etn =
static_cast<
const EnumNode *>(node))->flagsType()) {
4675 startSectionBegin(node);
4677 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
4681 m_writer->writeStartElement(dbNamespace,
"bridgehead");
4682 m_writer->writeAttribute(
"renderas",
"sect2");
4684 m_writer->writeEndElement();
4687 startSectionBegin(node);
4689 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
4694 Q_ASSERT(m_hasSection);
4703 closeSupplementarySection =
true;
4704 startSection(
"",
"Notes");
4708 const auto *func =
static_cast<
const FunctionNode *>(node);
4709 if (func->hasOverloads() && (func->isSignal() || func->isSlot()))
4717 const auto property =
static_cast<
const PropertyNode *>(node);
4726 m_writer->writeStartElement(dbNamespace,
"para");
4728 m_writer->writeStartElement(dbNamespace,
"emphasis");
4729 m_writer->writeAttribute(
"role",
"bold");
4730 m_writer->writeCharacters(
"Access functions:");
4732 m_writer->writeEndElement();
4734 m_writer->writeEndElement();
4736 generateSectionList(section, node);
4743 m_writer->writeStartElement(dbNamespace,
"para");
4745 m_writer->writeStartElement(dbNamespace,
"emphasis");
4746 m_writer->writeAttribute(
"role",
"bold");
4747 m_writer->writeCharacters(
"Notifier signal:");
4749 m_writer->writeEndElement();
4751 m_writer->writeEndElement();
4753 generateSectionList(notifiers, node);
4757 const auto en =
static_cast<
const EnumNode *>(node);
4759 if (m_qflagsHref.isEmpty()) {
4760 Node *qflags = m_qdb->findClassNode(QStringList(
"QFlags"));
4762 m_qflagsHref = linkForNode(qflags,
nullptr);
4765 if (en->flagsType()) {
4766 m_writer->writeStartElement(dbNamespace,
"para");
4767 m_writer->writeCharacters(
"The ");
4768 m_writer->writeStartElement(dbNamespace,
"code");
4769 m_writer->writeCharacters(en->flagsType()->name());
4770 m_writer->writeEndElement();
4771 m_writer->writeCharacters(
" type is a typedef for ");
4772 m_writer->writeStartElement(dbNamespace,
"code");
4773 generateSimpleLink(m_qflagsHref,
"QFlags");
4774 m_writer->writeCharacters(
"<" + en->name() +
">. ");
4775 m_writer->writeEndElement();
4776 m_writer->writeCharacters(
"It stores an OR combination of ");
4777 m_writer->writeStartElement(dbNamespace,
"code");
4778 m_writer->writeCharacters(en->name());
4779 m_writer->writeEndElement();
4780 m_writer->writeCharacters(
" values.");
4781 m_writer->writeEndElement();
4786 if (closeSupplementarySection)
4797 bool useObsoleteMembers)
4802 if (!members.isEmpty()) {
4803 bool hasPrivateSignals =
false;
4804 bool isInvokable =
false;
4806 m_writer->writeStartElement(dbNamespace,
"itemizedlist");
4808 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
4811 NodeVector::ConstIterator m = members.constBegin();
4812 while (m != members.constEnd()) {
4813 if ((*m)->access() == Access::Private) {
4818 m_writer->writeStartElement(dbNamespace,
"listitem");
4820 m_writer->writeStartElement(dbNamespace,
"para");
4823 generateSynopsis(*m, relative, section
.style());
4824 if ((*m)->isFunction()) {
4826 if (fn->isPrivateSignal())
4827 hasPrivateSignals =
true;
4828 else if (fn->isInvokable())
4832 m_writer->writeEndElement();
4834 m_writer->writeEndElement();
4840 m_writer->writeEndElement();
4843 if (hasPrivateSignals)
4850 && !section.inheritedMembers().isEmpty()) {
4851 m_writer->writeStartElement(dbNamespace,
"itemizedlist");
4853 m_writer->writeAttribute(itsNamespace,
"translate",
"no");
4856 generateSectionInheritedList(section, relative);
4858 m_writer->writeEndElement();
4866 QList<std::pair<
const Aggregate *,
int>>::ConstIterator p = section.inheritedMembers().constBegin();
4867 while (p != section.inheritedMembers().constEnd()) {
4868 m_writer->writeStartElement(dbNamespace,
"listitem");
4869 m_writer->writeCharacters(QString::number((*p).second) + u' ');
4870 if ((*p).second == 1)
4871 m_writer->writeCharacters(section.singular());
4873 m_writer->writeCharacters(section.plural());
4874 m_writer->writeCharacters(
" inherited from ");
4875 generateSimpleLink(fileName((*p).first) +
'#'
4876 + Generator::cleanRef(section.title().toLower()),
4877 (*p).first->plainFullName(relative));
4883
4884
4885
4889 Q_ASSERT(m_writer ==
nullptr);
4890 m_writer = startDocument(pn);
4901
4902
4907 Q_ASSERT(m_writer ==
nullptr);
4908 m_writer = startDocument(qcn);
4911 QString title = qcn->name();
4913 title.append(
" QML Value Type");
4915 title.append(
" QML Type");
4918 title.append(
" (Singleton)");
4920 title.append(
" (Uncreatable)");
4931 m_writer->writeStartElement(dbNamespace,
"note");
4932 m_writer->writeStartElement(dbNamespace,
"para");
4933 m_writer->writeStartElement(dbNamespace,
"emphasis");
4934 m_writer->writeAttribute(
"role",
"bold");
4935 m_writer->writeCharacters(
"Note: ");
4936 m_writer->writeEndElement();
4937 if (qcn->isSingleton())
4938 m_writer->writeCharacters(
"This type is a QML singleton. "
4939 "There is only one instance of this type in the QML engine.");
4941 m_writer->writeCharacters(
"This is an uncreatable type. "
4942 "It cannot be instantiated in QML.");
4943 m_writer->writeEndElement();
4944 m_writer->writeEndElement();
4947 startSection(
"details",
"Detailed Description");
4955 for (
const auto §ion : sections.detailsSections()) {
4956 if (!section.isEmpty()) {
4957 startSection(section.title().toLower(), section.title());
4959 for (
const auto &member : section.members())
4960 generateDetailedQmlMember(member, qcn);
4966 generateObsoleteQmlMembers(sections);
4975
4976
4977
4984 if (!title.isEmpty())
4988 title += n->element() + QLatin1Char(
'.');
4989 title += n->name() +
" : " + n->dataType();
4994 auto generateQmlMethodTitle = [&](
Node *node) {
4999 const auto *scn =
static_cast<
const SharedCommentNode *>(node);
5002 if (!scn->name().isEmpty())
5003 heading = scn->name() +
" group";
5005 heading = node->name();
5006 startSection(scn, heading);
5011 const QList<Node *> sharedNodes = scn->collective();
5012 for (
const auto &sharedNode : sharedNodes) {
5013 if (sharedNode->isQmlProperty()) {
5014 auto *qpn =
static_cast<QmlPropertyNode *>(sharedNode);
5016 m_writer->writeStartElement(dbNamespace,
"bridgehead");
5017 m_writer->writeAttribute(
"renderas",
"sect2");
5019 m_writer->writeCharacters(getQmlPropertyTitle(qpn));
5020 m_writer->writeEndElement();
5023 generateDocBookSynopsis(qpn);
5027 auto qpn =
static_cast<QmlPropertyNode *>(node);
5028 startSection(qpn, getQmlPropertyTitle(qpn));
5032 const QList<Node *> &sharedNodes = scn->collective();
5037 for (
const auto &sharedNode : sharedNodes) {
5039 if (!sharedNode->isFunction(Genus::QML) && !sharedNode->isQmlProperty()) {
5045 startSectionBegin(sharedNode);
5047 m_writer->writeStartElement(dbNamespace,
"bridgehead");
5048 m_writer->writeAttribute(
"renderas",
"sect2");
5052 if (sharedNode->isFunction(Genus::QML))
5053 generateQmlMethodTitle(sharedNode);
5054 else if (sharedNode->isQmlProperty())
5055 m_writer->writeCharacters(
5056 getQmlPropertyTitle(
static_cast<QmlPropertyNode *>(sharedNode)));
5062 m_writer->writeEndElement();
5063 generateDocBookSynopsis(sharedNode);
5069 startSectionBegin(refForNode(node));
5072 generateQmlMethodTitle(node);
5073 else if (node->isQmlProperty())
5074 m_writer->writeCharacters(
5075 getQmlPropertyTitle(
static_cast<QmlPropertyNode *>(node)));
5080 startSectionBegin(node);
5084 startSectionBegin(node);
5085 generateQmlMethodTitle(node);
5099
5100
5107 if (!node->url().isNull())
5111 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139 auto cn =
static_cast<CollectionNode *>(node);
5140 if (cn->wasSeen()) {
5141 m_qdb->mergeCollections(cn);
5142 generateCollectionNode(cn);
5143 }
else if (cn->isGenericCollection()) {
5147 generateGenericCollectionPage(cn);
5150 generatePageNode(
static_cast<PageNode *>(node));
5154 generateCppReferencePage(
static_cast<Aggregate *>(node));
5156 generateQmlTypePage(
static_cast<QmlTypeNode *>(node));
5158 generateProxyPage(
static_cast<Aggregate *>(node));
5164 auto *aggregate =
static_cast<Aggregate *>(node);
5165 for (
auto c : aggregate->childNodes()) {
5166 if (node->isPageNode())
5167 generateDocumentation(c);
5178 Q_ASSERT(m_writer ==
nullptr);
5179 m_writer = startDocument(aggregate);
5187 if (!aggregate
->doc().isEmpty()) {
5188 startSection(
"details",
"Detailed Description");
5190 generateBody(aggregate);
5199 for (
const auto §ion : detailsSections) {
5200 if (section.isEmpty())
5203 startSection(section.title().toLower(), section.title());
5205 const QList<Node *> &members = section.members();
5206 for (
const auto &member : members) {
5207 if (!member->isClassNode()) {
5208 generateDetailedMember(member, aggregate);
5210 startSectionBegin();
5211 generateFullName(member, aggregate);
5214 generateBrief(member);
5228
5229
5234 Q_ASSERT(m_writer ==
nullptr);
5235 m_writer = startDocument(cn);
5244 if (cn
->genus() != Genus::DOC && cn
->genus() != Genus::DontCare) {
5255 if (!nmm.isEmpty()) {
5256 startSection(
"namespaces",
"Namespaces");
5257 generateAnnotatedList(cn, nmm.values(),
"namespaces");
5261 if (!nmm.isEmpty()) {
5262 startSection(
"classes",
"Classes");
5263 generateAnnotatedList(cn, nmm.values(),
"classes");
5269 bool generatedTitle =
false;
5271 startSection(
"details",
"Detailed Description");
5272 generatedTitle =
true;
5277 !cn
->doc().body().isEmpty() ||
5279 !cn
->doc().alsoList().empty() ||
5282 writeAnchor(
"details");
5288 if (!cn->noAutoList() && (cn->isGroup() || cn->isQmlModule()))
5289 generateAnnotatedList(cn, cn->members(),
"members", AutoSection);
5300
5301
5302
5303
5308 QString name = cn->name().toLower();
5309 name.replace(QChar(
' '), QString(
"-"));
5310 QString filename = cn
->tree()->physicalModuleName() +
"-" + name +
"." + fileExtension();
5313 Q_ASSERT(m_writer ==
nullptr);
5314 m_writer = startGenericDocument(cn, filename);
5323 m_writer->writeStartElement(dbNamespace,
"para");
5324 m_writer->writeCharacters(
"Each function or type documented here is related to a class or "
5325 "namespace that is documented in a different module. The reference "
5326 "page for that class or namespace will link to the function or type "
5328 m_writer->writeEndElement();
5332 for (
const auto &member : members)
5333 generateDetailedMember(member, cnc);
5346 m_writer->writeStartElement(dbNamespace,
"link");
5347 m_writer->writeAttribute(xlinkNamespace,
"href", fullDocumentLocation(node));
5348 m_writer->writeAttribute(xlinkNamespace,
"role", targetType(node));
5349 m_writer->writeCharacters(node->fullName(relative));
5350 m_writer->writeEndElement();
5354 const Node *actualNode)
5356 Q_ASSERT(apparentNode);
5357 Q_ASSERT(actualNode);
5360 m_writer->writeStartElement(dbNamespace,
"link");
5361 m_writer->writeAttribute(xlinkNamespace,
"href", fullDocumentLocation(actualNode));
5362 m_writer->writeAttribute(
"role", targetType(actualNode));
5363 m_writer->writeCharacters(fullName);
5364 m_writer->writeEndElement();
#define ATOM_FORMATTING_TELETYPE
#define ATOM_LIST_LOWERALPHA
#define ATOM_FORMATTING_UNDERLINE
#define ATOM_LIST_UPPERALPHA
#define ATOM_FORMATTING_NOTRANSLATE
#define ATOM_LIST_LOWERROMAN
#define ATOM_FORMATTING_SUBSCRIPT
#define ATOM_FORMATTING_BOLD
#define ATOM_FORMATTING_TRADEMARK
#define ATOM_FORMATTING_ITALIC
#define ATOM_LIST_UPPERROMAN
#define ATOM_FORMATTING_LINK
#define ATOM_FORMATTING_SUPERSCRIPT
#define ATOM_FORMATTING_UICONTROL
#define ATOM_FORMATTING_PARAMETER
The Atom class is the fundamental unit for representing documents internally.
AtomType type() const
Return the type of this atom.
const Atom * next() const
Return the next atom in the atom list.
The ClassNode represents a C++ class.
virtual Atom::AtomType atomType() const
A class for holding the members of a collection of doc pages.
const NodeList & members() const
NodeMap getMembers(NodeType type) const
void generatePageNode(PageNode *pn)
Generate the DocBook page for an entity that doesn't map to any underlying parsable C++ or QML elemen...
void generateQmlTypePage(QmlTypeNode *qcn)
Generate the DocBook page for a QML type.
void generateAlsoList(const Node *node) override
void generateQmlRequisites(const QmlTypeNode *qcn)
Lists the required imports and includes.
void generateAddendum(const Node *node, Generator::Addendum type, CodeMarker *marker, AdmonitionPrefix prefix) override
Generates an addendum note of type type for node.
void generateHeader(const Text &title, const Node *node)
Generates the opening portion of the DocBook header — {<db:info>} and the title element.
void initializeGenerator() override
Initializes the DocBook output generator's data structures from the configuration (Config).
bool generateText(const Text &text, const Node *relative) override
Generate the documentation for relative.
void finishHeader(const Node *node)
Emits the tail of the DocBook header — product, edition, titleabbrev, navigation links,...
void generateCppReferencePage(Node *node)
Generate a reference page for the C++ class, namespace, or header file documented in node.
void generateSortedQmlNames(const Node *base, const QStringList &knownTypes, const NodeList &subs)
DocBookGenerator(FileResolver &file_resolver)
bool generateThreadSafeness(const Node *node)
Generates text that explains how threadsafe and/or reentrant node is.
void generateCollectionNode(CollectionNode *cn)
Generate the HTML page for a group, module, or QML module.
void generateHeader(const Text &title, const QString &subtitle, const Node *node)
void generateDocBookSynopsis(const Node *node)
Generate the metadata for the given node in DocBook.
void generateGenericCollectionPage(CollectionNode *cn)
Generate the HTML page for a generic collection.
void generateList(const Node *relative, const QString &selector, Qt::SortOrder sortOrder=Qt::AscendingOrder)
void generateBody(const Node *node)
Generate the body of the documentation from the qdoc comment found with the entity represented by the...
qsizetype generateAtom(const Atom *atom, const Node *relative, CodeMarker *) override
Generate DocBook from an instance of Atom.
void generateProxyPage(Aggregate *aggregate)
bool generateStatus(const Node *node)
void generateRequisites(const Aggregate *inner)
Lists the required imports and includes.
void generateSortedNames(const ClassNode *cn, const QList< RelatedClass > &rc)
void generateDocumentation(Node *node) override
Recursive writing of DocBook files from the root node.
void generateGroupReferenceText(const Node *node)
Return a string representing a text that exposes information about the groups that the node is part o...
QString format() const override
Returns the format identifier for this producer (e.g., "HTML", "DocBook", "template").
void generateExampleFilePage(const PageNode *en, ResolvedFile resolved_file, CodeMarker *=nullptr) override
Generate a file with the contents of a C++ or QML source file.
QString fileExtension() const override
Returns "xml" for this subclass of Generator.
bool generateSince(const Node *node)
const Location & location() const
Returns the starting location of a qdoc comment.
static void quoteFromFile(const Location &location, Quoter "er, ResolvedFile resolved_file, CodeMarker *marker=nullptr)
const Text & body() const
Text briefText(bool inclusive=false) const
Text deprecationText() const
const TypedefNode * flagsType() const
Encapsulate the logic that QDoc uses to find files whose path is provided by the user and that are re...
This node is used to represent any kind of function being documented.
bool isMacroWithoutParams() const
bool isPrivateSignal() const
const Parameters & parameters() const
bool isPureVirtual() const override
bool hasOverloads() const
Returns true if this function has overloads.
bool isMacro() const override
returns true if either FunctionNode::isMacroWithParams() or FunctionNode::isMacroWithoutParams() retu...
bool isDeletedAsWritten() const
bool isExplicitlyDefaulted() const
bool hasAssociatedProperties() const
bool generateComparisonCategory(const Node *node, CodeMarker *marker=nullptr)
static void setQmlTypeContext(QmlTypeNode *t)
const Atom * generateAtomList(const Atom *atom, const Node *relative, CodeMarker *marker, bool generate, int &numGeneratedAtoms)
void unknownAtom(const Atom *atom)
static bool matchAhead(const Atom *atom, Atom::AtomType expectedAtomType)
void generateEnumValuesForQmlReference(const Node *node, CodeMarker *marker)
virtual int skipAtoms(const Atom *atom, Atom::AtomType type) const
bool generateComparisonTable(const Node *node)
Generates a table of comparison categories for node, combining both self-comparison (from \compares) ...
virtual void initializeGenerator()
No-op base implementation.
void initializeTextOutput()
Resets the variables used during text output.
static bool isIncluded(const InclusionPolicy &policy, const NodeContext &context)
This class represents a C++ namespace.
NamespaceNode * docNode() const
Returns a pointer to the NamespaceNode that represents where the namespace documentation is actually ...
Tree * tree() const override
Returns a pointer to the Tree that contains this NamespaceNode.
Interface implemented by Node subclasses that can refer to a C++ enum.
virtual const NativeEnum * nativeEnum() const =0
Encapsulates information about native (C++) enum values.
const EnumNode * enumNode() const
A PageNode is a Node that generates a documentation page.
bool noAutoList() const
Returns the value of the no auto-list flag.
The Parameter class describes one function parameter.
This class describes one instance of using the Q_PROPERTY macro.
This class provides exclusive access to the qdoc database, which consists of a forrest of trees and a...
static QDocDatabase * qdocDB()
Creates the singleton.
Status
Specifies the status of the QQmlIncubator.
bool isDefault() const override
Returns true if the QML property node is marked as default.
bool isReadOnly() const
Returns true if this QML property node is marked as a read-only property.
bool isRequired() const
Const overloads that delegate to the resolving non-const versions when the attribute hasn't been cach...
bool isAttached() const override
Returns true if the QML property or QML method node is marked as attached.
ClassNode * classNode() const override
If this is a QmlTypeNode, this function returns the pointer to the C++ ClassNode that this QML type r...
bool isUncreatable() const
static void subclasses(const Node *base, NodeList &subs, bool recurse=false)
Loads the list subs with the nodes of all the subclasses of base.
QmlTypeNode * qmlBaseNode() const override
If this Aggregate is a QmlTypeNode, this function returns a pointer to the QmlTypeNode that is its ba...
CollectionNode * logicalModule() const override
If this is a QmlTypeNode, a pointer to its QML module is returned, which is a pointer to a Collection...
A class for containing the elements of one documentation section.
const NodeVector & obsoleteMembers() const
void appendMembers(const NodeVector &nv)
const NodeVector & members() const
A class for creating vectors of collections for documentation.
const Aggregate * aggregate() const
Sections(const Aggregate *aggregate)
This constructor builds the section vectors based on the type of the aggregate node.
bool hasObsoleteMembers(SectionPtrVector *summary_spv, SectionPtrVector *details_spv) const
Returns true if any sections in this object contain obsolete members.
SectionVector & detailsSections()
static Text sectionHeading(const Atom *sectionBegin)
const Atom * firstAtom() const
Text & operator=(const Text &text)
const Atom * lastAtom() const
bool isStatic() const override
Returns true if the FunctionNode represents a static function.
static bool isOneColumnValueTable(const Atom *atom)
Determines whether the list atom should be shown with just one column (value).
static void rewritePropertyBrief(const Atom *atom, const Node *relative)
Rewrites the brief of this node depending on its first word.
static int hOffset(const Node *node)
Header offset depending on the type of the node.
static bool hasBrief(const Node *node)
Do not display.
XmlGenerator(FileResolver &file_resolver)
static const QRegularExpression m_funcLeftParen
static NodeType typeFromString(const Atom *atom)
Returns the type of this atom as an enumeration.
#define CONFIG_DOCBOOKEXTENSIONS
#define CONFIG_PRELIMINARY
#define CONFIG_DESCRIPTION
#define CONFIG_EXAMPLESINSTALLPATH
#define CONFIG_NATURALLANGUAGE
#define CONFIG_PRODUCTNAME
#define CONFIG_BUILDVERSION
static const char xlinkNamespace[]
static QString nodeToSynopsisTag(const Node *node)
QString removeCodeMarkers(const QString &code)
static const char dbNamespace[]
QString taggedNode(const Node *node)
static const char itsNamespace[]
Provides human-readable descriptions of QDoc nodes.
constexpr std::size_t MultilineTemplateParamThreshold
QList< Node * > NodeVector
QMap< QString, Node * > NodeMap
QMap< QString, NodeMap > NodeMapMap
QMap< QString, CollectionNode * > CNMap
QT_BEGIN_NAMESPACE typedef QMultiMap< Text, const Node * > TextToNodeMap
QList< const Section * > SectionPtrVector
QList< Section > SectionVector
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.
const Doc & doc() const
Returns a reference to the node's Doc data member.
bool isQmlNode() const
Returns true if this node's Genus value is QML.
bool isEnumType(Genus g) const
bool isGroup() const
Returns true if the node type is Group.
virtual bool docMustBeGenerated() const
This function is called to perform a test to decide if the node must have documentation generated.
bool isPrivate() const
Returns true if this node's access is Private.
bool isNamespace() const
Returns true if the node type is Namespace.
bool isTypedef() const
Returns true if the node type is Typedef.
bool isQmlBasicType() const
Returns true if the node type is QmlBasicType.
bool isQmlType() const
Returns true if the node type is QmlType or QmlValueType.
bool isSharedCommentNode() const
Returns true if the node type is SharedComment.
virtual bool isInternal() const
Returns true if the node's status is Internal, or if its parent is a class with Internal status.
bool isHeader() const
Returns true if the node type is HeaderFile.
NodeType nodeType() const override
Returns this node's type.
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.
bool isEnumType() const
Returns true if the node type is Enum.
virtual Status status() const
Returns the node's status value.
virtual bool isTextPageNode() const
Returns true if the node is a PageNode but not an Aggregate.
Aggregate * parent() const
Returns the node's parent pointer, that is, the aggregate under which the node is documented.
bool isVariable() const
Returns true if the node type is Variable.
virtual bool isDeprecated() const
Returns true if this node's status is Deprecated.
virtual bool isAggregate() const
Returns true if this node is an aggregate, which means it inherits Aggregate and can therefore have c...
static bool nodeNameLessThan(const Node *first, const Node *second)
Returns true if the node n1 is less than node n2.
const Location & location() const
If this node's definition location is empty, this function returns this node's declaration location.
bool isProxyNode() const
Returns true if the node type is Proxy.
Access access() const
Returns the node's Access setting, which can be Public, Protected, or Private.
bool isFunction(Genus g=Genus::DontCare) const
Returns true if this is a FunctionNode and its Genus is set to g.
ThreadSafeness threadSafeness() const
Returns the thread safeness value for whatever this node represents.
virtual bool isMarkedReimp() const
Returns true if the FunctionNode is marked as a reimplemented function.
bool isProperty() const
Returns true if the node type is Property.
virtual Tree * tree() const
Returns a pointer to the Tree this node is in.
NodeContext createContext() const
bool isModule() const
Returns true if the node type is Module.
bool isClass() const
Returns true if the node type is Class.
virtual bool isPropertyGroup() const
Returns true if the node is a SharedCommentNode for documenting multiple C++ properties or multiple Q...
ThreadSafeness
An unsigned char that specifies the degree of thread-safeness of the element.
bool isSharingComment() const
This function returns true if the node is sharing a comment with other nodes.
bool hasDoc() const
Returns true if this node is documented, or it represents a documented node read from the index ('had...
bool isRelatedNonmember() const
Returns true if this is a related nonmember of something.
virtual bool isClassNode() const
Returns true if this is an instance of ClassNode.
virtual bool isCollectionNode() const
Returns true if this is an instance of CollectionNode.
static bool nodeSortKeyOrNameLessThan(const Node *n1, const Node *n2)
Returns true if node n1 is less than node n2 when comparing the sort keys, defined with.
Aggregate * declarationParent() const
Returns the aggregate in whose C++ scope the node was declared, or null if the node was not adopted b...
bool isQmlModule() const
Returns true if the node type is QmlModule.
bool isExample() const
Returns true if the node type is Example.
bool isIndexNode() const
Returns true if this node was created from something in an index file.
bool isQmlProperty() const
Returns true if the node type is QmlProperty.
A class for parsing and managing a function parameter list.
const Parameter & at(int i) const
std::size_t visibleParameterCount() const
Returns the number of template parameters that are visible in rendered output — SFINAE-annotated para...
ValuedDeclaration valued_declaration
@ TemplateTemplateParameter
Represents a file that is reachable by QDoc based on its current configuration.