diff options
author | Martin Smith <martin.smith@nokia.com> | 2010-05-25 10:09:14 (GMT) |
---|---|---|
committer | Martin Smith <martin.smith@nokia.com> | 2010-05-25 10:09:14 (GMT) |
commit | c6d92ebe915e4ed857aca5130e514c6ec81dd33f (patch) | |
tree | ae3845f4aa88bbeb0b50f788358f2cb8815e12c3 /tools | |
parent | 4add74753e868e2882bd8a571edb54a8966617fa (diff) | |
download | Qt-c6d92ebe915e4ed857aca5130e514c6ec81dd33f.zip Qt-c6d92ebe915e4ed857aca5130e514c6ec81dd33f.tar.gz Qt-c6d92ebe915e4ed857aca5130e514c6ec81dd33f.tar.bz2 |
qdoc: Improved class index page.
The classes.html page will look good with the correct css.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qdoc3/htmlgenerator.cpp | 193 |
1 files changed, 89 insertions, 104 deletions
diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index cf8ea7c..42db4e8 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -434,6 +434,9 @@ void HtmlGenerator::startText(const Node * /* relative */, sectionNumber.clear(); } +/*! + Generate html from an instance of Atom. + */ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker) @@ -1217,6 +1220,9 @@ int HtmlGenerator::generateAtom(const Atom *atom, return skipAhead; } +/*! + Generate a reference page for a C++ class. + */ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, CodeMarker *marker) { @@ -1466,6 +1472,10 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, appendDcfSubSection(&dcfClassesRoot, classSection); } +/*! + Generate the html page for a qdoc file that doesn't map + to an underlying c++ file. + */ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) { SubTitleSize subTitleSize = LargeSubTitle; @@ -1682,6 +1692,9 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) } } +/*! + Returns "html" for this subclass of Generator. + */ QString HtmlGenerator::fileExtension(const Node * /* node */) const { return "html"; @@ -1735,10 +1748,10 @@ void HtmlGenerator::generateBreadCrumbs(const QString& title, } else if (node->subType() == Node::Page) { if (fn->name() == QString("examples.html")) { - out() << " <li><a href=\"examples.html\">All Examples</a></li>"; + out() << " <li><a href=\"all-examples.html\">Examples</a></li>"; } else if (fn->name().startsWith("examples-")) { - out() << " <li><a href=\"examples.html\">All Examples</a></li>"; + out() << " <li><a href=\"all-examples.html\">Examples</a></li>"; out() << " <li><a href=\"" << fn->name() << "\">" << title << "</a></li>"; } @@ -1756,7 +1769,7 @@ void HtmlGenerator::generateBreadCrumbs(const QString& title, << "</a></li>"; } else if (node->subType() == Node::Example) { - out() << " <li><a href=\"examples.html\">All Examples</a></li>"; + out() << " <li><a href=\"all-examples.html\">Examples</a></li>"; QStringList sl = fn->name().split('/'); QString name = "examples-" + sl.at(0) + ".html"; QString t = CodeParser::titleFromName(name); @@ -2332,7 +2345,6 @@ void HtmlGenerator::generateCompactList(const Node *relative, QString commonPrefix) { const int NumParagraphs = 37; // '0' to '9', 'A' to 'Z', '_' - const int NumColumns = 1; // number of columns in the result if (classMap.isEmpty()) return; @@ -2415,18 +2427,18 @@ void HtmlGenerator::generateCompactList(const Node *relative, else key = pieces.last().toLower(); - int paragraphNo = NumParagraphs - 1; + int paragraphNr = NumParagraphs - 1; if (key[0].digitValue() != -1) { - paragraphNo = key[0].digitValue(); + paragraphNr = key[0].digitValue(); } else if (key[0] >= QLatin1Char('a') && key[0] <= QLatin1Char('z')) { - paragraphNo = 10 + key[0].unicode() - 'a'; + paragraphNr = 10 + key[0].unicode() - 'a'; } - paragraphName[paragraphNo] = key[0].toUpper(); + paragraphName[paragraphNr] = key[0].toUpper(); usedParagraphNames.insert(key[0].toLower().cell()); - paragraph[paragraphNo].insert(key, c.value()); + paragraph[paragraphNr].insert(key, c.value()); ++c; } @@ -2439,36 +2451,16 @@ void HtmlGenerator::generateCompactList(const Node *relative, start at offsets 0, 3, 4, 8, 9, 14, 23. */ int paragraphOffset[NumParagraphs + 1]; // 37 + 1 - int i, j, k; - paragraphOffset[0] = 0; - for (j = 0; j < NumParagraphs; j++) // j = 0..36 - paragraphOffset[j + 1] = paragraphOffset[j] + paragraph[j].count(); - - int firstOffset[NumColumns + 1]; - int currentOffset[NumColumns]; - int currentParagraphNo[NumColumns]; - int currentOffsetInParagraph[NumColumns]; + for (int i=0; i<NumParagraphs; i++) // i = 0..36 + paragraphOffset[i+1] = paragraphOffset[i] + paragraph[i].count(); - int numRows = (classMap.count() + NumColumns - 1) / NumColumns; - int curParagNo = 0; - - for (i = 0; i < NumColumns; i++) { - firstOffset[i] = qMin(i * numRows, classMap.size()); - currentOffset[i] = firstOffset[i]; - - for (j = curParagNo; j < NumParagraphs; j++) { - if (paragraphOffset[j] > firstOffset[i]) - break; - if (paragraphOffset[j] <= firstOffset[i]) - curParagNo = j; - } - currentParagraphNo[i] = curParagNo; - currentOffsetInParagraph[i] = firstOffset[i] - - paragraphOffset[curParagNo]; - } - firstOffset[NumColumns] = classMap.count(); + int curParNr = 0; + int curParOffset = 0; + /* + Output the alphabet as a row of links. + */ if (includeAlphabet) { out() << "<p class=\"centerAlign functionIndex\"><b>"; for (int i = 0; i < 26; i++) { @@ -2479,80 +2471,73 @@ void HtmlGenerator::generateCompactList(const Node *relative, out() << "</b></p>\n"; } + /* + Output a <div> element to contain all the <dl> elements. + */ out() << "<div class=\"flowListDiv\">\n"; - for (k = 0; k < numRows; k++) { - if (++numTableRows % 2 == 1) - out() << "<dl class=\"flowList odd\">"; - else - out() << "<dl class=\"flowList even\">"; - //break; - -// out() << "<tr>\n"; - for (i = 0; i < NumColumns; i++) { - if (currentOffset[i] >= firstOffset[i + 1]) { - // this column is finished - out() << "<dd>\n</dd>\n"; // check why? + + for (int i=0; i<classMap.count()-1; i++) { + while ((curParNr < NumParagraphs) && + (curParOffset == paragraph[curParNr].count())) { + ++curParNr; + curParOffset = 0; + } + + /* + Starting a new paragraph means starting a new <dl>. + */ + if (curParOffset == 0) { + if (i > 0) + out() << "</dl>\n"; + if (++numTableRows % 2 == 1) + out() << "<dl class=\"flowList odd\">"; + else + out() << "<dl class=\"flowList even\">"; + out() << "<dt class=\"alphaChar\"><p>"; + if (includeAlphabet) { + QChar c = paragraphName[curParNr][0].toLower(); + out() << QString("<a name=\"%1\"></a>").arg(c); } - else { - while ((currentParagraphNo[i] < NumParagraphs) && - (currentOffsetInParagraph[i] == paragraph[currentParagraphNo[i]].count())) { - ++currentParagraphNo[i]; - currentOffsetInParagraph[i] = 0; - } -#if 0 - if (currentParagraphNo[i] >= NumParagraphs) { - qDebug() << "### Internal error ###" << __FILE__ << __LINE__ - << currentParagraphNo[i] << NumParagraphs; - currentParagraphNo[i] = NumParagraphs - 1; - } -#endif - out() << "<dt class=\"alphaChar\"><p>"; - if (currentOffsetInParagraph[i] == 0) { - // start a new paragraph - if (includeAlphabet) { - QChar c = paragraphName[currentParagraphNo[i]][0].toLower(); - out() << QString("<a name=\"%1\"></a>").arg(c); - } - out() << "<b>" - << paragraphName[currentParagraphNo[i]] - << "</b>"; - } - out() << "</p></dt>\n"; - - out() << "<dd><p>"; - if ((currentParagraphNo[i] < NumParagraphs) && - !paragraphName[currentParagraphNo[i]].isEmpty()) { - NodeMap::Iterator it; - it = paragraph[currentParagraphNo[i]].begin(); - for (j = 0; j < currentOffsetInParagraph[i]; j++) - ++it; - - // Previously, we used generateFullName() for this, but we - // require some special formatting. - out() << "<a href=\"" - << linkForNode(it.value(), relative) - << "\">"; - QStringList pieces; - if (it.value()->subType() == Node::QmlClass) - pieces << it.value()->name(); - else - pieces = fullName(it.value(), relative, marker).split("::"); - out() << protectEnc(pieces.last()); - out() << "</a>"; - if (pieces.size() > 1) { - out() << " ("; - generateFullName(it.value()->parent(), relative, marker); - out() << ")"; - } - } - out() << "</p></dd>\n"; + out() << "<b>" + << paragraphName[curParNr] + << "</b>"; + out() << "</p></dt>\n"; + } - currentOffset[i]++; - currentOffsetInParagraph[i]++; + /* + Output a <dd> for the current offset in the current paragraph. + */ + out() << "<dd><p>"; + if ((curParNr < NumParagraphs) && + !paragraphName[curParNr].isEmpty()) { + NodeMap::Iterator it; + it = paragraph[curParNr].begin(); + for (int i=0; i<curParOffset; i++) + ++it; + + /* + Previously, we used generateFullName() for this, but we + require some special formatting. + */ + out() << "<a href=\"" << linkForNode(it.value(), relative) << "\">"; + + QStringList pieces; + if (it.value()->subType() == Node::QmlClass) + pieces << it.value()->name(); + else + pieces = fullName(it.value(), relative, marker).split("::"); + out() << protectEnc(pieces.last()); + out() << "</a>"; + if (pieces.size() > 1) { + out() << " ("; + generateFullName(it.value()->parent(), relative, marker); + out() << ")"; } } - out() << "</dl>\n"; + out() << "</p></dd>\n"; + curParOffset++; } + out() << "</dl>\n"; out() << "</div>\n"; } |