From 1055099e331af3b10d0b81b1a965e7d3db5f272d Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 13 Apr 2010 10:19:26 +0200 Subject: qdoc: Added new table of contents for non-class ref pages This feature is not complete in this commit. --- .../frameworks-technologies/eventsandfilters.qdoc | 2 - doc/src/modules.qdoc | 4 -- doc/src/qt4-intro.qdoc | 14 ---- tools/qdoc3/htmlgenerator.cpp | 76 +++++++++++++++++++++- tools/qdoc3/htmlgenerator.h | 1 + tools/qdoc3/pagegenerator.cpp | 2 - 6 files changed, 76 insertions(+), 23 deletions(-) diff --git a/doc/src/frameworks-technologies/eventsandfilters.qdoc b/doc/src/frameworks-technologies/eventsandfilters.qdoc index 29d8709..96ee18c 100644 --- a/doc/src/frameworks-technologies/eventsandfilters.qdoc +++ b/doc/src/frameworks-technologies/eventsandfilters.qdoc @@ -67,8 +67,6 @@ document describes how events are delivered and handled in a typical application. - \tableofcontents - \section1 How Events are Delivered When an event occurs, Qt creates an event object to represent it by diff --git a/doc/src/modules.qdoc b/doc/src/modules.qdoc index 8731d57..1ab1c00 100644 --- a/doc/src/modules.qdoc +++ b/doc/src/modules.qdoc @@ -297,8 +297,6 @@ QtScriptTools module provides additional Qt Script-related components that application developers may find useful. - \tableofcontents - To include the definitions of the module's classes, use the following directive: @@ -355,8 +353,6 @@ \brief The QtScriptTools module provides additional components for applications that use Qt Script. - \tableofcontents - \section1 Configuring the Build Process Applications that use the Qt Script Tools classes need to diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index ba9821a..f1b5d41 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -52,8 +52,6 @@ issues that you may encounter. It also explains how to turn on Qt 3 compatibility support. - \tableofcontents - \section1 New Technologies in Qt 4 Qt 4 introduces the following core technologies: @@ -467,10 +465,6 @@ A list of other Qt 4 features can be found on the \bold{\l{What's New in Qt 4}} page. - \bold{Highlights} - - \tableofcontents - \section1 Declarative UI development with Qt Quick \image quick_screens.png @@ -549,10 +543,6 @@ A list of other Qt 4 features can be found on the \bold{\l{What's New in Qt 4}} page. - \bold{Highlights} - - \tableofcontents - \section1 Support for Symbian Qt 4.6 is the first release to include support for the Symbian @@ -762,10 +752,6 @@ A list of other Qt 4 features can be found on the \bold{\l{What's New in Qt 4}} page. - \bold{Highlights} - - \tableofcontents - \section1 Qt WebKit Integration \image webkit-netscape-plugin.png diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index ad678a9..d80e8b4 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1469,6 +1469,14 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) } generateHeader(htmlTitle, fake, marker, true); + + /* + Generate the TOC for the new doc format. + Don't generate a TOC for the home page. + */ + if (fake->name() != QString("index.html")) + generateTableOfContents(fake,marker); + generateTitle(fullTitle, Text() << fake->subTitle(), subTitleSize, @@ -2014,6 +2022,72 @@ void HtmlGenerator::generateTableOfContents(const Node *node, inLink = false; } +/*! + Revised for the new doc format. + Generates a table of contents begining at \a node. + */ +void HtmlGenerator::generateTableOfContents(const Node *node, CodeMarker *marker) +{ + if (!node->doc().hasTableOfContents()) + return; + QList toc = node->doc().tableOfContents(); + if (toc.isEmpty()) + return; + + Doc::SectioningUnit sectioningUnit = Doc::Section4; + QString nodeName = node->name(); + + QStringList sectionNumber; + int columnSize = 0; + + // disable nested links in table of contents + inContents = true; + inLink = true; + + out() << "
\n"; + + for (int i = 0; i < toc.size(); ++i) { + Atom *atom = toc.at(i); + + int nextLevel = atom->string().toInt(); + if (nextLevel > (int)sectioningUnit) + continue; + + if (sectionNumber.size() < nextLevel) { + do { + out() << "
    \n"; + sectionNumber.append("1"); + } while (sectionNumber.size() < nextLevel); + } + else { + while (sectionNumber.size() > nextLevel) { + out() << "
\n"; + sectionNumber.removeLast(); + } + sectionNumber.last() = QString::number(sectionNumber.last().toInt() + 1); + } + int numAtoms; + Text headingText = Text::sectionHeading(atom); + out() << "
  • "; + out() << ""; + generateAtomList(headingText.firstAtom(), node, marker, true, numAtoms); + out() << "
  • \n"; + + ++columnSize; + } + while (!sectionNumber.isEmpty()) { + out() << "\n"; + sectionNumber.removeLast(); + } + out() << "
    \n"; + inContents = false; + inLink = false; +} + #if 0 void HtmlGenerator::generateNavigationBar(const NavigationBar& bar, const Node *node, @@ -2248,7 +2322,7 @@ void HtmlGenerator::generateCompactList(const Node *relative, QString commonPrefix) { const int NumParagraphs = 37; // '0' to '9', 'A' to 'Z', '_' - const int NumColumns = 2; // number of columns in the result + const int NumColumns = 3; // number of columns in the result if (classMap.isEmpty()) return; diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index 8fe0331..ec96c34 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -153,6 +153,7 @@ class HtmlGenerator : public PageGenerator Doc::SectioningUnit sectioningUnit, int numColumns, const Node *relative = 0); + void generateTableOfContents(const Node *node, CodeMarker *marker); QString generateListOfAllMemberFile(const InnerNode *inner, CodeMarker *marker); QString generateLowStatusMemberFile(const InnerNode *inner, CodeMarker *marker, diff --git a/tools/qdoc3/pagegenerator.cpp b/tools/qdoc3/pagegenerator.cpp index b701565..f0f14fe 100644 --- a/tools/qdoc3/pagegenerator.cpp +++ b/tools/qdoc3/pagegenerator.cpp @@ -217,8 +217,6 @@ void PageGenerator::generateInnerNode(const InnerNode *node, if (node->parent() != 0) { beginSubPage(node->location(), fileName(node)); - // - //generateTableOfContents(node,marker,Doc::Section4,1,relative); if (node->type() == Node::Namespace || node->type() == Node::Class) { generateClassLikeNode(node, marker); } -- cgit v0.12