aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-06-24 15:41:20 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-25 10:14:03 +0000
commit02945735a2da5969888c22ffe0796cd0ac677f45 (patch)
treeb78b277968200223f684caf434100403b475ef75 /sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
parent179a026e13baa056641b06a44cb29f165f938cd2 (diff)
shiboken6/doc generator: Resolve relative, local .html documents to doc.qt.io
Links to relative, local .html documents as generated by qdoc into the WebXML files are currently broken in our documentation (800 cases). They are syntactically not recognized by sphinx nor could be resolved in the HTML file tree. Expand them to URLs to the doc.qt.io web page. Task-number: PYSIDE-1112 Change-Id: Ibdc7f9c47db6d26c088678aa67f1a320542f68e0 Reviewed-by: Christian Tismer <tismer@stackless.com> (cherry picked from commit 2167ad24f81515a414a655742963fd4b3899ddb2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp')
-rw-r--r--sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
index fd4716e0a..6ba3847bd 100644
--- a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
@@ -1141,7 +1141,29 @@ const QLoggingCategory &QtDocGenerator::loggingCategory() const
return lcShibokenDoc();
}
+static bool isRelativeHtmlFile(const QString &linkRef)
+{
+ return !linkRef.startsWith(u"http")
+ && (linkRef.endsWith(u".html") || linkRef.contains(u".html#"));
+}
+
+// Resolve relative, local .html documents links to doc.qt.io as they
+// otherwise will not work and neither be found in the HTML tree.
QtXmlToSphinxLink QtDocGenerator::resolveLink(const QtXmlToSphinxLink &link) const
{
- return link;
+ if (link.type != QtXmlToSphinxLink::Reference || !isRelativeHtmlFile(link.linkRef))
+ return link;
+ static const QString prefix = QStringLiteral("https://doc.qt.io/qt-")
+ + QString::number(QT_VERSION_MAJOR) + QLatin1Char('/');
+ QtXmlToSphinxLink resolved = link;
+ resolved.type = QtXmlToSphinxLink::External;
+ resolved.linkRef = prefix + link.linkRef;
+ if (resolved.linkText.isEmpty()) {
+ resolved.linkText = link.linkRef;
+ const qsizetype anchor = resolved.linkText.lastIndexOf(u'#');
+ if (anchor != -1)
+ resolved.linkText.truncate(anchor);
+ }
+ qDebug() << __FUNCTION__ << link << "->" << resolved;
+ return resolved;
}