diff options
-rw-r--r-- | doc/src/qt4-intro.qdoc | 5 | ||||
-rw-r--r-- | tools/qdoc3/codemarker.h | 2 | ||||
-rw-r--r-- | tools/qdoc3/cppcodeparser.cpp | 6 | ||||
-rw-r--r-- | tools/qdoc3/htmlgenerator.cpp | 380 | ||||
-rw-r--r-- | tools/qdoc3/htmlgenerator.h | 59 | ||||
-rw-r--r-- | tools/qdoc3/node.cpp | 106 | ||||
-rw-r--r-- | tools/qdoc3/node.h | 22 |
7 files changed, 433 insertions, 147 deletions
diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index 6224cd4..38f346f 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -661,10 +661,9 @@ See the \l{QtMultimedia Module} documentation for more information. - \section1 Classes, functions, and other items introduced in 4.6 + \section1 Classes, functions, etc new in 4.6 - Links to classes, function, and other items that were added in - 4.6. + Links to classes, functions, and other items that are new in 4.6. \sincelist 4.6 diff --git a/tools/qdoc3/codemarker.h b/tools/qdoc3/codemarker.h index e400f8a..9858484 100644 --- a/tools/qdoc3/codemarker.h +++ b/tools/qdoc3/codemarker.h @@ -71,6 +71,8 @@ struct Section : name(name0), singularMember(singularMember0), pluralMember(pluralMember0) { } + void appendMember(Node* node) { members.append(node); } + void appendReimpMember(Node* node) { reimpMembers.append(node); } }; struct FastSection diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index ec5ce96..d93e24c 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -541,9 +541,10 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc, else { lastPath = parentPath; } - - if (func) + if (func) { func->borrowParameterNames(clone); + func->setParentPath(clone->parentPath()); + } delete clone; } return func; @@ -1371,6 +1372,7 @@ bool CppCodeParser::matchFunctionDecl(InnerNode *parent, func->setAccess(access); func->setLocation(location()); func->setReturnType(returnType.toString()); + func->setParentPath(parentPath); func->setTemplateStuff(templateStuff); if (compat) func->setStatus(Node::Compat); diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 291f60b..e883dfa 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -59,6 +59,24 @@ QT_BEGIN_NAMESPACE #define COMMAND_VERSION Doc::alias("version") +QString HtmlGenerator::sinceTitles[] = + { + " New Namespaces", + " New Classes", + " New Member Functions", + " New Functions in Namespaces", + " New Global Functions", + " New Macros", + " New Enum Types", + " New Typedefs", + " New Properties", + " New Variables", + " New Qml Properties", + " New Qml Signals", + " New Qml Methods", + "" + }; + static bool showBrokenLinks = false; static QRegExp linkTag("(<@link node=\"([^\"]+)\">).*(</@link>)"); @@ -186,7 +204,7 @@ HtmlGenerator::HtmlGenerator() : helpProjectWriter(0), inLink(false), inContents(false), inSectionHeading(false), inTableHeader(false), numTableRows(0), threeColumnEnumValueTable(true), funcLeftParen("\\S(\\()"), - tre(0), slow(false), obsoleteLinks(false) + myTree(0), slow(false), obsoleteLinks(false) { } @@ -313,7 +331,7 @@ void HtmlGenerator::generateTree(const Tree *tree, CodeMarker *marker) ++styleIter; } - tre = tree; + myTree = tree; nonCompatClasses.clear(); mainClasses.clear(); compatClasses.clear(); @@ -433,7 +451,7 @@ void HtmlGenerator::generateTree(const Tree *tree, CodeMarker *marker) projectUrl, projectDescription); - helpProjectWriter->generate(tre); + helpProjectWriter->generate(myTree); } void HtmlGenerator::startText(const Node * /* relative */, @@ -598,13 +616,12 @@ int HtmlGenerator::generateAtom(const Atom *atom, break; case Atom::AnnotatedList: { - QList<Node*> values = tre->groups().values(atom->string()); - QMap<QString, const Node*> nodeMap; + QList<Node*> values = myTree->groups().values(atom->string()); + NodeMap nodeMap; for (int i = 0; i < values.size(); ++i) { const Node* n = values.at(i); if ((n->status() != Node::Internal) && (n->access() != Node::Private)) { nodeMap.insert(n->nameForLists(),n); - //qDebug() << " " << n->nameForLists(); } } generateAnnotatedList(relative, marker, nodeMap); @@ -633,7 +650,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, if (editionModuleMap.contains(editionName)) { // Add all classes in the modules listed for that edition. - QMap<QString, const Node *> editionClasses; + NodeMap editionClasses; foreach (const QString &moduleName, editionModuleMap[editionName]) { if (moduleClassMap.contains(moduleName)) editionClasses.unite(moduleClassMap[moduleName]); @@ -642,7 +659,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, // Add additional groups and remove groups of classes that // should be excluded from the edition. - QMultiMap <QString, Node *> groups = tre->groups(); + QMultiMap <QString, Node *> groups = myTree->groups(); foreach (const QString &groupName, editionGroupMap[editionName]) { QList<Node *> groupClasses; if (groupName.startsWith("-")) { @@ -689,7 +706,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, else if (atom->string() == "related") { const FakeNode *fake = static_cast<const FakeNode *>(relative); if (fake && !fake->groupMembers().isEmpty()) { - QMap<QString, const Node *> groupMembersMap; + NodeMap groupMembersMap; foreach (const Node *node, fake->groupMembers()) { if (node->type() == Node::Fake) groupMembersMap[fullName(node, relative, marker)] = node; @@ -713,18 +730,125 @@ int HtmlGenerator::generateAtom(const Atom *atom, break; case Atom::SinceList: { - QList<Node*> nodes; - SinceVersionMap::const_iterator v; - v = sinceVersions.find(atom->string()); - if ((v != sinceVersions.constEnd()) && !v.value().isEmpty()) { + NodeMultiMapMap::const_iterator v; + v = nodeMultiMapMap.find(atom->string()); + NodeMapMap::const_iterator nc; + nc = nodeMapMap.find(atom->string()); + if ((v != nodeMultiMapMap.constEnd()) && !v.value().isEmpty()) { + QList<Section> sections; + QList<Section>::ConstIterator s; + for (int i=0; i<LastSinceType; ++i) + sections.append(Section(sinceTitle(i),QString(),QString())); + + NodeMultiMap::const_iterator n = v.value().constBegin(); + while (n != v.value().constEnd()) { + const Node* node = n.value(); + switch (node->type()) { + case Node::Namespace: + sections[Namespace].appendMember((Node*)node); + break; + case Node::Class: + sections[Class].appendMember((Node*)node); + break; + case Node::Enum: + sections[Enum].appendMember((Node*)node); + break; + case Node::Typedef: + sections[Typedef].appendMember((Node*)node); + break; + case Node::Function: + const FunctionNode* fn = static_cast<const FunctionNode*>(node); + if (fn->isMacro()) + sections[Macro].appendMember((Node*)node); + else { + Node* p = fn->parent(); + if (p) { + if (p->type() == Node::Class) + sections[MemberFunction].appendMember((Node*)node); + else if (p->type() == Node::Namespace) { + if (p->name().isEmpty()) + sections[GlobalFunction].appendMember((Node*)node); + else + sections[NamespaceFunction].appendMember((Node*)node); + } + else + sections[GlobalFunction].appendMember((Node*)node); + } + else + sections[GlobalFunction].appendMember((Node*)node); + } + break; + case Node::Property: + sections[Property].appendMember((Node*)node); + break; + case Node::Variable: + sections[Variable].appendMember((Node*)node); + break; + case Node::QmlProperty: + sections[QmlProperty].appendMember((Node*)node); + break; + case Node::QmlSignal: + sections[QmlSignal].appendMember((Node*)node); + break; + case Node::QmlMethod: + sections[QmlMethod].appendMember((Node*)node); + break; + default: + break; + } + ++n; + } + int idx = 0; + s = sections.constBegin(); + while (s != sections.constEnd()) { + if (!(*s).members.isEmpty()) { + out() << "<a name=\"" + << registerRef((*s).name.toLower()) + << "\"></a>\n"; + out() << "<h3>" << protect((*s).name) << "</h3>\n"; + if (idx == Class) + generateCompactList(0, marker, nc.value(), QString("Q")); + else if (idx == MemberFunction) { + NodeMultiMapMap nodemultimapmap; + NodeMultiMapMap::iterator nmmap; + NodeList::const_iterator i = s->members.constBegin(); + while (i != s->members.constEnd()) { + Node* p = (*i)->parent(); + nmmap = nodemultimapmap.find(p->name()); + if (nmmap == nodemultimapmap.end()) + nmmap = nodemultimapmap.insert(p->name(),NodeMultiMap()); + nmmap->insert((*i)->name(),(*i)); + ++i; + } + nmmap = nodemultimapmap.begin(); + while (nmmap != nodemultimapmap.end()) { + NodeList nlist = nmmap->values(); + out() << "<p>New functions in " << protect(nmmap.key()) << ":</p>\n"; + generateSection(nlist, 0, marker, CodeMarker::Summary); + out() << "<br />"; + ++nmmap; + } + } + else + generateSection(s->members, 0, marker, CodeMarker::Summary); + } + ++idx; + ++s; + } +#if 0 for (int i=0; !Node::typeName(i).isEmpty(); i++) { Node::Type t = (Node::Type) i; SinceNodeMultiMap::const_iterator n=v.value().constBegin(); QMultiMap<QString, const Node*> nodeMap; while (n != v.value().constEnd()) { const Node* node = n.value(); - if (node->type() == t) + if (node->type() == t) { nodeMap.insert(node->nameForLists(),node); + if (node->type() == Node::Function) { + const FunctionNode* fn = static_cast<const FunctionNode*>(node); + qDebug() << "SIGNATURE:" << fn->signature(); + } + } ++n; } if (!nodeMap.isEmpty()) { @@ -737,10 +861,11 @@ int HtmlGenerator::generateAtom(const Atom *atom, nodeMap.clear(); } } +#endif } } break; -case Atom::Image: + case Atom::Image: case Atom::InlineImage: { QString fileName = imageFileName(relative, atom->string()); @@ -1151,7 +1276,7 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, subtitleText << "[" << Atom(Atom::AutoLink, fixedModule) << " module]"; if (fixedModule.isEmpty()) { - QMultiMap<QString, QString> publicGroups = tre->publicGroups(); + QMultiMap<QString, QString> publicGroups = myTree->publicGroups(); QList<QString> groupNames = publicGroups.values(inner->name()); if (!groupNames.isEmpty()) { qSort(groupNames.begin(), groupNames.end()); @@ -1492,7 +1617,7 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) generateAlsoList(fake, marker); if (!fake->groupMembers().isEmpty()) { - QMap<QString, const Node *> groupMembersMap; + NodeMap groupMembersMap; foreach (const Node *node, fake->groupMembers()) { if (node->type() == Node::Class || node->type() == Node::Namespace) groupMembersMap[node->name()] = node; @@ -1564,7 +1689,7 @@ void HtmlGenerator::generateHeader(const QString& title, if (node && !node->doc().location().isEmpty()) out() << "<!-- " << node->doc().location().fileName() << " -->\n"; - shortVersion = tre->version(); + shortVersion = myTree->version(); if (shortVersion.count(QChar('.')) == 2) shortVersion.truncate(shortVersion.lastIndexOf(QChar('.'))); if (!shortVersion.isEmpty()) { @@ -1686,7 +1811,7 @@ void HtmlGenerator::generateHeader(const QString& title, "<body>\n"; if (mainPage) generateMacRef(node, marker); - out() << QString(postHeader).replace("\\" + COMMAND_VERSION, tre->version()); + out() << QString(postHeader).replace("\\" + COMMAND_VERSION, myTree->version()); if (node && !node->links().empty()) @@ -1717,8 +1842,8 @@ void HtmlGenerator::generateFooter(const Node *node) if (node && !node->links().empty()) out() << "<p>\n" << navigationLinks << "</p>\n"; - out() << QString(footer).replace("\\" + COMMAND_VERSION, tre->version()) - << QString(address).replace("\\" + COMMAND_VERSION, tre->version()) + out() << QString(footer).replace("\\" + COMMAND_VERSION, myTree->version()) + << QString(address).replace("\\" + COMMAND_VERSION, myTree->version()) << "</body>\n" "</html>\n"; } @@ -1970,8 +2095,8 @@ void HtmlGenerator::generateClassHierarchy(const Node *relative, if (classMap.isEmpty()) return; - QMap<QString, const Node *> topLevel; - QMap<QString, const Node *>::ConstIterator c = classMap.begin(); + NodeMap topLevel; + NodeMap::ConstIterator c = classMap.begin(); while (c != classMap.end()) { const ClassNode *classe = static_cast<const ClassNode *>(*c); if (classe->baseClasses().isEmpty()) @@ -1979,7 +2104,7 @@ void HtmlGenerator::generateClassHierarchy(const Node *relative, ++c; } - QStack<QMap<QString, const Node *> > stack; + QStack<NodeMap > stack; stack.push(topLevel); out() << "<ul>\n"; @@ -1996,7 +2121,7 @@ void HtmlGenerator::generateClassHierarchy(const Node *relative, out() << "</li>\n"; stack.top().erase(stack.top().begin()); - QMap<QString, const Node *> newTop; + NodeMap newTop; foreach (const RelatedClass &d, child->derivedClasses()) { if (d.access != Node::Private) newTop.insert(d.node->name(), d.node); @@ -2011,7 +2136,7 @@ void HtmlGenerator::generateClassHierarchy(const Node *relative, void HtmlGenerator::generateAnnotatedList(const Node *relative, CodeMarker *marker, - const QMap<QString, const Node *> &nodeMap) + const NodeMap &nodeMap) { out() << "<p><table width=\"100%\" class=\"annotated\" cellpadding=\"2\" " << "cellspacing=\"1\" border=\"0\">\n"; @@ -2049,9 +2174,19 @@ void HtmlGenerator::generateAnnotatedList(const Node *relative, out() << "</table></p>\n"; } +/*! + This function finds the common prefix of the names of all + the classes in \a classMap and then generates a compact + list of the class names alphabetized on the part of the + name not including the common prefix. You can tell the + function to use \a comonPrefix as the common prefix, but + normally you let it figure it out itself by looking at + the name of the first and last classes in \a classMap. + */ void HtmlGenerator::generateCompactList(const Node *relative, CodeMarker *marker, - const QMap<QString, const Node *> &classMap) + const NodeMap &classMap, + QString commonPrefix) { const int NumParagraphs = 37; // '0' to '9', 'A' to 'Z', '_' const int NumColumns = 4; // number of columns in the result @@ -2060,67 +2195,78 @@ void HtmlGenerator::generateCompactList(const Node *relative, return; /* - First, find out the common prefix of all non-namespaced classes. - For Qt, the prefix is Q. It can easily be derived from the first - and last classes in alphabetical order (QAccel and QXtWidget in Qt 2.1). - */ - int commonPrefixLen = 0; - QString commonPrefix; - QString first; - QString last; - - QMap<QString, const Node *>::const_iterator iter = classMap.begin(); - while (iter != classMap.end()) { - if (!iter.key().contains("::")) { - first = iter.key(); - break; + If commonPrefix is not empty, then the caller knows what + the common prefix is, so just use that. + */ + int commonPrefixLen = commonPrefix.length(); + if (commonPrefixLen == 0) { + QString first; + QString last; + + /* + First, find out the common prefix of all non-namespaced + classes. For Qt, the prefix is Q. It can easily be derived + from the first and last classes in alphabetical order + (QAccel and QXtWidget in Qt 2.1). + */ + + NodeMap::const_iterator iter = classMap.begin(); + while (iter != classMap.end()) { + if (!iter.key().contains("::")) { + first = iter.key(); + break; + } + ++iter; } - ++iter; - } - if (first.isEmpty()) - first = classMap.begin().key(); + if (first.isEmpty()) + first = classMap.begin().key(); - iter = classMap.end(); - while (iter != classMap.begin()) { - --iter; - if (!iter.key().contains("::")) { - last = iter.key(); - break; + iter = classMap.end(); + while (iter != classMap.begin()) { + --iter; + if (!iter.key().contains("::")) { + last = iter.key(); + break; + } } - } - if (last.isEmpty()) - last = classMap.begin().key(); + if (last.isEmpty()) + last = classMap.begin().key(); - if (classMap.size() > 1) { - while (commonPrefixLen < first.length() + 1 && - commonPrefixLen < last.length() + 1 && - first[commonPrefixLen] == last[commonPrefixLen]) - ++commonPrefixLen; - } + if (classMap.size() > 1) { + while (commonPrefixLen < first.length() + 1 && + commonPrefixLen < last.length() + 1 && + first[commonPrefixLen] == last[commonPrefixLen]) + ++commonPrefixLen; + } - commonPrefix = first.left(commonPrefixLen); + commonPrefix = first.left(commonPrefixLen); + } /* Divide the data into 37 paragraphs: 0, ..., 9, A, ..., Z, underscore (_). QAccel will fall in paragraph 10 (A) and QXtWidget in paragraph 33 (X). This is the only place where we assume that NumParagraphs is 37. Each paragraph is a - QMap<QString, const Node *>. + NodeMap. */ - QMap<QString, const Node *> paragraph[NumParagraphs+1]; + NodeMap paragraph[NumParagraphs+1]; QString paragraphName[NumParagraphs+1]; - QMap<QString, const Node *>::ConstIterator c = classMap.begin(); + qDebug() << "START COMPACT LIST"; + NodeMap::ConstIterator c = classMap.begin(); while (c != classMap.end()) { QStringList pieces = c.key().split("::"); QString key; + int idx = commonPrefixLen; + if (!pieces.last().startsWith(commonPrefix)) + idx = 0; if (pieces.size() == 1) - key = pieces.last().mid(commonPrefixLen).toLower(); + key = pieces.last().mid(idx).toLower(); else key = pieces.last().toLower(); - + qDebug() << " KEY:" << key; int paragraphNo = NumParagraphs - 1; if (key[0].digitValue() != -1) { @@ -2134,6 +2280,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, paragraph[paragraphNo].insert(key, c.value()); ++c; } + qDebug() << "END COMPACT LIST"; /* Each paragraph j has a size: paragraph[j].count(). In the @@ -2206,7 +2353,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, if ((currentParagraphNo[i] < NumParagraphs) && !paragraphName[currentParagraphNo[i]].isEmpty()) { - QMap<QString, const Node *>::Iterator it; + NodeMap::Iterator it; it = paragraph[currentParagraphNo[i]].begin(); for (j = 0; j < currentOffsetInParagraph[i]; j++) ++it; @@ -2253,7 +2400,7 @@ void HtmlGenerator::generateFunctionIndex(const Node *relative, #if 1 out() << "<ul>\n"; #endif - QMap<QString, QMap<QString, const Node *> >::ConstIterator f = funcIndex.begin(); + QMap<QString, NodeMap >::ConstIterator f = funcIndex.begin(); while (f != funcIndex.end()) { #if 1 out() << "<li>"; @@ -2268,7 +2415,7 @@ void HtmlGenerator::generateFunctionIndex(const Node *relative, nextLetter++; } - QMap<QString, const Node *>::ConstIterator s = (*f).begin(); + NodeMap::ConstIterator s = (*f).begin(); while (s != (*f).end()) { out() << " "; generateFullName((*s)->parent(), relative, marker, *s); @@ -2384,7 +2531,7 @@ void HtmlGenerator::generateOverviewList(const Node *relative, CodeMarker * /* m QMap<QString, FakeNode *> uncategorizedNodeMap; QRegExp singleDigit("\\b([0-9])\\b"); - const NodeList children = tre->root()->childNodes(); + const NodeList children = myTree->root()->childNodes(); foreach (Node *child, children) { if (child->type() == Node::Fake && child != relative) { FakeNode *fakeNode = static_cast<FakeNode *>(child); @@ -2436,7 +2583,7 @@ void HtmlGenerator::generateOverviewList(const Node *relative, CodeMarker * /* m 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 FakeNode *groupNode = static_cast<const FakeNode *>(tre->root()->findNode(group, Node::Fake)); + const FakeNode *groupNode = static_cast<const FakeNode *>(myTree->root()->findNode(group, Node::Fake)); if (groupNode) fakeNodeMap[groupNode].insert(sortKey, fakeNode); //else @@ -2748,7 +2895,7 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, if (parseArg(src, funcTag, &i, n, &arg, &par1)) { QString link = linkForNode( marker->resolveTarget(par1.toString(), - tre, + myTree, relative), relative); addLink(link, arg, &html); @@ -2777,7 +2924,7 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, if (parseArg(src, typeTags[k], &i, n, &arg, &par1)) { par1 = QStringRef(); QString link = linkForNode( - marker->resolveTarget(arg.toString(), tre, relative), + marker->resolveTarget(arg.toString(), myTree, relative), relative); addLink(link, arg, &html); handled = true; @@ -3018,7 +3165,7 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, if (parseArg(src, funcTag, &i, n, &arg, &par1)) { QString link = linkForNode( marker->resolveTarget(par1.toString(), - tre, + myTree, relative), relative); addLink(link, arg, &html); @@ -3047,7 +3194,7 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, if (parseArg(src, typeTags[k], &i, n, &arg, &par1)) { par1 = QStringRef(); QString link = linkForNode( - marker->resolveTarget(arg.toString(), tre, relative), + marker->resolveTarget(arg.toString(), myTree, relative), relative); addLink(link, arg, &html); handled = true; @@ -3591,15 +3738,44 @@ void HtmlGenerator::findAllSince(const InnerNode *node) while (c != node->childNodes().constEnd()) { QString sinceVersion = (*c)->since(); if (((*c)->access() != Node::Private) && !sinceVersion.isEmpty()) { - SinceVersionMap::iterator vmap = sinceVersions.find(sinceVersion); - if (vmap == sinceVersions.end()) - vmap = sinceVersions.insert(sinceVersion,SinceNodeMultiMap()); + NodeMultiMapMap::iterator vmap = nodeMultiMapMap.find(sinceVersion); + if (vmap == nodeMultiMapMap.end()) + vmap = nodeMultiMapMap.insert(sinceVersion,NodeMultiMap()); + NodeMapMap::iterator ncmap = nodeMapMap.find(sinceVersion); + if (ncmap == nodeMapMap.end()) + ncmap = nodeMapMap.insert(sinceVersion,NodeMap()); + if ((*c)->type() == Node::Function) { FunctionNode *func = static_cast<FunctionNode *>(*c); if ((func->status() > Node::Obsolete) && (func->metaness() != FunctionNode::Ctor) && (func->metaness() != FunctionNode::Dtor)) { vmap.value().insert(func->name(),(*c)); +#if 0 + qDebug() << "FUNCTION:" << func->name(); + Node* p = func->parent(); + if (p) { + if (p->type() == Node::Namespace) { + if (p->name().isEmpty()) + qDebug() << " Global namespace"; + else + qDebug() << " Namespace:" << p->name(); + } + else if (p->type() == Node::Class) + qDebug() << " Class:" << p->name(); + Node* q = p->parent(); + if (q) { + if (q->type() == Node::Namespace) { + if (q->name().isEmpty()) + qDebug() << " Grandparent Global namespace"; + else + qDebug() << " Grandparent Namespace:" << q->name(); + } + else if (q->type() == Node::Class) + qDebug() << " Grandparent Class:" << q->name(); + } + } +#endif } } else if ((*c)->url().isEmpty()) { @@ -3610,6 +3786,7 @@ void HtmlGenerator::findAllSince(const InnerNode *node) !(*c)->parent()->name().isEmpty()) className = (*c)->parent()->name()+"::"+className; vmap.value().insert(className,(*c)); + ncmap.value().insert(className,(*c)); } } else { @@ -3619,7 +3796,6 @@ void HtmlGenerator::findAllSince(const InnerNode *node) !(*c)->parent()->name().isEmpty()) name = (*c)->parent()->name()+"::"+name; vmap.value().insert(name,(*c)); - qDebug() << "GOT HEAH" << name; } if ((*c)->isInnerNode()) { findAllSince(static_cast<InnerNode *>(*c)); @@ -3646,9 +3822,10 @@ void HtmlGenerator::findAllFunctions(const InnerNode *node) } else if ((*c)->type() == Node::Function) { const FunctionNode *func = static_cast<const FunctionNode *>(*c); - if (func->status() > Node::Obsolete && func->metaness() != FunctionNode::Ctor - && func->metaness() != FunctionNode::Dtor) { - funcIndex[(*c)->name()].insert(tre->fullDocumentName((*c)->parent()), *c); + if ((func->status() > Node::Obsolete) && + (func->metaness() != FunctionNode::Ctor) && + (func->metaness() != FunctionNode::Dtor)) { + funcIndex[(*c)->name()].insert(myTree->fullDocumentName((*c)->parent()), *c); } } } @@ -3762,14 +3939,14 @@ const Node *HtmlGenerator::findNodeForTarget(const QString &target, node = relative; } else if (target.endsWith(".html")) { - node = tre->root()->findNode(target, Node::Fake); + node = myTree->root()->findNode(target, Node::Fake); } else if (marker) { - node = marker->resolveTarget(target, tre, relative); + node = marker->resolveTarget(target, myTree, relative); if (!node) - node = tre->findFakeNodeByTitle(target); + node = myTree->findFakeNodeByTitle(target); if (!node && atom) { - node = tre->findUnambiguousTarget(target, + node = myTree->findUnambiguousTarget(target, *const_cast<Atom**>(&atom)); } } @@ -3827,14 +4004,14 @@ QString HtmlGenerator::getLink(const Atom *atom, *node = relative; } else if (first.endsWith(".html")) { - *node = tre->root()->findNode(first, Node::Fake); + *node = myTree->root()->findNode(first, Node::Fake); } else { - *node = marker->resolveTarget(first, tre, relative); + *node = marker->resolveTarget(first, myTree, relative); if (!*node) - *node = tre->findFakeNodeByTitle(first); + *node = myTree->findFakeNodeByTitle(first); if (!*node) - *node = tre->findUnambiguousTarget(first, targetAtom); + *node = myTree->findUnambiguousTarget(first, targetAtom); } if (*node) { @@ -3886,7 +4063,7 @@ QString HtmlGenerator::getLink(const Atom *atom, } while (!path.isEmpty()) { - targetAtom = tre->findTarget(path.first(), *node); + targetAtom = myTree->findTarget(path.first(), *node); if (targetAtom == 0) break; path.removeFirst(); @@ -3915,7 +4092,7 @@ void HtmlGenerator::generateIndex(const QString &fileBase, const QString &url, const QString &title) { - tre->generateIndex(outputDir() + "/" + fileBase + ".index", url, title); + myTree->generateIndex(outputDir() + "/" + fileBase + ".index", url, title); } void HtmlGenerator::generateStatus(const Node *node, CodeMarker *marker) @@ -3930,18 +4107,21 @@ void HtmlGenerator::generateStatus(const Node *node, CodeMarker *marker) case Node::Compat: if (node->isInnerNode()) { text << Atom::ParaLeft - << Atom(Atom::FormattingLeft,ATOM_FORMATTING_BOLD) << "This " - << typeString(node) << " is part of the Qt 3 support library." + << Atom(Atom::FormattingLeft,ATOM_FORMATTING_BOLD) + << "This " + << typeString(node) + << " is part of the Qt 3 support library." << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD) - << " It is provided to keep old source code working. We strongly advise against " + << " It is provided to keep old source code working. " + << "We strongly advise against " << "using it in new code. See "; - const FakeNode *fakeNode = tre->findFakeNodeByTitle("Porting To Qt 4"); + const FakeNode *fakeNode = myTree->findFakeNodeByTitle("Porting To Qt 4"); Atom *targetAtom = 0; if (fakeNode && node->type() == Node::Class) { QString oldName(node->name()); - targetAtom = tre->findTarget(oldName.replace("3", ""), - fakeNode); + targetAtom = myTree->findTarget(oldName.replace("3", ""), + fakeNode); } if (targetAtom) { @@ -4151,7 +4331,7 @@ void HtmlGenerator::generateQmlInherits(const QmlClassNode* cn, QPair<QString,QString> linkPair; linkPair = cn->links()[Node::InheritsLink]; QStringList strList(linkPair.first); - const Node* n = tre->findNode(strList,Node::Fake); + const Node* n = myTree->findNode(strList,Node::Fake); if (n && n->subType() == Node::QmlClass) { const QmlClassNode* qcn = static_cast<const QmlClassNode*>(n); out() << "<p style=\"text-align: center\">"; @@ -4210,7 +4390,7 @@ void HtmlGenerator::generateInstantiatedBy(const ClassNode* cn, CodeMarker* marker) { if (cn && cn->status() != Node::Internal && !cn->qmlElement().isEmpty()) { - const Node* n = tre->root()->findNode(cn->qmlElement(),Node::Fake); + const Node* n = myTree->root()->findNode(cn->qmlElement(),Node::Fake); if (n && n->subType() == Node::QmlClass) { out() << "<p style=\"text-align: center\">"; Text text; diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index 3f6e564..fabfed1 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -67,14 +67,34 @@ struct NavigationBar }; #endif -typedef QMultiMap<QString, Node*> SinceNodeMultiMap; -typedef QMap<QString, SinceNodeMultiMap> SinceVersionMap; +typedef QMultiMap<QString, Node*> NodeMultiMap; +typedef QMap<QString, NodeMultiMap> NodeMultiMapMap; +typedef QMap<QString, const Node*> NodeMap; +typedef QMap<QString, NodeMap> NodeMapMap; class HelpProjectWriter; class HtmlGenerator : public PageGenerator { public: + enum SinceType { + Namespace, + Class, + MemberFunction, + NamespaceFunction, + GlobalFunction, + Macro, + Enum, + Typedef, + Property, + Variable, + QmlProperty, + QmlSignal, + QmlMethod, + LastSinceType + }; + + public: HtmlGenerator(); ~HtmlGenerator(); @@ -85,6 +105,7 @@ class HtmlGenerator : public PageGenerator static QString protect(const QString& string); static QString cleanRef(const QString& ref); + static QString sinceTitle(int i) { return sinceTitles[i]; } protected: virtual void startText(const Node *relative, CodeMarker *marker); @@ -134,13 +155,14 @@ class HtmlGenerator : public PageGenerator CodeMarker::Status status); void generateClassHierarchy(const Node *relative, CodeMarker *marker, - const QMap<QString,const Node *> &classMap); + const NodeMap &classMap); void generateAnnotatedList(const Node *relative, CodeMarker *marker, - const QMap<QString, const Node *> &nodeMap); + const NodeMap &nodeMap); void generateCompactList(const Node *relative, CodeMarker *marker, - const QMap<QString, const Node *> &classMap); + const NodeMap &classMap, + QString commonPrefix = QString()); void generateFunctionIndex(const Node *relative, CodeMarker *marker); void generateLegaleseList(const Node *relative, CodeMarker *marker); void generateOverviewList(const Node *relative, CodeMarker *marker); @@ -273,23 +295,25 @@ class HtmlGenerator : public PageGenerator QString navigationLinks; QStringList stylesheets; QStringList customHeadElements; - const Tree *tre; + const Tree *myTree; bool slow; bool obsoleteLinks; - QMap<QString, QMap<QString, const Node *> > moduleClassMap; - QMap<QString, QMap<QString, const Node *> > moduleNamespaceMap; - QMap<QString, const Node *> nonCompatClasses; - QMap<QString, const Node *> mainClasses; - QMap<QString, const Node *> compatClasses; - QMap<QString, const Node *> obsoleteClasses; - QMap<QString, const Node *> namespaceIndex; - QMap<QString, const Node *> serviceClasses; + QMap<QString, NodeMap > moduleClassMap; + QMap<QString, NodeMap > moduleNamespaceMap; + NodeMap nonCompatClasses; + NodeMap mainClasses; + NodeMap compatClasses; + NodeMap obsoleteClasses; + NodeMap namespaceIndex; + NodeMap serviceClasses; #ifdef QDOC_QML - QMap<QString, const Node *> qmlClasses; + NodeMap qmlClasses; #endif - QMap<QString, QMap<QString, const Node *> > funcIndex; + QMap<QString, NodeMap > funcIndex; QMap<Text, const Node *> legaleseTexts; - SinceVersionMap sinceVersions; + NodeMultiMapMap nodeMultiMapMap; + static QString sinceTitles[]; + NodeMapMap nodeMapMap; }; #define HTMLGENERATOR_ADDRESS "address" @@ -303,3 +327,4 @@ class HtmlGenerator : public PageGenerator QT_END_NAMESPACE #endif + diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index d547d20..558808f 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -48,29 +48,17 @@ QT_BEGIN_NAMESPACE -QString Node::typeNames[] = - { - "Namespaces", - "Classes", - "Fake", - "Enums", - "Typedefs", - "Functions and Macros", - "Properties", - "Variables", - "Targets", - "Qml Properties", - "Qml Signals", - "Qml Methods", - "" - }; - /*! \class Node - \brief A node in a Tree. + \brief The Node class is a node in the Tree. + + A Node represents a class or function or something else + from the source code.. */ /*! + When this Node is destroyed, if it has a parent Node, it + removes itself from the parent node's child list. */ Node::~Node() { @@ -81,6 +69,11 @@ Node::~Node() } /*! + Sets this Node's Doc to \a doc. If \a replace is false and + this Node already has a Doc, a warning is reported that the + Doc is being overridden, and it reports where the previous + Doc was found. If \a replace is true, the Doc is replaced + silently. */ void Node::setDoc(const Doc& doc, bool replace) { @@ -840,9 +833,17 @@ void TypedefNode::setAssociatedEnum(const EnumNode *enume) /*! \class Parameter + \brief The class Parameter contains one parameter. + + A parameter can be a function parameter or a macro + parameter. */ /*! + Constructs this parameter from the left and right types + \a leftType and rightType, the parameter \a name, and the + \a defaultValue. In practice, \a rightType is not used, + and I don't know what is was meant for. */ Parameter::Parameter(const QString& leftType, const QString& rightType, @@ -853,6 +854,7 @@ Parameter::Parameter(const QString& leftType, } /*! + The standard copy constructor copies the strings from \a p. */ Parameter::Parameter(const Parameter& p) : lef(p.lef), rig(p.rig), nam(p.nam), def(p.def) @@ -860,6 +862,8 @@ Parameter::Parameter(const Parameter& p) } /*! + Assigning Parameter \a p to this Parameter copies the + strings across. */ Parameter& Parameter::operator=(const Parameter& p) { @@ -871,6 +875,23 @@ Parameter& Parameter::operator=(const Parameter& p) } /*! + Reconstructs the text describing the parameter and + returns it. If \a value is true, the default value + will be included, if there is one. + */ +QString Parameter::reconstruct(bool value) const +{ + QString p = lef + rig; + if (!p.endsWith(QChar('*')) && !p.endsWith(QChar('&')) && !p.endsWith(QChar(' '))) + p += " "; + p += nam; + if (value) + p += def; + return p; +} + + +/*! \class FunctionNode */ @@ -924,6 +945,8 @@ void FunctionNode::borrowParameterNames(const FunctionNode *source) } /*! + If this function is a reimplementation, \a from points + to the FunctionNode of the function being reimplemented. */ void FunctionNode::setReimplementedFrom(FunctionNode *from) { @@ -932,6 +955,8 @@ void FunctionNode::setReimplementedFrom(FunctionNode *from) } /*! + Sets the "associated" property to \a property. The function + might be the setter or getter for a property, for example. */ void FunctionNode::setAssociatedProperty(PropertyNode *property) { @@ -939,6 +964,8 @@ void FunctionNode::setAssociatedProperty(PropertyNode *property) } /*! + Returns the overload number for this function obtained + from the parent. */ int FunctionNode::overloadNumber() const { @@ -946,6 +973,8 @@ int FunctionNode::overloadNumber() const } /*! + Returns the number of times this function name has been + overloaded, obtained from the parent. */ int FunctionNode::numOverloads() const { @@ -953,6 +982,7 @@ int FunctionNode::numOverloads() const } /*! + Returns the list of parameter names. */ QStringList FunctionNode::parameterNames() const { @@ -966,6 +996,46 @@ QStringList FunctionNode::parameterNames() const } /*! + Returns the list of reconstructed parameters. If \a values + is true, the default values are included, if any are present. + */ +QStringList FunctionNode::reconstructParams(bool values) const +{ + QStringList params; + QList<Parameter>::ConstIterator p = parameters().begin(); + while (p != parameters().end()) { + params << (*p).reconstruct(values); + ++p; + } + return params; +} + +/*! + Reconstructs and returns the function's signature. If \a values + is true, the default values of the parameters are included, if + present. + */ +QString FunctionNode::signature(bool values) const +{ + QString s; + if (!returnType().isEmpty()) + s = returnType() + " "; + s += name() + "("; + QStringList params = reconstructParams(values); + int p = params.size(); + if (p > 0) { + for (int i=0; i<p; i++) { + s += params[i]; + if (i < (p-1)) + s += ", "; + } + } + s += ")"; + return s; +} + + +/*! \class PropertyNode */ diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h index 09f38d2..f933270 100644 --- a/tools/qdoc3/node.h +++ b/tools/qdoc3/node.h @@ -175,13 +175,11 @@ class Node virtual QString fileBase() const; - static QString typeName(int i) { return typeNames[i]; } - protected: Node(Type type, InnerNode *parent, const QString& name); private: - static QString typeNames[]; + #ifdef Q_WS_WIN Type typ; Access acc; @@ -500,8 +498,10 @@ class Parameter { public: Parameter() {} - Parameter(const QString& leftType, const QString& rightType = "", - const QString& name = "", const QString& defaultValue = ""); + Parameter(const QString& leftType, + const QString& rightType = "", + const QString& name = "", + const QString& defaultValue = ""); Parameter(const Parameter& p); Parameter& operator=(const Parameter& p); @@ -514,6 +514,8 @@ class Parameter const QString& name() const { return nam; } const QString& defaultValue() const { return def; } + QString reconstruct(bool value = false) const; + private: QString lef; QString rig; @@ -541,6 +543,7 @@ class FunctionNode : public LeafNode virtual ~FunctionNode() { } void setReturnType(const QString& returnType) { rt = returnType; } + void setParentPath(const QStringList& parentPath) { pp = parentPath; } void setMetaness(Metaness metaness) { met = metaness; } void setVirtualness(Virtualness virtualness) { vir = virtualness; } void setConst(bool conste) { con = conste; } @@ -569,6 +572,10 @@ class FunctionNode : public LeafNode const FunctionNode *reimplementedFrom() const { return rf; } const QList<FunctionNode *> &reimplementedBy() const { return rb; } const PropertyNode *associatedProperty() const { return ap; } + const QStringList& parentPath() const { return pp; } + + QStringList reconstructParams(bool values = false) const; + QString signature(bool values = false) const; private: void setAssociatedProperty(PropertyNode *property); @@ -576,9 +583,10 @@ class FunctionNode : public LeafNode friend class InnerNode; friend class PropertyNode; - QString rt; + QString rt; + QStringList pp; #ifdef Q_WS_WIN - Metaness met; + Metaness met; Virtualness vir; #else Metaness met : 4; |