From b7f8e7664a38e401c6af6f2447cd565422109f7a Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Mon, 23 Jun 2014 16:48:54 +0200 Subject: qdoc: Improve element contents in HTML pages. -applied logic to projects that set (or not set): -landing page -home page -version -change would remove duplicate information and proper module names instead of "Title | QtModule 5.4", it would be "Title | Qt Module 5.4" -tested on various projects: -Digia projects -Qt 5 -Qt Creator Change-Id: Ica7d5203d293910c98306f947bfee8454b9225d0 Reviewed-by: Martin Smith <martin.smith@digia.com> --- src/tools/qdoc/htmlgenerator.cpp | 43 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'src/tools') diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index 7547177eb3..b27968982a 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -1819,13 +1819,48 @@ void HtmlGenerator::generateHeader(const QString& title, QString shortVersion = qdb_->version(); if (shortVersion.count(QChar('.')) == 2) shortVersion.truncate(shortVersion.lastIndexOf(QChar('.'))); - if (!project.isEmpty()) - shortVersion = QLatin1String(" | ") + project + QLatin1Char(' ') + shortVersion; + + //determine the rest of the <title> element content: "title | titleSuffix version" + QString titleSuffix; + if (!landingpage.isEmpty()) { + //for normal pages: "title | landingpage version" + titleSuffix = landingpage; + } + else if (!homepage.isEmpty()) { + //for pages that set the homepage but not landing page: "title | homepage version" + if (title != homepage) + titleSuffix = homepage; + } + else if (!project.isEmpty()) { + //for projects outside of Qt or Qt 5: "title | project version" + if (title != project) + titleSuffix = project; + } else - shortVersion = QLatin1String(" | ") + QLatin1String("Qt ") + shortVersion ; + //default: "title | Qt version" + titleSuffix = QLatin1String("Qt "); + + //for pages that duplicate the title and suffix (landing pages, home pages, + // and module landing pages, clear the duplicate + if (title == titleSuffix) + titleSuffix.clear(); + + //for pages that duplicate the version, clear the duplicate + if (title.contains(shortVersion) || titleSuffix.contains(shortVersion)) + shortVersion.clear(); + + QString divider; + if (!titleSuffix.isEmpty() && !title.isEmpty()) + divider = QLatin1String(" | "); // Generating page title - out() << " <title>" << protectEnc(title) << shortVersion << "\n"; + out() << " " + << protectEnc(title) + << divider + << titleSuffix + << QLatin1Char(' ') + << shortVersion + << "\n"; // Include style sheet and script links. out() << headerStyles; -- cgit v1.2.3