From efba0372add3a080acafc30663b28e72ef72e435 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 14 Oct 2009 10:27:01 +0200 Subject: qdoc: Made the \sincelist command produce better html. --- doc/src/qt4-intro.qdoc | 5 +- tools/qdoc3/htmlgenerator.cpp | 157 ++++++++++++++++++++++++++---------------- tools/qdoc3/htmlgenerator.h | 9 +-- 3 files changed, 105 insertions(+), 66 deletions(-) diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index e37d327..cecff0e 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -664,9 +664,10 @@ See the \l{QtMultimedia Module} documentation for more information. - \section1 Classes, functions, etc new in 4.6 + \section1 New Classes, Functions, Macros, etc - Links to classes, functions, and other items that are new in 4.6. + Links to new classes, functions, macros, and other items + introduced in Qt 4.6. \sincelist 4.6 diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 033c62c..c02dc2e 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -672,18 +672,18 @@ int HtmlGenerator::generateAtom(const Atom *atom, break; case Atom::SinceList: { - 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()) { + NewSinceMaps::const_iterator nsmap; + nsmap = newSinceMaps.find(atom->string()); + NewClassMaps::const_iterator ncmap; + ncmap = newClassMaps.find(atom->string()); + if ((nsmap != newSinceMaps.constEnd()) && !nsmap.value().isEmpty()) { QList
sections; QList
::ConstIterator s; for (int i=0; itype()) { case Node::Namespace: @@ -741,35 +741,63 @@ int HtmlGenerator::generateAtom(const Atom *atom, } ++n; } + + /* + First generate the table of contents. + */ + out() << "
    \n"; + s = sections.constBegin(); + while (s != sections.constEnd()) { + if (!(*s).members.isEmpty()) { + + out() << "
  • " + << "" + << (*s).name + << "
  • \n"; + } + ++s; + } + out() << "
\n"; + int idx = 0; s = sections.constBegin(); while (s != sections.constEnd()) { if (!(*s).members.isEmpty()) { out() << "\n"; out() << "

" << protect((*s).name) << "

\n"; if (idx == Class) - generateCompactList(0, marker, nc.value(), QString("Q")); + generateCompactList(0, marker, ncmap.value(), QString("Q")); else if (idx == MemberFunction) { - NodeMultiMapMap nodemultimapmap; - NodeMultiMapMap::iterator nmmap; + ParentMaps parentmaps; + ParentMaps::iterator pmap; 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)); + pmap = parentmaps.find(p); + if (pmap == parentmaps.end()) + pmap = parentmaps.insert(p,NodeMultiMap()); + pmap->insert((*i)->name(),(*i)); ++i; } - nmmap = nodemultimapmap.begin(); - while (nmmap != nodemultimapmap.end()) { - NodeList nlist = nmmap->values(); - out() << "

New functions in " << protect(nmmap.key()) << ":

\n"; + pmap = parentmaps.begin(); + while (pmap != parentmaps.end()) { + NodeList nlist = pmap->values(); + out() << "

Class "; + + out() << ""; + QStringList pieces = fullName(pmap.key(), 0, marker).split("::"); + out() << protect(pieces.last()); + out() << "" << ":

\n"; + generateSection(nlist, 0, marker, CodeMarker::Summary); out() << "
"; - ++nmmap; + ++pmap; } } else @@ -1124,7 +1152,10 @@ int HtmlGenerator::generateAtom(const Atom *atom, } if (node) - generateTableOfContents(node, marker, sectioningUnit, numColumns, + generateTableOfContents(node, + marker, + sectioningUnit, + numColumns, relative); } break; @@ -2112,7 +2143,8 @@ void HtmlGenerator::generateCompactList(const Node *relative, /* If commonPrefix is not empty, then the caller knows what - the common prefix is, so just use that. + the common prefix is and has passed it in, so just use that + one. */ int commonPrefixLen = commonPrefix.length(); if (commonPrefixLen == 0) { @@ -2120,10 +2152,15 @@ void HtmlGenerator::generateCompactList(const Node *relative, 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). + The caller didn't pass in a common prefix, so get the common + prefix by looking at the class names of the first and last + classes in the class map. Discard any namespace names and + just use the bare class names. For Qt, the prefix is "Q". + + Note that the algorithm used here to derive the common prefix + from the first and last classes in alphabetical order (QAccel + and QXtWidget in Qt 2.1), fails if either class name does not + begin with Q. */ NodeMap::const_iterator iter = classMap.begin(); @@ -2164,8 +2201,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, 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 - NodeMap. + assume that NumParagraphs is 37. Each paragraph is a NodeMap. */ NodeMap paragraph[NumParagraphs+1]; QString paragraphName[NumParagraphs+1]; @@ -3644,53 +3680,54 @@ void HtmlGenerator::findAllClasses(const InnerNode *node) } /*! - For generating the "Since x.y" page. + For generating the "New Classes... in 4.6" section on the + What's New in 4.6" page. */ void HtmlGenerator::findAllSince(const InnerNode *node) { - NodeList::const_iterator c = node->childNodes().constBegin(); - while (c != node->childNodes().constEnd()) { - QString sinceVersion = (*c)->since(); - if (((*c)->access() != Node::Private) && !sinceVersion.isEmpty()) { - 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()); + NodeList::const_iterator child = node->childNodes().constBegin(); + while (child != node->childNodes().constEnd()) { + QString sinceVersion = (*child)->since(); + if (((*child)->access() != Node::Private) && !sinceVersion.isEmpty()) { + NewSinceMaps::iterator nsmap = newSinceMaps.find(sinceVersion); + if (nsmap == newSinceMaps.end()) + nsmap = newSinceMaps.insert(sinceVersion,NodeMultiMap()); + NewClassMaps::iterator ncmap = newClassMaps.find(sinceVersion); + if (ncmap == newClassMaps.end()) + ncmap = newClassMaps.insert(sinceVersion,NodeMap()); - if ((*c)->type() == Node::Function) { - FunctionNode *func = static_cast(*c); + if ((*child)->type() == Node::Function) { + FunctionNode *func = static_cast(*child); if ((func->status() > Node::Obsolete) && (func->metaness() != FunctionNode::Ctor) && (func->metaness() != FunctionNode::Dtor)) { - vmap.value().insert(func->name(),(*c)); + nsmap.value().insert(func->name(),(*child)); } } - else if ((*c)->url().isEmpty()) { - if ((*c)->type() == Node::Class && !(*c)->doc().isEmpty()) { - QString className = (*c)->name(); - if ((*c)->parent() && - (*c)->parent()->type() == Node::Namespace && - !(*c)->parent()->name().isEmpty()) - className = (*c)->parent()->name()+"::"+className; - vmap.value().insert(className,(*c)); - ncmap.value().insert(className,(*c)); + else if ((*child)->url().isEmpty()) { + if ((*child)->type() == Node::Class && !(*child)->doc().isEmpty()) { + QString className = (*child)->name(); + if ((*child)->parent() && + (*child)->parent()->type() == Node::Namespace && + !(*child)->parent()->name().isEmpty()) + className = (*child)->parent()->name()+"::"+className; + nsmap.value().insert(className,(*child)); + ncmap.value().insert(className,(*child)); } } else { - QString name = (*c)->name(); - if ((*c)->parent() && - (*c)->parent()->type() == Node::Namespace && - !(*c)->parent()->name().isEmpty()) - name = (*c)->parent()->name()+"::"+name; - vmap.value().insert(name,(*c)); + QString name = (*child)->name(); + if ((*child)->parent() && + (*child)->parent()->type() == Node::Namespace && + !(*child)->parent()->name().isEmpty()) + name = (*child)->parent()->name()+"::"+name; + nsmap.value().insert(name,(*child)); } - if ((*c)->isInnerNode()) { - findAllSince(static_cast(*c)); + if ((*child)->isInnerNode()) { + findAllSince(static_cast(*child)); } } - ++c; + ++child; } } diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index fabfed1..40117df 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -68,9 +68,10 @@ struct NavigationBar #endif typedef QMultiMap NodeMultiMap; -typedef QMap NodeMultiMapMap; +typedef QMap NewSinceMaps; +typedef QMap ParentMaps; typedef QMap NodeMap; -typedef QMap NodeMapMap; +typedef QMap NewClassMaps; class HelpProjectWriter; @@ -311,9 +312,9 @@ class HtmlGenerator : public PageGenerator #endif QMap funcIndex; QMap legaleseTexts; - NodeMultiMapMap nodeMultiMapMap; + NewSinceMaps newSinceMaps; static QString sinceTitles[]; - NodeMapMap nodeMapMap; + NewClassMaps newClassMaps; }; #define HTMLGENERATOR_ADDRESS "address" -- cgit v0.12