summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMartin Smith <msmith@trolltech.com>2010-04-13 08:19:26 (GMT)
committerMartin Smith <msmith@trolltech.com>2010-04-13 08:19:26 (GMT)
commit1055099e331af3b10d0b81b1a965e7d3db5f272d (patch)
tree781840932860e63ce09fe421fdb8de3acbaee0d1 /tools
parent9eab27889b1e14385f9428417e048da960ca06de (diff)
downloadQt-1055099e331af3b10d0b81b1a965e7d3db5f272d.zip
Qt-1055099e331af3b10d0b81b1a965e7d3db5f272d.tar.gz
Qt-1055099e331af3b10d0b81b1a965e7d3db5f272d.tar.bz2
qdoc: Added new table of contents for non-class ref pages
This feature is not complete in this commit.
Diffstat (limited to 'tools')
-rw-r--r--tools/qdoc3/htmlgenerator.cpp76
-rw-r--r--tools/qdoc3/htmlgenerator.h1
-rw-r--r--tools/qdoc3/pagegenerator.cpp2
3 files changed, 76 insertions, 3 deletions
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<Atom *> 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() << "<div class=\"toc\">\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() << "<ul>\n";
+ sectionNumber.append("1");
+ } while (sectionNumber.size() < nextLevel);
+ }
+ else {
+ while (sectionNumber.size() > nextLevel) {
+ out() << "</ul>\n";
+ sectionNumber.removeLast();
+ }
+ sectionNumber.last() = QString::number(sectionNumber.last().toInt() + 1);
+ }
+ int numAtoms;
+ Text headingText = Text::sectionHeading(atom);
+ out() << "<li>";
+ out() << "<a href=\""
+ << nodeName
+ << "#"
+ << Doc::canonicalTitle(headingText.toString())
+ << "\">";
+ generateAtomList(headingText.firstAtom(), node, marker, true, numAtoms);
+ out() << "</a></li>\n";
+
+ ++columnSize;
+ }
+ while (!sectionNumber.isEmpty()) {
+ out() << "</ul>\n";
+ sectionNumber.removeLast();
+ }
+ out() << "</div>\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));
- // <!--Put all your content here-->
- //generateTableOfContents(node,marker,Doc::Section4,1,relative);
if (node->type() == Node::Namespace || node->type() == Node::Class) {
generateClassLikeNode(node, marker);
}