diff options
Diffstat (limited to 'src/tools/qdoc/htmlgenerator.cpp')
-rw-r--r-- | src/tools/qdoc/htmlgenerator.cpp | 546 |
1 files changed, 286 insertions, 260 deletions
diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index 641e59f018..ceed09a7cf 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -264,16 +264,15 @@ QString HtmlGenerator::format() } /*! - Traverses the database generating all the HTML documentation. + Traverses the current tree generating all the HTML documentation. */ -void HtmlGenerator::generateTree() +void HtmlGenerator::generateDocs() { - qdb_->buildCollections(); Node* qflags = qdb_->findNodeByNameAndType(QStringList("QFlags"), Node::Class, Node::NoSubType); if (qflags) qflagsHref_ = linkForNode(qflags,0); if (!runPrepareOnly()) { - Generator::generateTree(); + Generator::generateDocs(); generateCollisionPages(); } @@ -303,10 +302,11 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark { int skipAhead = 0; static bool in_para = false; - +#if 0 if (Generator::debugging()) { atom->dump(); } +#endif switch (atom->type()) { case Atom::AbstractLeft: if (relative) @@ -320,6 +320,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark if (!inLink_ && !inContents_ && !inSectionHeading_) { const Node *node = 0; QString link = getLink(atom, relative, &node); + QDocDatabase::debug = false; if (!link.isEmpty()) { beginLink(link, node, relative); generateLink(atom, marker); @@ -327,6 +328,8 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark } else { out() << protectEnc(atom->string()); + if (autolinkErrors()) + relative->doc().location().warning(tr("Can't autolink to '%1'").arg(atom->string())); } } else { @@ -485,9 +488,9 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark break; case Atom::AnnotatedList: { - DocNode* dn = qdb_->getGroup(atom->string()); - if (dn) - generateAnnotatedList(relative, marker, dn->members()); + GroupNode* gn = qdb_->getGroup(atom->string()); + if (gn) + generateList(gn, marker, atom->string()); } break; case Atom::GeneratedList: @@ -504,10 +507,10 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark QString arg = atom->string().trimmed(); QString moduleName = atom->string().mid(atom->string().indexOf("classesbymodule") + 15).trimmed(); QDocDatabase* qdb = QDocDatabase::qdocDB(); - DocNode* dn = qdb->findModule(moduleName); - if (dn) { + ModuleNode* mn = qdb->findModule(moduleName); + if (mn) { NodeMap m; - dn->getMemberClasses(m); + mn->getMemberClasses(m); if (!m.isEmpty()) { generateAnnotatedList(relative, marker, m); } @@ -550,16 +553,25 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark generateCompactList(Generic, relative, qdb_->getServiceClasses(), false, QStringLiteral("Q")); } else if (atom->string() == "overviews") { - generateOverviewList(relative); + generateList(relative, marker, "overviews"); + } + else if (atom->string() == "cpp-modules") { + generateList(relative, marker, "cpp-modules"); + } + else if (atom->string() == "qml-modules") { + generateList(relative, marker, "qml-modules"); } else if (atom->string() == "namespaces") { generateAnnotatedList(relative, marker, qdb_->getNamespaces()); } else if (atom->string() == "related") { - const DocNode *dn = static_cast<const DocNode *>(relative); - if (dn) - generateAnnotatedList(dn, marker, dn->members()); + generateList(relative, marker, "related"); } +#if 0 + /* + This is not used in Qt5, as of 10/02/2014 + Remove permanently if it is not missed. + */ else if (atom->string() == "relatedinline") { const DocNode *dn = static_cast<const DocNode *>(relative); if (dn && !dn->members().isEmpty()) { @@ -573,6 +585,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark generateBody(node, marker); } } +#endif break; case Atom::SinceList: { @@ -1341,7 +1354,6 @@ void HtmlGenerator::generateCollisionPages() if (collisions.size() <= 1) continue; - ncn->clearCurrentChild(); beginSubPage(ncn, Generator::fileName(ncn)); QString fullTitle = ncn->fullTitle(); QString htmlTitle = fullTitle; @@ -1374,7 +1386,7 @@ void HtmlGenerator::generateCollisionPages() int count = 0; for (int i=0; i<collisions.size(); ++i) { InnerNode* n = static_cast<InnerNode*>(collisions.at(i)); - if (n->findChildNodeByName(t.key())) { + if (n->findChildNode(t.key())) { ++count; if (count > 1) { targets.append(t.key()); @@ -1393,7 +1405,7 @@ void HtmlGenerator::generateCollisionPages() out() << "<ul>\n"; for (int i=0; i<collisions.size(); ++i) { InnerNode* n = static_cast<InnerNode*>(collisions.at(i)); - Node* p = n->findChildNodeByName(*t); + Node* p = n->findChildNode(*t); if (p) { QString link = linkForNode(p,0); QString label; @@ -1470,29 +1482,7 @@ void HtmlGenerator::generateDocNode(DocNode* dn, CodeMarker* marker) dn, marker); - if (dn->subType() == Node::Module) { - // Generate brief text and status for modules. - generateBrief(dn, marker); - generateStatus(dn, marker); - generateSince(dn, marker); - - NodeMap nm; - dn->getMemberNamespaces(nm); - if (!nm.isEmpty()) { - out() << "<a name=\"" << registerRef("namespaces") << "\"></a>" << divNavTop << '\n'; - out() << "<h2>Namespaces</h2>\n"; - generateAnnotatedList(dn, marker, nm); - } - nm.clear(); - dn->getMemberClasses(nm); - if (!nm.isEmpty()) { - out() << "<a name=\"" << registerRef("classes") << "\"></a>" << divNavTop << '\n'; - out() << "<h2>Classes</h2>\n"; - generateAnnotatedList(dn, marker, nm); - } - nm.clear(); - } - else if (dn->subType() == Node::HeaderFile) { + if (dn->subType() == Node::HeaderFile) { // Generate brief text and status for modules. generateBrief(dn, marker); generateStatus(dn, marker); @@ -1523,7 +1513,6 @@ void HtmlGenerator::generateDocNode(DocNode* dn, CodeMarker* marker) out() << "</ul>\n"; } else if (dn->subType() == Node::QmlClass) { - const_cast<DocNode*>(dn)->setCurrentChild(); ClassNode* cn = qml_cn->classNode(); generateBrief(qml_cn, marker); generateQmlRequisites(qml_cn, marker); @@ -1568,7 +1557,6 @@ void HtmlGenerator::generateDocNode(DocNode* dn, CodeMarker* marker) ++s; } generateFooter(dn); - const_cast<DocNode*>(dn)->clearCurrentChild(); return; } @@ -1581,29 +1569,100 @@ void HtmlGenerator::generateDocNode(DocNode* dn, CodeMarker* marker) ++s; } - Text brief = dn->doc().briefText(); - if (dn->subType() == Node::Module && !brief.isEmpty()) { - generateExtractionMark(dn, DetailedDescriptionMark); + generateExtractionMark(dn, DetailedDescriptionMark); + out() << "<div class=\"descr\"> <a name=\"" << registerRef("details") << "\"></a>\n"; // QTBUG-9504 + + generateBody(dn, marker); + out() << "</div>\n"; // QTBUG-9504 + generateAlsoList(dn, marker); + generateExtractionMark(dn, EndMark); + + sections = marker->sections(dn, CodeMarker::Detailed, CodeMarker::Okay); + s = sections.constBegin(); + while (s != sections.constEnd()) { + //out() << "<hr />\n"; + out() << "<h2>" << protectEnc((*s).name) << "</h2>\n"; + + NodeList::ConstIterator m = (*s).members.constBegin(); + while (m != (*s).members.constEnd()) { + generateDetailedMember(*m, dn, marker); + ++m; + } + ++s; + } + generateFooter(dn); +} + +/*! + Generate the HTML page for a group, module, or QML module. + */ +void HtmlGenerator::generateCollectionNode(CollectionNode* cn, CodeMarker* marker) +{ + SubTitleSize subTitleSize = LargeSubTitle; + QList<Section> sections; + QList<Section>::const_iterator s; + QString fullTitle = cn->fullTitle(); + QString htmlTitle = fullTitle; + + generateHeader(htmlTitle, cn, marker); + generateTableOfContents(cn,marker,0); + generateTitle(fullTitle, Text() << cn->subTitle(), subTitleSize, cn, marker); + + if (cn->isModule()) { + // Generate brief text and status for modules. + generateBrief(cn, marker); + generateStatus(cn, marker); + generateSince(cn, marker); + + NodeMap nm; + cn->getMemberNamespaces(nm); + if (!nm.isEmpty()) { + out() << "<a name=\"" << registerRef("namespaces") << "\"></a>" << divNavTop << '\n'; + out() << "<h2>Namespaces</h2>\n"; + generateAnnotatedList(cn, marker, nm); + } + nm.clear(); + cn->getMemberClasses(nm); + if (!nm.isEmpty()) { + out() << "<a name=\"" << registerRef("classes") << "\"></a>" << divNavTop << '\n'; + out() << "<h2>Classes</h2>\n"; + generateAnnotatedList(cn, marker, nm); + } + nm.clear(); + } + + sections = marker->sections(cn, CodeMarker::Summary, CodeMarker::Okay); + s = sections.constBegin(); + while (s != sections.constEnd()) { + out() << "<a name=\"" << registerRef((*s).name) << "\"></a>" << divNavTop << '\n'; + out() << "<h2>" << protectEnc((*s).name) << "</h2>\n"; + generateSectionList(*s, cn, marker, CodeMarker::Summary); + ++s; + } + + Text brief = cn->doc().briefText(); + if (cn->isModule() && !brief.isEmpty()) { + generateExtractionMark(cn, DetailedDescriptionMark); out() << "<a name=\"" << registerRef("details") << "\"></a>" << divNavTop << '\n'; out() << "<div class=\"descr\">\n"; // QTBUG-9504 out() << "<h2>" << "Detailed Description" << "</h2>\n"; } else { - generateExtractionMark(dn, DetailedDescriptionMark); + generateExtractionMark(cn, DetailedDescriptionMark); out() << "<div class=\"descr\"> <a name=\"" << registerRef("details") << "\"></a>\n"; // QTBUG-9504 } - generateBody(dn, marker); + generateBody(cn, marker); out() << "</div>\n"; // QTBUG-9504 - generateAlsoList(dn, marker); - generateExtractionMark(dn, EndMark); + generateAlsoList(cn, marker); + generateExtractionMark(cn, EndMark); - if ((dn->subType() == Node::Group)) - generateAnnotatedList(dn, marker, dn->members()); - else if (dn->subType() == Node::QmlModule) - generateAnnotatedList(dn, marker, dn->members()); + if (cn->isGroup()) + generateAnnotatedList(cn, marker, cn->members()); + else if (cn->isQmlModule()) + generateAnnotatedList(cn, marker, cn->members()); - sections = marker->sections(dn, CodeMarker::Detailed, CodeMarker::Okay); + sections = marker->sections(cn, CodeMarker::Detailed, CodeMarker::Okay); s = sections.constBegin(); while (s != sections.constEnd()) { //out() << "<hr />\n"; @@ -1611,12 +1670,12 @@ void HtmlGenerator::generateDocNode(DocNode* dn, CodeMarker* marker) NodeList::ConstIterator m = (*s).members.constBegin(); while (m != (*s).members.constEnd()) { - generateDetailedMember(*m, dn, marker); + generateDetailedMember(*m, cn, marker); ++m; } ++s; } - generateFooter(dn); + generateFooter(cn); } /*! @@ -1892,7 +1951,7 @@ void HtmlGenerator::generateRequisites(InnerNode *inner, CodeMarker *marker) if (inner->type() == Node::Class || inner->type() == Node::Namespace) { //add the QT variable to the map if (!inner->moduleName().isEmpty()) { - DocNode * moduleNode = qdb_->findModule(inner->moduleName()); + ModuleNode* moduleNode = qdb_->findModule(inner->moduleName()); if (moduleNode && !moduleNode->qtVariable().isEmpty()) { text.clear(); text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_TELETYPE) @@ -1923,18 +1982,20 @@ void HtmlGenerator::generateRequisites(InnerNode *inner, CodeMarker *marker) r = classe->baseClasses().constBegin(); index = 0; while (r != classe->baseClasses().constEnd()) { - text << Atom(Atom::LinkNode, CodeMarker::stringForNode((*r).node)) - << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK) - << Atom(Atom::String, (*r).dataTypeWithTemplateArgs) - << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); - - if ((*r).access == Node::Protected) { - text << " (protected)"; - } - else if ((*r).access == Node::Private) { - text << " (private)"; + if ((*r).node_) { + text << Atom(Atom::LinkNode, CodeMarker::stringForNode((*r).node_)) + << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK) + << Atom(Atom::String, (*r).signature_) + << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); + + if ((*r).access_ == Node::Protected) { + text << " (protected)"; + } + else if ((*r).access_ == Node::Private) { + text << " (private)"; + } + text << separator(index++, classe->baseClasses().count()); } - text << separator(index++, classe->baseClasses().count()); ++r; } text << Atom::ParaRight; @@ -2002,9 +2063,9 @@ void HtmlGenerator::generateQmlRequisites(QmlClassNode *qcn, CodeMarker *marker) //add the module name and version to the map QString qmlModuleVersion; - DocNode* dn = qdb_->findQmlModule(qcn->qmlModuleName()); - if (dn) - qmlModuleVersion = dn->qmlModuleVersion(); + QmlModuleNode* qmn = qdb_->findQmlModule(qcn->qmlModuleName()); + if (qmn) + qmlModuleVersion = qmn->qmlModuleVersion(); else qmlModuleVersion = qcn->qmlModuleVersion(); text.clear(); @@ -2044,7 +2105,7 @@ void HtmlGenerator::generateQmlRequisites(QmlClassNode *qcn, CodeMarker *marker) } //add the inherits to the map - const QmlClassNode* base = qcn->qmlBaseNode(); + QmlClassNode* base = qcn->qmlBaseNode(); while (base && base->isInternal()) { base = base->qmlBaseNode(); } @@ -2136,7 +2197,7 @@ void HtmlGenerator::generateTableOfContents(const Node *node, QList<Atom*> toc; if (node->doc().hasTableOfContents()) toc = node->doc().tableOfContents(); - if (toc.isEmpty() && !sections && (node->subType() != Node::Module)) + if (toc.isEmpty() && !sections && !node->isModule()) return; QStringList sectionNumber; @@ -2151,7 +2212,7 @@ void HtmlGenerator::generateTableOfContents(const Node *node, sectionNumber.append("1"); out() << "<ul>\n"; - if (node->subType() == Node::Module) { + if (node->isModule()) { if (node->hasNamespaces()) { out() << "<li class=\"level" << sectionNumber.size() @@ -2178,9 +2239,7 @@ void HtmlGenerator::generateTableOfContents(const Node *node, } } } - else if (sections && ((node->type() == Node::Class) || - (node->type() == Node::Namespace) || - (node->subType() == Node::QmlClass))) { + else if (sections && (node->isClass() || node->isNamespace() || node->isQmlType())) { QList<Section>::ConstIterator s = sections->constBegin(); while (s != sections->constEnd()) { if (!s->members.isEmpty() || !s->reimpMembers.isEmpty()) { @@ -2278,8 +2337,7 @@ QString HtmlGenerator::generateListOfAllMemberFile(const InnerNode *inner, the members of QML class \a qml_cn, including the inherited members. The \a marker is used for formatting stuff. */ -QString HtmlGenerator::generateAllQmlMembersFile(const QmlClassNode* qml_cn, - CodeMarker* marker) +QString HtmlGenerator::generateAllQmlMembersFile(QmlClassNode* qml_cn, CodeMarker* marker) { QList<Section> sections; QList<Section>::ConstIterator s; @@ -2448,8 +2506,8 @@ void HtmlGenerator::generateClassHierarchy(const Node *relative, NodeMap& classM NodeMap newTop; foreach (const RelatedClass &d, child->derivedClasses()) { - if (d.access != Node::Private && !d.node->doc().isEmpty()) - newTop.insert(d.node->name(), d.node); + if (d.node_ && !d.isPrivate() && !d.node_->isInternal() && d.node_->hasDoc()) + newTop.insert(d.node_->name(), d.node_); } if (!newTop.isEmpty()) { stack.push(newTop); @@ -2469,33 +2527,29 @@ void HtmlGenerator::generateAnnotatedList(const Node* relative, { if (nodeMap.isEmpty()) return; - NodeList nl; - NodeMap::const_iterator i = nodeMap.begin(); - while (i != nodeMap.end()) { - nl.append(i.value()); - ++i; - } - generateAnnotatedList(relative, marker, nl); + generateAnnotatedList(relative, marker, nodeMap.values()); } +/*! + */ void HtmlGenerator::generateAnnotatedList(const Node *relative, CodeMarker *marker, - const NodeList& nodes) + const NodeList& unsortedNodes) { + NodeMap nm; bool allInternal = true; - foreach (const Node* node, nodes) { - if (!node->isInternal() && node->status() != Node::Obsolete) { + foreach (Node* node, unsortedNodes) { + if (!node->isInternal() && !node->isObsolete()) { allInternal = false; + nm.insert(node->fullName(relative), node); } } if (allInternal) return; out() << "<table class=\"annotated\">\n"; int row = 0; + NodeList nodes = nm.values(); foreach (const Node* node, nodes) { - if (node->isInternal() || node->status() == Node::Obsolete) - continue; - if (++row % 2 == 1) out() << "<tr class=\"odd topAlign\">"; else @@ -2504,7 +2558,7 @@ void HtmlGenerator::generateAnnotatedList(const Node *relative, generateFullName(node, relative); out() << "</p></td>"; - if (!(node->type() == Node::Document)) { + if (!node->isDocNode()) { Text brief = node->doc().trimmedBriefText(node->name()); if (!brief.isEmpty()) { out() << "<td class=\"tblDescr\"><p>"; @@ -2786,117 +2840,105 @@ void HtmlGenerator::generateQmlItem(const Node *node, marked.remove("<@type>"); marked.remove("</@type>"); } - out() << highlightedCode(marked, relative, false, node); + out() << highlightedCode(marked, relative, false); } -void HtmlGenerator::generateOverviewList(const Node *relative) +void HtmlGenerator::generateList(const Node* relative, CodeMarker* marker, const QString& selector) { - QMap<const DocNode *, QMap<QString, DocNode *> > docNodeMap; - QMap<QString, const DocNode *> groupTitlesMap; - QMap<QString, DocNode *> uncategorizedNodeMap; + NodeList nl; + CollectionList cl; QRegExp singleDigit("\\b([0-9])\\b"); - const NodeList children = qdb_->treeRoot()->childNodes(); - foreach (Node *child, children) { - if (child->type() == Node::Document && child != relative) { - DocNode *docNode = static_cast<DocNode *>(child); - - // Check whether the page is part of a group or is the group - // definition page. - QString group; - bool isGroupPage = false; - if (docNode->doc().metaCommandsUsed().contains("group")) { - group = docNode->doc().metaCommandArgs("group")[0].first; - isGroupPage = true; - } - - // there are too many examples; they would clutter the list - if (docNode->subType() == Node::Example) - continue; - - // not interested either in individual (Qt Designer etc.) manual chapters - if (docNode->links().contains(Node::ContentsLink)) - continue; - - // Discard external nodes. - if (docNode->subType() == Node::ExternalPage) - continue; - - QString sortKey = docNode->fullTitle().toLower(); - if (sortKey.startsWith("the ")) - sortKey.remove(0, 4); - sortKey.replace(singleDigit, "0\\1"); - - if (!group.isEmpty()) { - if (isGroupPage) { - // If we encounter a group definition page, we add all - // the pages in that group to the list for that group. - foreach (Node *member, docNode->members()) { - if (member->isInternal() || member->type() != Node::Document) - continue; - DocNode *page = static_cast<DocNode *>(member); - if (page) { - QString sortKey = page->fullTitle().toLower(); - if (sortKey.startsWith("the ")) - sortKey.remove(0, 4); - sortKey.replace(singleDigit, "0\\1"); - docNodeMap[const_cast<const DocNode *>(docNode)].insert(sortKey, page); - groupTitlesMap[docNode->fullTitle()] = const_cast<const DocNode *>(docNode); - } - } - } - else if (!isGroupPage) { - // If we encounter a page that belongs to a group then - // we add that page to the list for that group. - const DocNode* gn = qdb_->getGroup(group); - if (gn && !docNode->isInternal()) - docNodeMap[gn].insert(sortKey, docNode); - } - } + if (selector == "overviews") { + CNMap groups; + qdb_->mergeCollections(Node::Group, groups, relative); + cl = groups.values(); + foreach (CollectionNode* cn, cl) + nl.append(cn); + generateAnnotatedList(relative, marker, nl); + } + else if (selector == "cpp-modules") { + CNMap modules; + qdb_->mergeCollections(Node::Module, modules, relative); + cl = modules.values(); + foreach (CollectionNode* cn, cl) + nl.append(cn); + generateAnnotatedList(relative, marker, nl); + } + else if (selector == "qml-modules") { + CNMap qmlModules; + qdb_->mergeCollections(Node::QmlModule, qmlModules, relative); + cl = qmlModules.values(); + foreach (CollectionNode* cn, cl) + nl.append(cn); + generateAnnotatedList(relative, marker, nl); + } + else { + /* + \generatelist {selector} is only allowed in a + comment where the topic is \group, \module, or + \qmlmodule. + */ + if (!relative || !relative->isCollectionNode()) { + relative->doc().location().warning(tr("\\generatelist {%1} is only allowed in \\group, \\module, and \\qmlmodule comments.").arg(selector)); + return; + } + if (selector == "related") { + Node* n = const_cast<Node*>(relative); + CollectionNode* cn = static_cast<CollectionNode*>(n); + qdb_->mergeCollections(cn); + generateAnnotatedList(cn, marker, cn->members()); + } + else { + Node* n = const_cast<Node*>(relative); + CollectionNode* cn = static_cast<CollectionNode*>(n); + qdb_->mergeCollections(cn); + generateAnnotatedList(cn, marker, cn->members()); } } - // We now list all the pages found that belong to groups. - // If only certain pages were found for a group, but the definition page - // for that group wasn't listed, the list of pages will be intentionally - // incomplete. However, if the group definition page was listed, all the - // pages in that group are listed for completeness. - - if (!docNodeMap.isEmpty()) { - foreach (const QString &groupTitle, groupTitlesMap.keys()) { - const DocNode *groupNode = groupTitlesMap[groupTitle]; +#if 0 + QStringList keys = groups.uniqueKeys(); + foreach (QString key, keys) { + GroupNode* gn = static_cast<GroupNode*>(groups.value(key)); + if (gn) { out() << QString("<h3><a href=\"%1\">%2</a></h3>\n").arg( - linkForNode(groupNode, relative)).arg( - protectEnc(groupNode->fullTitle())); - - if (docNodeMap[groupNode].count() == 0) + linkForNode(gn, relative)).arg( + protectEnc(gn->fullTitle())); +#if 0 + if (gn->members().isEmpty()) continue; - out() << "<ul>\n"; + NodeMap nm; + foreach (Node* member, gn->members()) { + if (member->isInternal() || member->isExample() || member->isExternalPage() || + member->isObsolete()) + continue; + // not interested either in individual (Qt Designer etc.) manual chapters + if (member->links().contains(Node::ContentsLink)) + continue; + QString sortKey = member->fullTitle().toLower(); + if (sortKey.startsWith("the ")) + sortKey.remove(0, 4); + sortKey.replace(singleDigit, "0\\1"); + nm.insert(sortKey, member); + } - foreach (const DocNode *docNode, docNodeMap[groupNode]) { - QString title = docNode->fullTitle(); + out() << "<ul>\n"; + QStringList titles = nm.keys(); + foreach (QString t, titles) { + Node* member = nm.value(t); + QString title = member->fullTitle(); if (title.startsWith("The ")) title.remove(0, 4); - out() << "<li><a href=\"" << linkForNode(docNode, relative) << "\">" + out() << "<li><a href=\"" << linkForNode(member, relative) << "\">" << protectEnc(title) << "</a></li>\n"; } out() << "</ul>\n"; +#endif } } - - if (!uncategorizedNodeMap.isEmpty()) { - out() << QString("<h3>Miscellaneous</h3>\n"); - out() << "<ul>\n"; - foreach (const DocNode *docNode, uncategorizedNodeMap) { - QString title = docNode->fullTitle(); - if (title.startsWith("The ")) - title.remove(0, 4); - out() << "<li><a href=\"" << linkForNode(docNode, relative) << "\">" - << protectEnc(title) << "</a></li>\n"; - } - out() << "</ul>\n"; - } +#endif } void HtmlGenerator::generateSection(const NodeList& nl, @@ -3099,8 +3141,7 @@ void HtmlGenerator::generateSynopsis(const Node *node, QString HtmlGenerator::highlightedCode(const QString& markedCode, const Node* relative, - bool alignNames, - const Node* self) + bool alignNames) { QString src = markedCode; QString html; @@ -3148,8 +3189,7 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, if (src.at(i) == charLangle && src.at(i + 1) == charAt) { i += 2; if (parseArg(src, funcTag, &i, srcSize, &arg, &par1)) { - - const Node* n = qdb_->resolveTarget(par1.toString(), relative); + const Node* n = qdb_->resolveFunctionTarget(par1.toString(), relative); QString link = linkForNode(n, relative); addLink(link, arg, &html); par1 = QStringRef(); @@ -3164,7 +3204,7 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, } } - // replace all "(<@(type|headerfile|func)(?: +[^>]*)?>)(.*)(</@\\2>)" tags + // replace all "(<@(type|headerfile)(?: +[^>]*)?>)(.*)(</@\\2>)" tags src = html; html = QString(); @@ -3174,7 +3214,7 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, bool handled = false; if (parseArg(src, typeTag, &i, srcSize, &arg, &par1)) { par1 = QStringRef(); - const Node* n = qdb_->resolveTarget(arg.toString(), relative, self); + const Node* n = qdb_->resolveType(arg.toString(), relative); html += QLatin1String("<span class=\"type\">"); if (n && n->subType() == Node::QmlBasicType) { if (relative && relative->subType() == Node::QmlClass) @@ -3189,17 +3229,18 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, } else if (parseArg(src, headerTag, &i, srcSize, &arg, &par1)) { par1 = QStringRef(); - const Node* n = qdb_->resolveTarget(arg.toString(), relative); - addLink(linkForNode(n,relative), arg, &html); - handled = true; - } - else if (parseArg(src, funcTag, &i, srcSize, &arg, &par1)) { - par1 = QStringRef(); - const Node* n = qdb_->resolveTarget(arg.toString(), relative); - addLink(linkForNode(n,relative), arg, &html); + if (arg.at(0) == QChar('&')) + html += arg.toString(); + else { + // zzz resolveClassTarget() + const Node* n = qdb_->resolveTarget(arg.toString(), relative); + if (n) + addLink(linkForNode(n,relative), arg, &html); + else + html += arg.toString(); + } handled = true; } - if (!handled) { html += charLangle; html += charAt; @@ -3721,45 +3762,35 @@ QString HtmlGenerator::getLink(const Atom *atom, const Node *relative, const Nod *node = 0; inObsoleteLink = false; - if (atom->string().contains(QLatin1Char(':')) && - (atom->string().startsWith("file:") - || atom->string().startsWith("http:") - || atom->string().startsWith("https:") - || atom->string().startsWith("ftp:") - || atom->string().startsWith("mailto:"))) { - - link = atom->string(); + if (atom->string().contains(QLatin1Char(':')) && (atom->string().startsWith("file:") || + atom->string().startsWith("http:") || + atom->string().startsWith("https:") || + atom->string().startsWith("ftp:") || + atom->string().startsWith("mailto:"))) { + link = atom->string(); // It's some kind of protocol. } else { QStringList path; - if (atom->string().contains('#')) { - path = atom->string().split('#'); - } - else { - path.append(atom->string()); - } + if (atom->string().contains('#')) + path = atom->string().split('#'); // The target is in the html file. + else + path.append(atom->string()); // It's a general case target. QString ref; QString first = path.first().trimmed(); - if (first.isEmpty()) { + if (first.isEmpty()) *node = relative; - } - else if (first.endsWith(".html")) { - /* - This is not a recursive search. That's ok in - this case, because we are searching for a page - node, which must be a direct child of the tree - root. - */ - *node = qdb_->treeRoot()->findChildNodeByNameAndType(first, Node::Document); + else if (first.endsWith(".html")) // The target is an html file. + *node = qdb_->findNodeByNameAndType(QStringList(first), Node::Document, Node::NoSubType); + else if (first.endsWith("()")) { // The target is a C++ function or QML method. + *node = qdb_->resolveFunctionTarget(first, relative); } else { *node = qdb_->resolveTarget(first, relative); - if (!*node) { - *node = qdb_->findDocNodeByTitle(first, relative); - } - if (!*node) { - *node = qdb_->findUnambiguousTarget(first, ref, relative); + if (!(*node)) + *node = qdb_->findDocNodeByTitle(first); + if (!(*node)) { + *node = qdb_->findUnambiguousTarget(first, ref); if (*node && !(*node)->url().isEmpty() && !ref.isEmpty()) { QString final = (*node)->url() + "#" + ref; return final; @@ -3767,16 +3798,13 @@ QString HtmlGenerator::getLink(const Atom *atom, const Node *relative, const Nod } } if (*node) { - if (!(*node)->url().isEmpty()) { + if (!(*node)->url().isEmpty()) return (*node)->url(); - } - else { + else path.removeFirst(); - } } - else { + else *node = relative; - } if (*node) { if ((*node)->status() == Node::Obsolete) { @@ -3801,10 +3829,8 @@ QString HtmlGenerator::getLink(const Atom *atom, const Node *relative, const Nod } } } - else { - qDebug() << "Link to Obsolete entity" - << (*node)->name() << "no relative"; - } + else + qDebug() << "Link to Obsolete entity" << (*node)->name() << "no relative"; } } @@ -3832,9 +3858,8 @@ QString HtmlGenerator::getLink(const Atom *atom, const Node *relative, const Nod link = linkForNode(*node, relative); if (*node && (*node)->subType() == Node::Image) link = "images/used-in-examples/" + link; - if (!ref.isEmpty()) { + if (!ref.isEmpty()) link += QLatin1Char('#') + ref; - } } } return link; @@ -4018,7 +4043,7 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, out() << "<td class=\"tblQmlPropNode\"><p>"; out() << "<a name=\"" + refForNode(qpn) + "\"></a>"; - if (!qpn->isWritable(qdb_)) + if (!qpn->isWritable()) out() << "<span class=\"qmlreadonly\">read-only</span>"; if (qpn->isDefault()) out() << "<span class=\"qmldefault\">default</span>"; @@ -4039,7 +4064,7 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, out() << "<a name=\"" + refForNode(qpn) + "\"></a>"; if (!qpn->isReadOnlySet()) { if (qpn->declarativeCppNode()) - qpn->setReadOnly(!qpn->isWritable(qdb_)); + qpn->setReadOnly(!qpn->isWritable()); } if (qpn->isReadOnly()) out() << "<span class=\"qmlreadonly\">read-only</span>"; @@ -4101,11 +4126,11 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, Output the "Inherits" line for the QML element, if there should be one. */ -void HtmlGenerator::generateQmlInherits(const QmlClassNode* qcn, CodeMarker* marker) +void HtmlGenerator::generateQmlInherits(QmlClassNode* qcn, CodeMarker* marker) { if (!qcn) return; - const QmlClassNode* base = qcn->qmlBaseNode(); + QmlClassNode* base = qcn->qmlBaseNode(); while (base && base->isInternal()) { base = base->qmlBaseNode(); } @@ -4229,7 +4254,7 @@ void HtmlGenerator::generateManifestFiles() { generateManifestFile("examples", "example"); generateManifestFile("demos", "demo"); - ExampleNode::exampleNodeMap.clear(); + qdb_->exampleNodeMap().clear(); manifestMetaContent.clear(); } @@ -4240,7 +4265,8 @@ void HtmlGenerator::generateManifestFiles() */ void HtmlGenerator::generateManifestFile(QString manifest, QString element) { - if (ExampleNode::exampleNodeMap.isEmpty()) + ExampleNodeMap& exampleNodeMap = qdb_->exampleNodeMap(); + if (exampleNodeMap.isEmpty()) return; QString fileName = manifest +"-manifest.xml"; QFile file(outputDir() + QLatin1Char('/') + fileName); @@ -4251,8 +4277,8 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element) demos = true; bool proceed = false; - ExampleNodeMap::Iterator i = ExampleNode::exampleNodeMap.begin(); - while (i != ExampleNode::exampleNodeMap.end()) { + ExampleNodeMap::Iterator i = exampleNodeMap.begin(); + while (i != exampleNodeMap.end()) { const ExampleNode* en = i.value(); if (demos) { if (en->name().startsWith("demos")) { @@ -4276,8 +4302,8 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element) writer.writeAttribute("module", project); writer.writeStartElement(manifest); - i = ExampleNode::exampleNodeMap.begin(); - while (i != ExampleNode::exampleNodeMap.end()) { + i = exampleNodeMap.begin(); + while (i != exampleNodeMap.end()) { const ExampleNode* en = i.value(); if (demos) { if (!en->name().startsWith("demos")) { @@ -4501,6 +4527,12 @@ void HtmlGenerator::reportOrphans(const InnerNode* parent) break; case Node::Class: break; + case Node::Group: + break; + case Node::Module: + break; + case Node::QmlModule: + break; case Node::Document: switch (child->subType()) { case Node::Example: @@ -4511,10 +4543,6 @@ void HtmlGenerator::reportOrphans(const InnerNode* parent) break; case Node::Image: break; - case Node::Group: - break; - case Node::Module: - break; case Node::Page: break; case Node::ExternalPage: @@ -4523,8 +4551,6 @@ void HtmlGenerator::reportOrphans(const InnerNode* parent) break; case Node::QmlBasicType: break; - case Node::QmlModule: - break; case Node::Collision: break; default: |