qdoc: Conditionally generate the navigation bar items as table cells

The new offline template for Qt 5.6, including simplified CSS rules
suitable for rendering with a QTextBrowser, requires the navigation
bar to be generated as an HTML table instead of the previously-used
unordered list.

Make QDoc select between the two based on the contents of
HTML.postheader .qdocconf variable, which defines the header of
the navigation bar.

Modify the old offline CSS to look good also when the nav. bar
is a table.

Task-number: QTBUG-48322
Change-Id: I00e16c24f436e0be049b85d4bcfc916c33ea6b73
Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com>
Reviewed-by: Martin Smith <martin.smith@digia.com>
This commit is contained in:
Topi Reinio 2015-10-16 12:12:09 +02:00 committed by Topi Reiniö
parent 1735024e9d
commit afcc26619f
3 changed files with 65 additions and 31 deletions

View File

@ -266,7 +266,7 @@ footer and license
float: left
}
.navigationbar li a {
.navigationbar li a, .navigationbar td a {
display: block;
text-decoration: none;
background: url(../images/arrow_bc.png);
@ -275,6 +275,23 @@ footer and license
padding-right: 17px;
}
table.buildversion {
float: right;
margin-top: -18px !important;
}
.navigationbar table {
border-radius: 0;
border: 0 none;
background-color: #F2F2F2;
margin: 0;
}
.navigationbar table td {
padding: 0;
border: 0 none;
}
#buildversion {
font-style: italic;
font-size: small;

View File

@ -1847,71 +1847,87 @@ QString HtmlGenerator::fileExtension() const
Output navigation list in the html file.
*/
void HtmlGenerator::generateNavigationBar(const QString &title,
const Node *node,
CodeMarker *marker)
const Node *node,
CodeMarker *marker,
const QString &buildversion,
bool tableItems)
{
if (noNavigationBar)
return;
Text navigationbar;
// Set list item types based on the navigation bar type
Atom::AtomType itemLeft = tableItems ?
Atom::TableItemLeft : Atom::ListItemLeft;
Atom::AtomType itemRight = tableItems ?
Atom::TableItemRight : Atom::ListItemRight;
if (homepage == title)
return;
if (!homepage.isEmpty())
navigationbar << Atom(Atom::ListItemLeft)
<< Atom(Atom::NavAutoLink, homepage)
<< Atom(Atom::ListItemRight);
navigationbar << Atom(itemLeft)
<< Atom(Atom::NavAutoLink, homepage)
<< Atom(itemRight);
if (!landingpage.isEmpty() && landingpage != title)
navigationbar << Atom(Atom::ListItemLeft)
navigationbar << Atom(itemLeft)
<< Atom(Atom::NavAutoLink, landingpage)
<< Atom(Atom::ListItemRight);
<< Atom(itemRight);
if (node->isClass()) {
const ClassNode *cn = static_cast<const ClassNode *>(node);
QString name = node->physicalModuleName();
if (!cppclassespage.isEmpty())
navigationbar << Atom(Atom::ListItemLeft)
navigationbar << Atom(itemLeft)
<< Atom(Atom::NavLink, cppclassespage)
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK)
<< Atom(Atom::String, QLatin1String("C++ Classes"))
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK)
<< Atom(Atom::ListItemRight);
<< Atom(itemRight);
if (!cn->name().isEmpty())
navigationbar << Atom(Atom::ListItemLeft)
<< Atom(Atom::String, cn->name())
<< Atom(Atom::ListItemRight);
if (!node->name().isEmpty())
navigationbar << Atom(itemLeft)
<< Atom(Atom::String, node->name())
<< Atom(itemRight);
}
else if (node->isQmlType() || node->isQmlBasicType() ||
node->isJsType() || node->isJsBasicType()) {
if (!qmltypespage.isEmpty())
navigationbar << Atom(Atom::ListItemLeft)
navigationbar << Atom(itemLeft)
<< Atom(Atom::NavLink, qmltypespage)
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK)
<< Atom(Atom::String, QLatin1String("QML Types"))
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK)
<< Atom(Atom::ListItemRight)
<< Atom(Atom::ListItemLeft)
<< Atom(itemRight)
<< Atom(itemLeft)
<< Atom(Atom::String, title)
<< Atom(Atom::ListItemRight);
<< Atom(itemRight);
}
else {
if (node->isExampleFile()) {
navigationbar << Atom(Atom::ListItemLeft)
navigationbar << Atom(itemLeft)
<< Atom(Atom::NavLink, node->parent()->name())
<< Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK)
<< Atom(Atom::String, node->parent()->title())
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK)
<< Atom(Atom::ListItemRight);
<< Atom(itemRight);
}
navigationbar << Atom(Atom::ListItemLeft)
navigationbar << Atom(itemLeft)
<< Atom(Atom::String, title)
<< Atom(Atom::ListItemRight);
<< Atom(itemRight);
}
generateText(navigationbar, node, marker);
if (buildversion.isEmpty())
return;
if (tableItems) {
out() << "</tr></table><table class=\"buildversion\"><tr>\n"
<< "<td id=\"buildversion\" width=\"100%\" align=\"right\">"
<< buildversion << "</td>\n";
} else {
out() << "<li id=\"buildversion\">" << buildversion << "</li>\n";
}
}
void HtmlGenerator::generateHeader(const QString& title,
@ -1990,9 +2006,8 @@ void HtmlGenerator::generateHeader(const QString& title,
#endif
out() << QString(postHeader).replace("\\" + COMMAND_VERSION, qdb_->version());
generateNavigationBar(title,node,marker);
if (!buildversion.isEmpty())
out() << "<li id=\"buildversion\">" << buildversion << "</li>\n";
bool usingTable = postHeader.trimmed().endsWith(QLatin1String("<tr>"));
generateNavigationBar(title, node, marker, buildversion, usingTable);
out() << QString(postPostHeader).replace("\\" + COMMAND_VERSION, qdb_->version());
navigationLinks.clear();

View File

@ -125,9 +125,11 @@ private:
};
const QPair<QString,QString> anchorForNode(const Node *node);
void generateNavigationBar(const QString& title,
const Node *node,
CodeMarker *marker);
void generateNavigationBar(const QString &title,
const Node *node,
CodeMarker *marker,
const QString &buildversion,
bool tableItems = false);
void generateHeader(const QString& title,
const Node *node = 0,
CodeMarker *marker = 0);