summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2019-03-18 13:39:57 +0100
committerTopi Reinio <topi.reinio@qt.io>2019-05-31 15:24:34 +0200
commite42dd0a13ebf37f7402a4cf09a6fb62b8c740c76 (patch)
tree9e1368906334cef88abbf7d78df3168953c6f012
parent2ecbaa7c29de2350486c6e83375ba8c83fee6cda (diff)
qdoc: Avoid duplicating version strings in HTML <title> element
Commit 802aa37f introduced full version strings into the titles in HTML header. However, for pages that already included a prefix of the version information (e.g. 'Qt 5.13'), this meant that the version appeared now twice ('Qt 5.13 5.13.0'). This commit checks for the presence of a version prefix in the title and only appends the full version if one is not found or does not match with the project version (which for Qt modules is QT_VERSION). Fixes: QTBUG-74301 Change-Id: Iceb3cf8f0e0181709e547a87cb6e92a6a13dcfef Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
-rw-r--r--src/qdoc/htmlgenerator.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp
index 23cd581e6..e5a5675f2 100644
--- a/src/qdoc/htmlgenerator.cpp
+++ b/src/qdoc/htmlgenerator.cpp
@@ -45,6 +45,7 @@
#include <qtextcodec.h>
#include <quuid.h>
#include <qmap.h>
+#include <QtCore/qversionnumber.h>
QT_BEGIN_NAMESPACE
@@ -1953,8 +1954,6 @@ void HtmlGenerator::generateHeader(const QString& title,
if (node && !node->doc().location().isEmpty())
out() << "<!-- " << node->doc().location().fileName() << " -->\n";
- QString projectVersion = qdb_->version();
-
//determine the rest of the <title> element content: "title | titleSuffix version"
QString titleSuffix;
if (!landingtitle.isEmpty()) {
@@ -1976,15 +1975,9 @@ void HtmlGenerator::generateHeader(const QString& title,
//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(projectVersion) || titleSuffix.contains(projectVersion))
- projectVersion.clear();
-
QString divider;
if (!titleSuffix.isEmpty() && !title.isEmpty())
divider = QLatin1String(" | ");
@@ -1995,9 +1988,18 @@ void HtmlGenerator::generateHeader(const QString& title,
<< divider
<< titleSuffix;
- if (!projectVersion.isEmpty())
- out() << QLatin1Char(' ') << projectVersion;
-
+ // append a full version to the suffix if neither suffix nor title
+ // include (a prefix of) version information
+ QVersionNumber projectVersion = QVersionNumber::fromString(qdb_->version());
+ if (!projectVersion.isNull()) {
+ QVersionNumber titleVersion;
+ QRegExp re("\\d+\\.\\d+");
+ const QString &versionedTitle = titleSuffix.isEmpty() ? title : titleSuffix;
+ if (versionedTitle.contains(re))
+ titleVersion = QVersionNumber::fromString(re.cap());
+ if (titleVersion.isNull() || !titleVersion.isPrefixOf(projectVersion))
+ out() << QLatin1Char(' ') << projectVersion.toString();
+ }
out() << "</title>\n";
// Include style sheet and script links.