From 04925d40d960a394345f83ef51cce7b547431b92 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 29 Apr 2010 13:49:43 +0200 Subject: qdoc: Added breadcrumbs to examples. Coolio. Doesn't work in a few cases because of non-standard naming of things. --- tools/qdoc3/codeparser.cpp | 12 ++++++++++++ tools/qdoc3/codeparser.h | 2 ++ tools/qdoc3/htmlgenerator.cpp | 23 +++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/tools/qdoc3/codeparser.cpp b/tools/qdoc3/codeparser.cpp index a717ff1..78804eb 100644 --- a/tools/qdoc3/codeparser.cpp +++ b/tools/qdoc3/codeparser.cpp @@ -70,6 +70,7 @@ QT_BEGIN_NAMESPACE QList CodeParser::parsers; bool CodeParser::showInternal = false; +QMap CodeParser::nameToTitle; /*! The constructor adds this code parser to the static @@ -250,10 +251,21 @@ void CodeParser::processCommonMetaCommand(const Location &location, if (node->type() == Node::Fake) { FakeNode *fake = static_cast(node); fake->setTitle(arg); + nameToTitle.insert(fake->name(),arg); + qDebug() << "NAME TO TITLE:" << fake->name() << arg; } else location.warning(tr("Ignored '\\%1'").arg(COMMAND_TITLE)); } } +/*! + Find the page title given the page \a name and return it. + */ +const QString CodeParser::titleFromName(const QString& name) +{ + const QString t = nameToTitle.value(name); + return t; +} + QT_END_NAMESPACE diff --git a/tools/qdoc3/codeparser.h b/tools/qdoc3/codeparser.h index 7b0d0eb..ebba601 100644 --- a/tools/qdoc3/codeparser.h +++ b/tools/qdoc3/codeparser.h @@ -78,6 +78,7 @@ class CodeParser static void initialize(const Config& config); static void terminate(); static CodeParser *parserForLanguage(const QString& language); + static const QString titleFromName(const QString& name); protected: QSet commonMetaCommands(); @@ -88,6 +89,7 @@ class CodeParser private: static QList parsers; static bool showInternal; + static QMap nameToTitle; }; QT_END_NAMESPACE diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index f8b1d59..9aa8a9a 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -44,6 +44,7 @@ */ #include "codemarker.h" +#include "codeparser.h" #include "helpprojectwriter.h" #include "htmlgenerator.h" #include "node.h" @@ -1674,6 +1675,9 @@ QString HtmlGenerator::fileExtension(const Node * /* node */) const return "html"; } +/*! + Output breadcrumb list in the html file. + */ void HtmlGenerator::generateBreadCrumbs(const QString& title, const Node *node, CodeMarker *marker) @@ -1713,9 +1717,28 @@ void HtmlGenerator::generateBreadCrumbs(const QString& title, if (fn->name() == QString("modules")) out() << "
  • All Modules
  • "; } + else if (node->subType() == Node::Page) { + if (fn->name() == QString("examples.html")) { + out() << "
  • All Examples
  • "; + } + else if (fn->name().startsWith("examples-")) { + out() << "
  • All Examples
  • "; + out() << "
  • name() << "\">" << title + << "
  • "; + } + } else if (node->subType() == Node::QmlClass) { } else if (node->subType() == Node::Example) { + out() << "
  • All Examples
  • "; + QStringList sl = fn->name().split('/'); + QString name = "examples-" + sl.at(0) + ".html"; + QString t = CodeParser::titleFromName(name); + out() << "
  • " + << t << "
  • "; + out() << "
  • " + << title << "
  • "; } } else if (node->type() == Node::Namespace) { -- cgit v0.12