diff options
Diffstat (limited to 'src/qdoc/htmlgenerator.cpp')
-rw-r--r-- | src/qdoc/htmlgenerator.cpp | 902 |
1 files changed, 236 insertions, 666 deletions
diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index 97222ef13..a336467ba 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -199,10 +199,8 @@ void HtmlGenerator::initializeGenerator(const Config &config) if (naturalLanguage.isEmpty()) naturalLanguage = QLatin1String("en"); - QSet<QString> editionNames = config.subVars(CONFIG_EDITION); - QSet<QString>::ConstIterator edition = editionNames.constBegin(); - while (edition != editionNames.constEnd()) { - QString editionName = *edition; + const QSet<QString> editionNames = config.subVars(CONFIG_EDITION); + for (const auto &editionName : editionNames) { QStringList editionModules = config.getStringList(CONFIG_EDITION + Config::dot + editionName + @@ -218,8 +216,6 @@ void HtmlGenerator::initializeGenerator(const Config &config) editionModuleMap[editionName] = editionModules; if (!editionGroups.isEmpty()) editionGroupMap[editionName] = editionGroups; - - ++edition; } codeIndent = config.getInt(CONFIG_CODEINDENT); // QTBUG-27798 @@ -569,25 +565,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark break; } out() << "<p>"; - if (relative->isProperty() || relative->isVariable()) { - atom = atom->next(); - if (atom != nullptr && atom->type() == Atom::String) { - QString firstWord = atom->string().toLower().section(' ', 0, 0, QString::SectionSkipEmpty); - if (firstWord == QLatin1String("the") - || firstWord == QLatin1String("a") - || firstWord == QLatin1String("an") - || firstWord == QLatin1String("whether") - || firstWord == QLatin1String("which")) { - QString str = "This "; - if (relative->isProperty()) - str += "property holds "; - else - str += "variable holds "; - str += atom->string().left(1).toLower() + atom->string().mid(1); - const_cast<Atom *>(atom)->setString(str); - } - } - } + rewritePropertyBrief(atom, relative); break; case Atom::BriefRight: if (hasBrief(relative)) @@ -598,12 +576,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark // now widely used to write teletype text. As a result, text marked // with the \c command is not passed to a code marker. out() << formattingLeftMap()[ATOM_FORMATTING_TELETYPE]; - if (inLink_) { - out() << protectEnc(plainCode(atom->string())); - } - else { - out() << protectEnc(plainCode(atom->string())); - } + out() << protectEnc(plainCode(atom->string())); out() << formattingRightMap()[ATOM_FORMATTING_TELETYPE]; break; case Atom::CaptionLeft: @@ -728,13 +701,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark } else if ((idx = atom->string().indexOf(QStringLiteral("bymodule"))) != -1) { QString moduleName = atom->string().mid(idx + 8).trimmed(); - Node::NodeType type = Node::Module; - if (atom->string().startsWith(QLatin1String("qml"))) - type = Node::QmlModule; - else if (atom->string().startsWith(QLatin1String("js"))) - type = Node::JsModule; - else if (atom->string().startsWith(QLatin1String("groups"))) - type = Node::Group; + Node::NodeType type = typeFromString(atom); QDocDatabase *qdb = QDocDatabase::qdocDB(); const CollectionNode *cn = qdb->getCollectionNode(moduleName, type); if (cn) { @@ -816,28 +783,26 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark Sections sections(nsmap); out() << "<ul>\n"; - QVector<Section>::ConstIterator s = sections.sinceSections().constBegin(); - while (s != sections.sinceSections().constEnd()) { - if (!s->members().isEmpty()) { + const QVector<Section> sinceSections = sections.sinceSections(); + for (const auto §ion : sinceSections) { + if (!section.members().isEmpty()) { out() << "<li>" << "<a href=\"#" - << Doc::canonicalTitle(s->title()) + << Doc::canonicalTitle(section.title()) << "\">" - << s->title() + << section.title() << "</a></li>\n"; } - ++s; } out() << "</ul>\n"; int idx = 0; - s = sections.sinceSections().constBegin(); - while (s != sections.sinceSections().constEnd()) { - if (!s->members().isEmpty()) { + for (const auto §ion : sinceSections) { + if (!section.members().isEmpty()) { out() << "<a name=\"" - << Doc::canonicalTitle(s->title()) + << Doc::canonicalTitle(section.title()) << "\"></a>\n"; - out() << "<h3>" << protectEnc(s->title()) << "</h3>\n"; + out() << "<h3>" << protectEnc(section.title()) << "</h3>\n"; if (idx == Sections::SinceClasses) generateCompactList(Generic, nullptr, ncmap, false, QStringLiteral("Q")); else if (idx == Sections::SinceQmlTypes) @@ -845,37 +810,33 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark else if (idx == Sections::SinceMemberFunctions) { ParentMaps parentmaps; ParentMaps::iterator pmap; - NodeVector::const_iterator i = s->members().constBegin(); - while (i != s->members().constEnd()) { - Node *p = (*i)->parent(); - pmap = parentmaps.find(p); + const QVector<Node *> members = section.members(); + for (const auto &member : members) { + Node *parent = (*member).parent(); + pmap = parentmaps.find(parent); if (pmap == parentmaps.end()) - pmap = parentmaps.insert(p,NodeMultiMap()); - pmap->insert((*i)->name(),(*i)); - ++i; + pmap = parentmaps.insert(parent, NodeMultiMap()); + pmap->insert(member->name(), member); } - pmap = parentmaps.begin(); - while (pmap != parentmaps.end()) { - NodeVector nv = pmap->values().toVector(); + for (auto map = parentmaps.begin(); map != parentmaps.end(); ++map) { + NodeVector nv = map->values().toVector(); out() << "<p>Class "; out() << "<a href=\"" - << linkForNode(pmap.key(), nullptr) + << linkForNode(map.key(), nullptr) << "\">"; - QStringList pieces = pmap.key()->fullName().split("::"); + QStringList pieces = map.key()->fullName().split("::"); out() << protectEnc(pieces.last()); out() << "</a>" << ":</p>\n"; generateSection(nv, nullptr, marker); out() << "<br/>"; - ++pmap; } + } else { + generateSection(section.members(), nullptr, marker); } - else - generateSection(s->members(), nullptr, marker); } ++idx; - ++s; } } break; @@ -908,13 +869,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark out() << " alt=\"\""; out() << " />"; helpProjectWriter->addExtraFile(fileName); - if (relative->isExample()) { - const ExampleNode *cen = static_cast<const ExampleNode *>(relative); - if (cen->imageFileName().isEmpty()) { - ExampleNode *en = const_cast<ExampleNode *>(cen); - en->setImageFileName(fileName); - } - } + setImageFileName(relative, fileName); } if (atom->type() == Atom::Image) out() << "</p>"; @@ -969,23 +924,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark QString target = qdb_->getNewLinkTarget(relative, node, outFileName(), text); out() << "<a id=\"" << Doc::canonicalTitle(target) << "\" class=\"qa-mark\"></a>"; } - /* - mws saw this on 17/10/2014. - Is this correct? Setting node to 0 means the - following test always fails. Did we decide to - no longer warn about linking to obsolete things? - */ node = nullptr; - if (node && node->isObsolete()) { - if ((relative->parent() != node) && !relative->isObsolete()) { - inObsoleteLink = true; - if (obsoleteLinks) { - relative->doc().location().warning(tr("Link to obsolete item '%1' in %2") - .arg(atom->string()) - .arg(relative->plainFullName())); - } - } - } } beginLink(link, node, relative); skipAhead = 1; @@ -1082,24 +1021,9 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark out() << "<dt>"; } else { // (atom->string() == ATOM_LIST_VALUE) - const Atom *lookAhead = atom->next(); - QString t = lookAhead->string(); - lookAhead = lookAhead->next(); - Q_ASSERT(lookAhead->type() == Atom::ListTagRight); - lookAhead = lookAhead->next(); - if (lookAhead && lookAhead->type() == Atom::SinceTagLeft) { - lookAhead = lookAhead->next(); - Q_ASSERT(lookAhead && lookAhead->type() == Atom::String); - t = t + QLatin1String(" (since "); - if (lookAhead->string().at(0).isDigit()) - t = t + QLatin1String("Qt "); - t = t + lookAhead->string() + QLatin1String(")"); - skipAhead = 4; - } - else { - skipAhead = 1; - } - t = protectEnc(plainCode(marker->markedUpEnumValue(t, relative))); + QPair<QString, int> pair = getAtomListValue(atom); + skipAhead = pair.second; + QString t = protectEnc(plainCode(marker->markedUpEnumValue(pair.first, relative))); out() << "<tr><td class=\"topAlign\"><code>" << t << "</code>"; if (relative->isEnumType()) { @@ -1215,30 +1139,15 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark break; case Atom::TableLeft: { - QString p1, p2; - QString attr = "generic"; - QString width; + QPair<QString, QString> pair = getTableWidthAttr(atom); + QString attr = pair.second; + QString width = pair.first; + if (in_para) { out() << "</p>\n"; in_para = false; } - if (atom->count() > 0) { - p1 = atom->string(0); - if (atom->count() > 1) - p2 = atom->string(1); - } - if (!p1.isEmpty()) { - if (p1 == QLatin1String("borderless")) - attr = p1; - else if (p1.contains(QLatin1Char('%'))) - width = p1; - } - if (!p2.isEmpty()) { - if (p2 == QLatin1String("borderless")) - attr = p2; - else if (p2.contains(QLatin1Char('%'))) - width = p2; - } + out() << "<div class=\"table\"><table class=\"" << attr << '"'; if (!width.isEmpty()) out() << " width=\"" << width << '"'; @@ -1303,7 +1212,6 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark out() << '>'; else { out() << '>'; - //out() << "><p>"; } if (matchAhead(atom, Atom::ParaLeft)) skipAhead = 1; @@ -1314,7 +1222,6 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark out() << "</th>"; else { out() << "</td>"; - //out() << "</p></td>"; } if (matchAhead(atom, Atom::ParaLeft)) skipAhead = 1; @@ -1446,45 +1353,40 @@ void HtmlGenerator::generateCppReferencePage(Aggregate *aggregate, CodeMarker *m bool needOtherSection = false; - SectionVector::ConstIterator s = summarySections->constBegin(); - while (s != summarySections->constEnd()) { - if (s->members().isEmpty() && s->reimplementedMembers().isEmpty()) { - if (!s->inheritedMembers().isEmpty()) + for (const auto §ion : qAsConst(*summarySections)) { + if (section.members().isEmpty() && section.reimplementedMembers().isEmpty()) { + if (!section.inheritedMembers().isEmpty()) needOtherSection = true; - } - else { - if (!s->members().isEmpty()) { - QString ref = registerRef(s->title().toLower()); + } else { + if (!section.members().isEmpty()) { + QString ref = registerRef(section.title().toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << "\n"; - out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->title()) << "</h2>\n"; - generateSection(s->members(), aggregate, marker); + out() << "<h2 id=\"" << ref << "\">" << protectEnc(section.title()) << "</h2>\n"; + generateSection(section.members(), aggregate, marker); } - if (!s->reimplementedMembers().isEmpty()) { - QString name = QString("Reimplemented ") + s->title(); + if (!section.reimplementedMembers().isEmpty()) { + QString name = QString("Reimplemented ") + section.title(); QString ref = registerRef(name.toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << "\n"; out() << "<h2 id=\"" << ref << "\">" << protectEnc(name) << "</h2>\n"; - generateSection(s->reimplementedMembers(), aggregate, marker); + generateSection(section.reimplementedMembers(), aggregate, marker); } - if (!s->inheritedMembers().isEmpty()) { + if (!section.inheritedMembers().isEmpty()) { out() << "<ul>\n"; - generateSectionInheritedList(*s, aggregate); + generateSectionInheritedList(section, aggregate); out() << "</ul>\n"; } } - ++s; } if (needOtherSection) { out() << "<h3>Additional Inherited Members</h3>\n" "<ul>\n"; - s = summarySections->constBegin(); - while (s != summarySections->constEnd()) { - if (s->members().isEmpty() && !s->inheritedMembers().isEmpty()) - generateSectionInheritedList(*s, aggregate); - ++s; + for (const auto §ion : qAsConst(*summarySections)) { + if (section.members().isEmpty() && !section.inheritedMembers().isEmpty()) + generateSectionInheritedList(section, aggregate); } out() << "</ul>\n"; } @@ -1508,42 +1410,38 @@ void HtmlGenerator::generateCppReferencePage(Aggregate *aggregate, CodeMarker *m generateExtractionMark(aggregate, EndMark); } - s = detailsSections->constBegin(); - while (s != detailsSections->constEnd()) { + for (const auto §ion :qAsConst(*detailsSections)) { bool headerGenerated = false; - if (s->isEmpty()) { - ++s; + if (section.isEmpty()) continue; - } - NodeVector::ConstIterator m = s->members().constBegin(); - while (m != s->members().constEnd()) { - if ((*m)->access() == Node::Private) { // ### check necessary? - ++m; + + const QVector<Node *> members = section.members(); + for (const auto &member : members) { + if (member->access() == Node::Private) // ### check necessary? continue; - } if (!headerGenerated) { - if (!s->divClass().isEmpty()) - out() << "<div class=\"" << s->divClass() << "\">\n"; // QTBUG-9504 - out() << "<h2>" << protectEnc(s->title()) << "</h2>\n"; + if (!section.divClass().isEmpty()) + out() << "<div class=\"" << section.divClass() << "\">\n"; // QTBUG-9504 + out() << "<h2>" << protectEnc(section.title()) << "</h2>\n"; headerGenerated = true; } - if (!(*m)->isClassNode()) - generateDetailedMember(*m, aggregate, marker); + if (!member->isClassNode()) + generateDetailedMember(member, aggregate, marker); else { out() << "<h3> class "; - generateFullName(*m, aggregate); + generateFullName(member, aggregate); out() << "</h3>"; - generateBrief(*m, marker, aggregate); + generateBrief(member, marker, aggregate); } QStringList names; - names << (*m)->name(); - if ((*m)->isFunction()) { - const FunctionNode *func = reinterpret_cast<const FunctionNode *>(*m); + names << member->name(); + if (member->isFunction()) { + const FunctionNode *func = reinterpret_cast<const FunctionNode *>(member); if (func->isSomeCtor() || func->isDtor() || func->overloadNumber() != 0) names.clear(); - } else if ((*m)->isProperty()) { - const PropertyNode *prop = reinterpret_cast<const PropertyNode *>(*m); + } else if (member->isProperty()) { + const PropertyNode *prop = reinterpret_cast<const PropertyNode *>(member); if (!prop->getters().isEmpty() && !names.contains(prop->getters().first()->name())) names << prop->getters().first()->name(); @@ -1553,8 +1451,8 @@ void HtmlGenerator::generateCppReferencePage(Aggregate *aggregate, CodeMarker *m names << prop->resetters().first()->name(); if (!prop->notifiers().isEmpty()) names << prop->notifiers().first()->name(); - } else if ((*m)->isEnumType()) { - const EnumNode *enume = reinterpret_cast<const EnumNode *>(*m); + } else if (member->isEnumType()) { + const EnumNode *enume = reinterpret_cast<const EnumNode *>(member); if (enume->flagsType()) names << enume->flagsType()->name(); const auto &enumItemNameList = enume->doc().enumItemNames(); @@ -1566,11 +1464,9 @@ void HtmlGenerator::generateCppReferencePage(Aggregate *aggregate, CodeMarker *m enume)); } } - ++m; } - if (headerGenerated && !s->divClass().isEmpty()) + if (headerGenerated && !section.divClass().isEmpty()) out() << "</div>\n"; // QTBUG-9504 - ++s; } generateFooter(aggregate); } @@ -1595,16 +1491,13 @@ void HtmlGenerator::generateProxyPage(Aggregate *aggregate, CodeMarker *marker) generateHeader(title, aggregate, marker); generateTitle(title, subtitleText, SmallSubTitle, aggregate, marker); generateBrief(aggregate, marker); - SectionVector::ConstIterator s = summarySections->constBegin(); - while (s != summarySections->constEnd()) { - if (!s->members().isEmpty()) { - // out() << "<hr />\n"; - QString ref = registerRef(s->title().toLower()); + for (auto it = summarySections->constBegin(); it != summarySections->constEnd(); ++it) { + if (!it->members().isEmpty()) { + QString ref = registerRef(it->title().toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << "\n"; - out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->title()) << "</h2>\n"; - generateSection(s->members(), aggregate, marker); + out() << "<h2 id=\"" << ref << "\">" << protectEnc(it->title()) << "</h2>\n"; + generateSection(it->members(), aggregate, marker); } - ++s; } QString detailsRef = registerRef("details"); @@ -1612,7 +1505,6 @@ void HtmlGenerator::generateProxyPage(Aggregate *aggregate, CodeMarker *marker) if (!aggregate->doc().isEmpty()) { generateExtractionMark(aggregate, DetailedDescriptionMark); - //out() << "<hr />\n" out() << "<div class=\"descr\">\n" // QTBUG-9504 << "<h2 id=\"" << detailsRef << "\">" << "Detailed Description" << "</h2>\n"; generateBody(aggregate, marker); @@ -1622,54 +1514,47 @@ void HtmlGenerator::generateProxyPage(Aggregate *aggregate, CodeMarker *marker) generateExtractionMark(aggregate, EndMark); } - s = detailsSections->constBegin(); - while (s != detailsSections->constEnd()) { - if (s->isEmpty()) { - ++s; + for (const auto §ion : qAsConst(*detailsSections)) { + if (section.isEmpty()) continue; - } - //out() << "<hr />\n"; - if (!s->divClass().isEmpty()) - out() << "<div class=\"" << s->divClass() << "\">\n"; // QTBUG-9504 - out() << "<h2>" << protectEnc(s->title()) << "</h2>\n"; - NodeVector::ConstIterator m = s->members().constBegin(); - while (m != s->members().constEnd()) { - if (!(*m)->isPrivate()) { // ### check necessary? - if (!(*m)->isClassNode()) - generateDetailedMember(*m, aggregate, marker); + if (!section.divClass().isEmpty()) + out() << "<div class=\"" << section.divClass() << "\">\n"; // QTBUG-9504 + out() << "<h2>" << protectEnc(section.title()) << "</h2>\n"; + + const QVector<Node *> &members = section.members(); + for (const auto &member : members) { + if (!member->isPrivate()) { // ### check necessary? + if (!member->isClassNode()) + generateDetailedMember(member, aggregate, marker); else { out() << "<h3> class "; - generateFullName(*m, aggregate); + generateFullName(member, aggregate); out() << "</h3>"; - generateBrief(*m, marker, aggregate); + generateBrief(member, marker, aggregate); } QStringList names; - names << (*m)->name(); - if ((*m)->isFunction()) { - const FunctionNode *func = reinterpret_cast<const FunctionNode *>(*m); + names << member->name(); + if (member->isFunction()) { + const FunctionNode *func = reinterpret_cast<const FunctionNode *>(member); if (func->isSomeCtor() || func->isDtor() || func->overloadNumber() != 0) names.clear(); - } else if ((*m)->isEnumType()) { - const EnumNode *enume = reinterpret_cast<const EnumNode *>(*m); + } else if (member->isEnumType()) { + const EnumNode *enume = reinterpret_cast<const EnumNode *>(member); if (enume->flagsType()) names << enume->flagsType()->name(); const auto &enumItemNameList = enume->doc().enumItemNames(); const auto &omitEnumItemNameList = enume->doc().omitEnumItemNames(); const auto items = QSet<QString>(enumItemNameList.cbegin(), enumItemNameList.cend()) - QSet<QString>(omitEnumItemNameList.cbegin(), omitEnumItemNameList.cend()); - for (const QString &enumName : items) { - names << plainCode(marker->markedUpEnumValue(enumName, - enume)); - } + for (const QString &enumName : items) + names << plainCode(marker->markedUpEnumValue(enumName, enume)); } } - ++m; } - if (!s->divClass().isEmpty()) + if (!section.divClass().isEmpty()) out() << "</div>\n"; // QTBUG-9504 - ++s; } generateFooter(aggregate); } @@ -1712,16 +1597,15 @@ void HtmlGenerator::generateQmlTypePage(QmlTypeNode *qcn, CodeMarker *marker) out() << "</ul>\n"; } - SectionVector::ConstIterator s = sections.stdQmlTypeSummarySections().constBegin(); - while (s != sections.stdQmlTypeSummarySections().constEnd()) { - if (!s->isEmpty()) { - QString ref = registerRef(s->title().toLower()); + const QVector<Section> &stdQmlTypeSummarySections = sections.stdQmlTypeSummarySections(); + for (const auto §ion : stdQmlTypeSummarySections) { + if (!section.isEmpty()) { + QString ref = registerRef(section.title().toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n'; - out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->title()) << "</h2>\n"; - generateQmlSummary(s->members(), qcn, marker); + out() << "<h2 id=\"" << ref << "\">" << protectEnc(section.title()) << "</h2>\n"; + generateQmlSummary(section.members(), qcn, marker); } - ++s; } generateExtractionMark(qcn, DetailedDescriptionMark); @@ -1734,20 +1618,17 @@ void HtmlGenerator::generateQmlTypePage(QmlTypeNode *qcn, CodeMarker *marker) generateQmlText(cn->doc().body(), cn, marker, qcn->name()); generateAlsoList(qcn, marker); generateExtractionMark(qcn, EndMark); - //out() << "<hr />\n"; - - s = sections.stdQmlTypeDetailsSections().constBegin(); - while (s != sections.stdQmlTypeDetailsSections().constEnd()) { - if (!s->isEmpty()) { - out() << "<h2>" << protectEnc(s->title()) << "</h2>\n"; - NodeVector::ConstIterator m = s->members().constBegin(); - while (m != s->members().constEnd()) { - generateDetailedQmlMember(*m, qcn, marker); + + const QVector<Section> &stdQmlTypeDetailsSections = sections.stdQmlTypeDetailsSections(); + for (const auto §ion : stdQmlTypeDetailsSections) { + if (!section.isEmpty()) { + out() << "<h2>" << protectEnc(section.title()) << "</h2>\n"; + const QVector<Node *> members = section.members(); + for (const auto member : members) { + generateDetailedQmlMember(member, qcn, marker); out() << "<br/>\n"; - ++m; } } - ++s; } generateFooter(qcn); Generator::setQmlTypeContext(nullptr); @@ -1778,16 +1659,15 @@ void HtmlGenerator::generateQmlBasicTypePage(QmlBasicTypeNode *qbtn, CodeMarker qbtn, marker); - SectionVector::const_iterator s = sections.stdQmlTypeSummarySections().constBegin(); - while (s != sections.stdQmlTypeSummarySections().constEnd()) { - if (!s->isEmpty()) { - QString ref = registerRef(s->title().toLower()); + const QVector<Section> &stdQmlTypeSummarySections = sections.stdQmlTypeSummarySections(); + for (const auto §ion : stdQmlTypeSummarySections) { + if (!section.isEmpty()) { + QString ref = registerRef(section.title().toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n'; - out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->title()) << "</h2>\n"; - generateQmlSummary(s->members(), qbtn, marker); + out() << "<h2 id=\"" << ref << "\">" << protectEnc(section.title()) << "</h2>\n"; + generateQmlSummary(section.members(), qbtn, marker); } - ++s; } generateExtractionMark(qbtn, DetailedDescriptionMark); @@ -1798,18 +1678,16 @@ void HtmlGenerator::generateQmlBasicTypePage(QmlBasicTypeNode *qbtn, CodeMarker generateAlsoList(qbtn, marker); generateExtractionMark(qbtn, EndMark); - s = sections.stdQmlTypeDetailsSections().constBegin(); - while (s != sections.stdQmlTypeDetailsSections().constEnd()) { - if (!s->isEmpty()) { - out() << "<h2>" << protectEnc(s->title()) << "</h2>\n"; - NodeVector::ConstIterator m = s->members().constBegin(); - while (m != s->members().constEnd()) { - generateDetailedQmlMember(*m, qbtn, marker); + const QVector<Section> &stdQmlTypeDetailsSections = sections.stdQmlTypeDetailsSections(); + for (const auto §ion : stdQmlTypeDetailsSections) { + if (!section.isEmpty()) { + out() << "<h2>" << protectEnc(section.title()) << "</h2>\n"; + const QVector<Node *> members = section.members(); + for (const auto member : members) { + generateDetailedQmlMember(member, qbtn, marker); out() << "<br/>\n"; - ++m; } } - ++s; } generateFooter(qbtn); } @@ -1942,13 +1820,10 @@ void HtmlGenerator::generateGenericCollectionPage(CollectionNode *cn, CodeMarker generateText(brief, cn, marker); out() << "</p>\n"; - NodeList::ConstIterator m = cn->members().constBegin(); - while (m != cn->members().constEnd()) { - generateDetailedMember(*m, cn, marker); - ++m; - } + const QList<Node *> members = cn->members(); + for (const auto &member : members) + generateDetailedMember(member, cn, marker); - // generateAnnotatedList(cn, marker, cn->members()); generateFooter(cn); } @@ -1969,7 +1844,7 @@ void HtmlGenerator::generateNavigationBar(const QString &title, const QString &buildversion, bool tableItems) { - if (noNavigationBar) + if (noNavigationBar || node == nullptr) return; Text navigationbar; @@ -2335,25 +2210,22 @@ void HtmlGenerator::generateRequisites(Aggregate *aggregate, CodeMarker *marker) } //add the inherits to the map - QList<RelatedClass>::ConstIterator r; - int index; if (!classe->baseClasses().isEmpty()) { + int index = 0; text.clear(); - r = classe->baseClasses().constBegin(); - index = 0; - while (r != classe->baseClasses().constEnd()) { - if ((*r).node_) { - appendFullName(text, (*r).node_, classe); + const auto baseClasses = classe->baseClasses(); + for (const auto &cls : baseClasses) { + if (cls.node_) { + appendFullName(text, cls.node_, classe); - if ((*r).access_ == Node::Protected) { + if (cls.access_ == Node::Protected) { text << " (protected)"; } - else if ((*r).access_ == Node::Private) { + else if (cls.access_ == Node::Private) { text << " (private)"; } text << comma(index++, classe->baseClasses().count()); } - ++r; } text << Atom::ParaRight; if (index > 0) @@ -2375,19 +2247,18 @@ void HtmlGenerator::generateRequisites(Aggregate *aggregate, CodeMarker *marker) //generate the table out() << "<div class=\"table\"><table class=\"alignedsummary\">\n"; - QStringList::ConstIterator i; - for (i = requisiteorder.constBegin(); i != requisiteorder.constEnd(); ++i) { + for (auto it = requisiteorder.constBegin(); it != requisiteorder.constEnd(); ++it) { - if (requisites.contains(*i)) { + if (requisites.contains(*it)) { out() << "<tr>" << "<td class=\"memItemLeft rightAlign topAlign\"> " - << *i << ":" + << *it << ":" "</td><td class=\"memItemRight bottomAlign\"> "; - if (*i == headerText) - out() << requisites.value(*i).toString(); + if (*it == headerText) + out() << requisites.value(*it).toString(); else - generateText(requisites.value(*i), aggregate, marker); + generateText(requisites.value(*it), aggregate, marker); out() << "</td></tr>"; } } @@ -2412,14 +2283,6 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker) const QString inheritsText = "Inherits:"; const QString instantiatesText = "Instantiates:"; - //The order of the requisites matter - QStringList requisiteorder; - requisiteorder << importText - << sinceText - << instantiatesText - << inheritsText - << inheritedBytext; - //add the module name and version to the map QString logicalModuleVersion; const CollectionNode *collection = qdb_->getCollectionNode(qcn->logicalModuleName(), qcn->nodeType()); @@ -2495,23 +2358,29 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker) requisites.insert(inheritedBytext, text); } + //The order of the requisites matter + const QStringList requisiteorder { + importText, + sinceText, + instantiatesText, + inheritsText, + inheritedBytext }; + if (!requisites.isEmpty()) { //generate the table out() << "<div class=\"table\"><table class=\"alignedsummary\">\n"; + for (const auto &requisite : requisiteorder) { - QStringList::ConstIterator i; - for (i = requisiteorder.constBegin(); i != requisiteorder.constEnd(); ++i) { - - if (requisites.contains(*i)) { + if (requisites.contains(requisite)) { out() << "<tr>" << "<td class=\"memItemLeft rightAlign topAlign\"> " - << *i + << requisite << "</td><td class=\"memItemRight bottomAlign\"> "; - if (*i == importText) - out()<<requisites.value(*i).toString(); + if (requisite == importText) + out()<<requisites.value(requisite).toString(); else - generateText(requisites.value(*i), qcn, marker); + generateText(requisites.value(requisite), qcn, marker); out() << "</td></tr>"; } } @@ -2554,7 +2423,7 @@ void HtmlGenerator::generateTableOfContents(const Node *node, CodeMarker *marker, QVector<Section> *sections) { - QList<Atom *> toc; + QVector<Atom *> toc; if (node->doc().hasTableOfContents()) toc = node->doc().tableOfContents(); if (tocDepth == 0 || (toc.isEmpty() && !sections && !node->isModule())) { @@ -2605,26 +2474,24 @@ void HtmlGenerator::generateTableOfContents(const Node *node, node->isNamespace() || node->isQmlType() || node->isJsType())) { - SectionVector::ConstIterator s = sections->constBegin(); - while (s != sections->constEnd()) { - if (!s->members().isEmpty()) { + for (const auto §ion : qAsConst(*sections)) { + if (!section.members().isEmpty()) { out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#" - << registerRef(s->plural()) - << "\">" << s->title() + << registerRef(section.plural()) + << "\">" << section.title() << "</a></li>\n"; } - if (!s->reimplementedMembers().isEmpty()) { - QString ref = QString("Reimplemented ") + s->plural(); + if (!section.reimplementedMembers().isEmpty()) { + QString ref = QString("Reimplemented ") + section.plural(); out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#" << registerRef(ref.toLower()) - << "\">" << QString("Reimplemented ") + s->title() + << "\">" << QString("Reimplemented ") + section.title() << "</a></li>\n"; } - ++s; } if (!node->isNamespace() || node->hasDoc()) { out() << "<li class=\"level" @@ -2641,8 +2508,7 @@ void HtmlGenerator::generateTableOfContents(const Node *node, } } - for (int i = 0; i < toc.size(); ++i) { - const Atom *atom = toc.at(i); + for (const auto &atom : toc) { sectionNumber = atom->string().toInt() + detailsBase; //restrict the ToC depth to the one set by the HTML.tocdepth variable or //print all levels if tocDepth is not set. @@ -2803,22 +2669,18 @@ QString HtmlGenerator::generateObsoleteMembersFile(const Sections §ions, Cod << "They are provided to keep old source code working. " << "We strongly advise against using them in new code.</p>\n"; - for (int i = 0; i < summary_spv.size(); ++i) { - out() << "<h2>" << protectEnc(summary_spv.at(i)->title()) << "</h2>\n"; - const Section §ion = *summary_spv.at(i); - generateSectionList(section, aggregate, marker, Section::Obsolete); + for (const auto §ion : summary_spv) { + out() << "<h2>" << protectEnc(section->title()) << "</h2>\n"; + generateSectionList(*section, aggregate, marker, Section::Obsolete); } - for (int i = 0; i < details_spv.size(); ++i) { - //out() << "<hr />\n"; - out() << "<h2>" << protectEnc(details_spv.at(i)->title()) << "</h2>\n"; + for (const auto §ion : details_spv) { + out() << "<h2>" << protectEnc(section->title()) << "</h2>\n"; - const NodeVector &members = details_spv.at(i)->obsoleteMembers(); - NodeVector::ConstIterator m = members.constBegin(); - while (m != members.constEnd()) { - if ((*m)->access() != Node::Private) - generateDetailedMember(*m, aggregate, marker); - ++m; + const NodeVector &members = section->obsoleteMembers(); + for (const auto &member : members) { + if (member->access() != Node::Private) + generateDetailedMember(member, aggregate, marker); } } @@ -2863,22 +2725,20 @@ QString HtmlGenerator::generateObsoleteQmlMembersFile(const Sections §ions, << "They are provided to keep old source code working. " << "We strongly advise against using them in new code.</p>\n"; - for (int i = 0; i < summary_spv.size(); ++i) { - QString ref = registerRef(summary_spv.at(i)->title().toLower()); + for (const auto §ion : summary_spv) { + QString ref = registerRef(section->title().toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n'; - out() << "<h2 id=\"" << ref << "\">" << protectEnc(summary_spv.at(i)->title()) << "</h2>\n"; - generateQmlSummary(summary_spv.at(i)->obsoleteMembers(), aggregate, marker); + out() << "<h2 id=\"" << ref << "\">" << protectEnc(section->title()) << "</h2>\n"; + generateQmlSummary(section->obsoleteMembers(), aggregate, marker); } - for (int i = 0; i < details_spv.size(); ++i) { - out() << "<h2>" << protectEnc(details_spv.at(i)->title()) << "</h2>\n"; - const NodeVector &members = details_spv.at(i)->obsoleteMembers(); - NodeVector::ConstIterator m = members.constBegin(); - while (m != members.constEnd()) { - generateDetailedQmlMember(*m, aggregate, marker); + for (const auto §ion : details_spv) { + out() << "<h2>" << protectEnc(section->title()) << "</h2>\n"; + const NodeVector &members = section->obsoleteMembers(); + for (const auto &member : members) { + generateDetailedQmlMember(member, aggregate, marker); out() << "<br/>\n"; - ++m; } } @@ -2893,12 +2753,10 @@ void HtmlGenerator::generateClassHierarchy(const Node *relative, NodeMap &classM return; NodeMap topLevel; - NodeMap::Iterator c = classMap.begin(); - while (c != classMap.end()) { - ClassNode *classe = static_cast<ClassNode *>(*c); + for (auto it = classMap.begin(); it != classMap.end(); ++it) { + ClassNode *classe = static_cast<ClassNode *>(*it); if (classe->baseClasses().isEmpty()) topLevel.insert(classe->name(), classe); - ++c; } QStack<NodeMap > stack; @@ -2939,7 +2797,7 @@ void HtmlGenerator::generateAnnotatedList(const Node *relative, CodeMarker *marker, const NodeMultiMap &nmm) { - if (nmm.isEmpty()) + if (nmm.isEmpty() || relative == nullptr) return; generateAnnotatedList(relative, marker, nmm.values()); } @@ -3051,8 +2909,7 @@ void HtmlGenerator::generateCompactList(ListType listType, QString paragraphName[NumParagraphs+1]; QSet<char> usedParagraphNames; - NodeMultiMap::ConstIterator c = nmm.constBegin(); - while (c != nmm.constEnd()) { + for (auto c = nmm.constBegin(); c != nmm.constEnd(); ++c) { QStringList pieces = c.key().split("::"); int idx = commonPrefixLen; if (idx > 0 && !pieces.last().startsWith(commonPrefix, Qt::CaseInsensitive)) @@ -3072,7 +2929,6 @@ void HtmlGenerator::generateCompactList(ListType listType, paragraphName[paragraphNr] = key[0].toUpper(); usedParagraphNames.insert(key[0].toLower().cell()); paragraph[paragraphNr].insert(last, c.value()); - ++c; } /* @@ -3217,26 +3073,22 @@ void HtmlGenerator::generateFunctionIndex(const Node *relative) out() << "<ul>\n"; NodeMapMap &funcIndex = qdb_->getFunctionIndex(); - QMap<QString, NodeMap >::ConstIterator f = funcIndex.constBegin(); - while (f != funcIndex.constEnd()) { + for (auto fnMap = funcIndex.constBegin(); fnMap != funcIndex.constEnd(); ++fnMap) { out() << "<li>"; - out() << protectEnc(f.key()) << ':'; + out() << protectEnc(fnMap.key()) << ':'; - currentLetter = f.key()[0].unicode(); + currentLetter = fnMap.key()[0].unicode(); while (islower(currentLetter) && currentLetter >= nextLetter) { out() << QString("<a name=\"%1\"></a>").arg(nextLetter); nextLetter++; } - NodeMap::ConstIterator s = (*f).constBegin(); - while (s != (*f).constEnd()) { + for (auto it = (*fnMap).constBegin(); it != (*fnMap).constEnd(); ++it) { out() << ' '; - generateFullName((*s)->parent(), relative, *s); - ++s; + generateFullName((*it)->parent(), relative, *it); } out() << "</li>"; out() << '\n'; - ++f; } out() << "</ul>\n"; } @@ -3247,7 +3099,6 @@ void HtmlGenerator::generateLegaleseList(const Node *relative, CodeMarker *marke QMap<Text, const Node *>::ConstIterator it = legaleseTexts.constBegin(); while (it != legaleseTexts.constEnd()) { Text text = it.key(); - //out() << "<hr />\n"; generateText(text, relative, marker); out() << "<ul>\n"; do { @@ -3331,7 +3182,7 @@ void HtmlGenerator::generateList(const Node *relative, CodeMarker *marker, const if (type != Node::NoType) { NodeList nodeList; qdb_->mergeCollections(type, cnm, relative); - const CollectionList collectionList = cnm.values(); + const auto collectionList = cnm.values(); nodeList.reserve(collectionList.size()); for (auto *collectionNode : collectionList) nodeList.append(collectionNode); @@ -3375,29 +3226,25 @@ void HtmlGenerator::generateSection(const NodeVector &nv, const Node *relative, } int i = 0; - NodeVector::ConstIterator m = nv.constBegin(); - while (m != nv.constEnd()) { - if ((*m)->access() == Node::Private) { - ++m; + for (const auto &member : nv) { + if (member->access() == Node::Private) continue; - } if (alignNames) { out() << "<tr><td class=\"memItemLeft rightAlign topAlign\"> "; } else { - if (twoColumn && i == (int) (nv.count() + 1) / 2) + if (twoColumn && i == (nv.count() + 1) / 2) out() << "</ul></td><td class=\"topAlign\"><ul>\n"; out() << "<li class=\"fn\">"; } - generateSynopsis(*m, relative, marker, Section::Summary, alignNames); + generateSynopsis(member, relative, marker, Section::Summary, alignNames); if (alignNames) out() << "</td></tr>\n"; else out() << "</li>\n"; i++; - ++m; } if (alignNames) out() << "</table></div>\n"; @@ -3438,18 +3285,15 @@ void HtmlGenerator::generateSectionList(const Section& section, } int i = 0; - NodeVector::ConstIterator m = members.constBegin(); - while (m != members.constEnd()) { - if ((*m)->access() == Node::Private) { - ++m; + for (const auto &member : members) { + if (member->access() == Node::Private) continue; - } if (alignNames) { out() << "<tr><td class=\"memItemLeft topAlign rightAlign\"> "; } else { - if (twoColumn && i == (int) (members.count() + 1) / 2) + if (twoColumn && i == (members.count() + 1) / 2) out() << "</ul></td><td class=\"topAlign\"><ul>\n"; out() << "<li class=\"fn\">"; } @@ -3460,9 +3304,9 @@ void HtmlGenerator::generateSectionList(const Section& section, prefix = keys.at(i).mid(1); prefix = prefix.left(keys.at(i).indexOf("::") + 1); } - generateSynopsis(*m, relative, marker, section.style(), alignNames, &prefix); - if ((*m)->isFunction()) { - const FunctionNode *fn = static_cast<const FunctionNode *>(*m); + generateSynopsis(member, relative, marker, section.style(), alignNames, &prefix); + if (member->isFunction()) { + const FunctionNode *fn = static_cast<const FunctionNode *>(member); if (fn->isPrivateSignal()) { hasPrivateSignals = true; if (alignNames) @@ -3479,7 +3323,6 @@ void HtmlGenerator::generateSectionList(const Section& section, else out() << "</li>\n"; i++; - ++m; } if (alignNames) out() << "</table></div>\n"; @@ -3503,25 +3346,23 @@ void HtmlGenerator::generateSectionList(const Section& section, void HtmlGenerator::generateSectionInheritedList(const Section& section, const Node *relative) { - QList<QPair<Aggregate *, int> >::ConstIterator p = section.inheritedMembers().constBegin(); - while (p != section.inheritedMembers().constEnd()) { + const QVector<QPair<Aggregate *, int>> &inheritedMembers = section.inheritedMembers(); + for (const auto &member : inheritedMembers) { out() << "<li class=\"fn\">"; - out() << (*p).second << ' '; - if ((*p).second == 1) { + out() << member.second << ' '; + if (member.second == 1) { out() << section.singular(); } else { out() << section.plural(); } - out() << " inherited from <a href=\"" << fileName((*p).first) + out() << " inherited from <a href=\"" << fileName(member.first) << '#' << Generator::cleanRef(section.title().toLower()) << "\">" - << protectEnc((*p).first->plainFullName(relative)) + << protectEnc(member.first->plainFullName(relative)) << "</a></li>\n"; - ++p; } } -// generateSynopsis(*m, relative, marker, Section::Summary, alignNames); void HtmlGenerator::generateSynopsis(const Node *node, const Node *relative, CodeMarker *marker, @@ -3745,23 +3586,6 @@ void HtmlGenerator::generateLink(const Atom *atom, CodeMarker *marker) } } -QString HtmlGenerator::registerRef(const QString &ref) -{ - QString clean = Generator::cleanRef(ref); - - for (;;) { - QString &prevRef = refMap[clean.toLower()]; - if (prevRef.isEmpty()) { - prevRef = ref; - break; - } else if (prevRef == ref) { - break; - } - clean += QLatin1Char('x'); - } - return clean; -} - QString HtmlGenerator::protectEnc(const QString &string) { #ifndef QT_NO_TEXTCODEC @@ -3829,199 +3653,6 @@ QString HtmlGenerator::fileName(const Node *node) return Generator::fileName(node); } -QString HtmlGenerator::refForNode(const Node *node) -{ - QString ref; - switch (node->nodeType()) { - case Node::Enum: - ref = node->name() + "-enum"; - break; - case Node::Typedef: - { - const TypedefNode *tdn = static_cast<const TypedefNode *>(node); - if (tdn->associatedEnum()) - return refForNode(tdn->associatedEnum()); - else - ref = node->name() + "-typedef"; - } - break; - case Node::Function: - { - const FunctionNode *fn = static_cast<const FunctionNode *>(node); - switch (fn->metaness()) { - case FunctionNode::JsSignal: - case FunctionNode::QmlSignal: - ref = fn->name() + "-signal"; - break; - case FunctionNode::JsSignalHandler: - case FunctionNode::QmlSignalHandler: - ref = fn->name() + "-signal-handler"; - break; - case FunctionNode::JsMethod: - case FunctionNode::QmlMethod: - ref = fn->name() + "-method"; - if (fn->overloadNumber() != 0) - ref += QLatin1Char('-') + QString::number(fn->overloadNumber()); - break; - default: - if (fn->hasOneAssociatedProperty() && fn->doc().isEmpty()) { - return refForNode(fn->firstAssociatedProperty()); - } else { - ref = fn->name(); - if (fn->overloadNumber() != 0) - ref += QLatin1Char('-') + QString::number(fn->overloadNumber()); - } - break; - } - } - break; - case Node::JsProperty: - case Node::QmlProperty: - if (node->isAttached()) - ref = node->name() + "-attached-prop"; - else - ref = node->name() + "-prop"; - break; - case Node::Property: - ref = node->name() + "-prop"; - break; - case Node::Variable: - ref = node->name() + "-var"; - break; - case Node::SharedComment: - if (node->isPropertyGroup()) - ref = node->name() + "-prop"; - break; - default: - break; - } - return registerRef(ref); -} - -/*! - This function is called for links, i.e. for words that - are marked with the qdoc link command. For autolinks - that are not marked with the qdoc link command, the - getAutoLink() function is called - - It returns the string for a link found by using the data - in the \a atom to search the database. It also sets \a node - to point to the target node for that link. \a relative points - to the node holding the qdoc comment where the link command - was found. - */ -QString HtmlGenerator::getLink(const Atom *atom, const Node *relative, const Node** node) -{ - const QString &t = atom->string(); - if (t.at(0) == QChar('h')) { - if (t.startsWith("http:") || t.startsWith("https:")) - return t; - } - else if (t.at(0) == QChar('f')) { - if (t.startsWith("file:") || t.startsWith("ftp:")) - return t; - } - else if (t.at(0) == QChar('m')) { - if (t.startsWith("mailto:")) - return t; - } - return getAutoLink(atom, relative, node); -} - -/*! - This function is called for autolinks, i.e. for words that - are not marked with the qdoc link command that qdoc has - reason to believe should be links. For links marked with - the qdoc link command, the getLink() function is called. - - It returns the string for a link found by using the data - in the \a atom to search the database. It also sets \a node - to point to the target node for that link. \a relative points - to the node holding the qdoc comment where the link command - was found. - */ -QString HtmlGenerator::getAutoLink(const Atom *atom, const Node *relative, const Node** node) -{ - QString ref; - - *node = qdb_->findNodeForAtom(atom, relative, ref); - if (!(*node)) { - return QString(); - } - - QString link = (*node)->url(); - if (link.isEmpty()) - link = linkForNode(*node, relative); - if (!ref.isEmpty()) { - int hashtag = link.lastIndexOf(QChar('#')); - if (hashtag != -1) - link.truncate(hashtag); - link += QLatin1Char('#') + ref; - } - return link; -} - -/*! - Construct the link string for the \a node and return it. - The \a relative node is use to decide the link we are - generating is in the same file as the target. Note the - relative node can be 0, which pretty much guarantees - that the link and the target aren't in the same file. - */ -QString HtmlGenerator::linkForNode(const Node *node, const Node *relative) -{ - if (node == nullptr) - return QString(); - if (!node->url().isEmpty()) - return node->url(); - if (fileBase(node).isEmpty()) - return QString(); - if (node->isPrivate()) - return QString(); - QString fn = fileName(node); - if (node && node->parent() && - (node->parent()->isQmlType() || node->parent()->isJsType()) - && node->parent()->isAbstract()) { - if (Generator::qmlTypeContext()) { - if (Generator::qmlTypeContext()->inherits(node->parent())) { - fn = fileName(Generator::qmlTypeContext()); - } - else if (node->parent()->isInternal()) { - node->doc().location().warning(tr("Cannot link to property in internal type '%1'").arg(node->parent()->name())); - return QString(); - } - } - } - QString link = fn; - - if (!node->isPageNode() || node->isPropertyGroup()) { - QString ref = refForNode(node); - if (relative && fn == fileName(relative) && ref == refForNode(relative)) - return QString(); - - link += QLatin1Char('#'); - link += ref; - } - /* - If the output is going to subdirectories, then if the - two nodes will be output to different directories, then - the link must go up to the parent directory and then - back down into the other subdirectory. - */ - if (node && relative && (node != relative)) { - if (useOutputSubdirs() && !node->isExternalPage() && - node->outputSubdirectory() != relative->outputSubdirectory()) { - if (link.startsWith(QString(node->outputSubdirectory() + QLatin1Char('/')))) { - link.prepend(QString("../")); - } - else { - link.prepend(QString("../" + node->outputSubdirectory() + QLatin1Char('/'))); - } - } - } - return link; -} - void HtmlGenerator::generateFullName(const Node *apparentNode, const Node *relative, const Node *actualNode) { if (actualNode == nullptr) @@ -4089,7 +3720,7 @@ void HtmlGenerator::generateDetailedMember(const Node *node, generateSince(node, marker); if (node->isProperty()) { - const PropertyNode *property = static_cast<const PropertyNode *>(node); + const auto property = static_cast<const PropertyNode *>(node); Section section(Section::Accessors, Section::Active); section.appendMembers(property->getters().toVector()); @@ -4106,7 +3737,6 @@ void HtmlGenerator::generateDetailedMember(const Node *node, if (!notifiers.members().isEmpty()) { out() << "<p><b>Notifier signal:</b></p>\n"; - //out() << "<p>This signal is emitted when the property value is changed.</p>\n"; generateSectionList(notifiers, node, marker); } } @@ -4134,53 +3764,6 @@ void HtmlGenerator::generateDetailedMember(const Node *node, generateExtractionMark(node, EndMark); } -int HtmlGenerator::hOffset(const Node *node) -{ - switch (node->nodeType()) { - case Node::Namespace: - case Node::Class: - case Node::Struct: - case Node::Union: - case Node::Module: - return 2; - case Node::QmlModule: - case Node::QmlBasicType: - case Node::QmlType: - case Node::Page: - return 1; - case Node::Enum: - case Node::Typedef: - case Node::Function: - case Node::Property: - default: - return 3; - } -} - -bool HtmlGenerator::isThreeColumnEnumValueTable(const Atom *atom) -{ - while (atom != nullptr && !(atom->type() == Atom::ListRight && atom->string() == ATOM_LIST_VALUE)) { - if (atom->type() == Atom::ListItemLeft && !matchAhead(atom, Atom::ListItemRight)) - return true; - atom = atom->next(); - } - return false; -} - - -const QPair<QString,QString> HtmlGenerator::anchorForNode(const Node *node) -{ - QPair<QString,QString> anchorPair; - - anchorPair.first = Generator::fileName(node); - if (node->isPageNode()) { - const PageNode *pn = static_cast<const PageNode *>(node); - anchorPair.second = pn->title(); - } - - return anchorPair; -} - #ifdef GENERATE_MAC_REFS /* No longer valid. @@ -4256,28 +3839,25 @@ void HtmlGenerator::generateQmlSummary(const NodeVector &members, { if (!members.isEmpty()) { out() << "<ul>\n"; - NodeVector::const_iterator m = members.constBegin(); - while (m != members.constEnd()) { + for (const auto &member : members) { out() << "<li class=\"fn\">"; - generateQmlItem(*m, relative, marker, true); - if ((*m)->isPropertyGroup()) { - const SharedCommentNode *scn = static_cast<const SharedCommentNode *>(*m); + generateQmlItem(member, relative, marker, true); + if (member->isPropertyGroup()) { + const SharedCommentNode *scn = static_cast<const SharedCommentNode *>(member); if (scn->count() > 0) { - QVector<Node *>::ConstIterator p = scn->collective().constBegin(); out() << "<ul>\n"; - while (p != scn->collective().constEnd()) { - if ((*p)->isQmlProperty() || (*p)->isJsProperty()) { + const QVector<Node *> sharedNodes = scn->collective(); + for (const auto &node : sharedNodes) { + if (node->isQmlProperty() || node->isJsProperty()) { out() << "<li class=\"fn\">"; - generateQmlItem(*p, relative, marker, true); + generateQmlItem(node, relative, marker, true); out() << "</li>\n"; } - ++p; } out() << "</ul>\n"; } } out() << "</li>\n"; - ++m; } out() << "</ul>\n"; } @@ -4311,7 +3891,6 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, QString nodeRef; if (node->isPropertyGroup()) { const SharedCommentNode *scn = static_cast<const SharedCommentNode*>(node); - QVector<Node *>::ConstIterator p = scn->collective().constBegin(); out() << "<div class=\"qmlproto\">"; out() << "<div class=\"table\"><table class=\"qmlname\">"; if (!scn->name().isEmpty()) { @@ -4323,9 +3902,10 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, out() << "<b>" << heading << "</b>"; out() << "</p></th></tr>"; } - while (p != scn->collective().constEnd()) { - if ((*p)->isQmlProperty() || (*p)->isJsProperty()) { - qpn = static_cast<QmlPropertyNode *>(*p); + const QVector<Node *> sharedNodes = scn->collective(); + for (const auto &node : sharedNodes) { + if (node->isQmlProperty() || node->isJsProperty()) { + qpn = static_cast<QmlPropertyNode *>(node); nodeRef = refForNode(qpn); out() << "<tr valign=\"top\" class=\"odd\" id=\"" << nodeRef << "\">"; out() << "<td class=\"tblQmlPropNode\"><p>"; @@ -4338,7 +3918,6 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, generateQmlItem(qpn, relative, marker, false); out() << "</p></td></tr>"; } - ++p; } out() << "</table></div>"; out() << "</div>"; @@ -4361,19 +3940,19 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, out() << qmlItemFooter; } else if (node->isSharedCommentNode()) { const SharedCommentNode *scn = reinterpret_cast<const SharedCommentNode *>(node); - const QVector<Node *> &collective = scn->collective(); - if (collective.size() > 1) + const QVector<Node *> &sharedNodes = scn->collective(); + if (sharedNodes.size() > 1) out() << "<div class=\"fngroup\">\n"; out() << qmlItemHeader; - for (const auto m : collective) { - if (m->isFunction(Node::QML) || m->isFunction(Node::JS)) { - out() << qmlItemStart.arg(nodeRef, "tblQmlFuncNode", refForNode(m)); - generateSynopsis(m, relative, marker, Section::Details, false); + for (const auto &node : sharedNodes) { + if (node->isFunction(Node::QML) || node->isFunction(Node::JS)) { + out() << qmlItemStart.arg(nodeRef, "tblQmlFuncNode", refForNode(node)); + generateSynopsis(node, relative, marker, Section::Details, false); out() << qmlItemEnd; } } out() << qmlItemFooter; - if (collective.size() > 1) + if (sharedNodes.size() > 1) out() << "</div>"; } else { // assume the node is a method/signal handler out() << qmlItemHeader; @@ -4550,9 +4129,8 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString demos = true; bool proceed = false; - ExampleNodeMap::Iterator i = exampleNodeMap.begin(); - while (i != exampleNodeMap.end()) { - const ExampleNode *en = i.value(); + for (auto map = exampleNodeMap.begin(); map != exampleNodeMap.end(); ++map) { + const ExampleNode *en = map.value(); if (demos) { if (en->name().startsWith("demos")) { proceed = true; @@ -4563,7 +4141,6 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString proceed = true; break; } - ++i; } if (!proceed || !file.open(QFile::WriteOnly | QFile::Text)) return; @@ -4576,17 +4153,12 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString writer.writeStartElement(manifest); QStringList usedAttributes; - i = exampleNodeMap.begin(); - while (i != exampleNodeMap.end()) { - const ExampleNode *en = i.value(); + for (auto map = exampleNodeMap.begin(); map != exampleNodeMap.end(); ++map) { + const ExampleNode *en = map.value(); if (demos) { - if (!en->name().startsWith("demos")) { - ++i; + if (!en->name().startsWith("demos")) continue; - } - } - else if (en->name().startsWith("demos")) { - ++i; + } else if (en->name().startsWith("demos")) { continue; } // attributes that are always written for the element @@ -4761,8 +4333,7 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString } } - QMap<int, QString>::const_iterator it = filesToOpen.constEnd(); - while (it != filesToOpen.constBegin()) { + for (auto it = filesToOpen.constEnd(); it != filesToOpen.constBegin(); ) { writer.writeStartElement("fileToOpen"); if (--it == filesToOpen.constBegin()) { writer.writeAttribute(QStringLiteral("mainFile"), QStringLiteral("true")); @@ -4772,7 +4343,6 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString } writer.writeEndElement(); // example - ++i; } writer.writeEndElement(); // examples |