From 6f20dba6d25dac1a78558a07f4a7e0430546c03a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 18 Jun 2021 13:50:09 +0200 Subject: shiboken6/Doc generator: Fix HTTP URLs in documentation Always use as "external", do not reformat them as RST labels. Fixes for example the link to the Sinclair ZX Spectrum page in the QLCDnumber documentation, which appeared as WebXML link tag and was reformatted. Change-Id: Ibf0195365488979bdfd3e08cdd59e77860ac30f6 Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 705b80e6a427ac9d27e0e1911e1bdcfb17634b12) Reviewed-by: Qt Cherry-pick Bot --- sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp index 20681f426..52d8f4614 100644 --- a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp +++ b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp @@ -69,6 +69,11 @@ QString msgFallbackWarning(const QXmlStreamReader &reader, const QString &contex return msgTagWarning(reader, context, tag, message); } +static bool isHttpLink(const QString &ref) +{ + return ref.startsWith(u"http://") || ref.startsWith(u"https://"); +} + struct QtXmlToSphinx::LinkContext { enum Type @@ -931,7 +936,9 @@ QtXmlToSphinx::LinkContext *QtXmlToSphinx::handleLinkStart(const QString &type, else if (m_insideItalic) result->flags |= LinkContext::InsideItalic; - if (type == functionLinkType() && !m_context.isEmpty()) { + if (type == u"external" || isHttpLink(ref)) { + result->type = LinkContext::External; + } else if (type == functionLinkType() && !m_context.isEmpty()) { result->type = LinkContext::Method; const auto rawlinklist = QStringView{result->linkRef}.split(QLatin1Char('.')); if (rawlinklist.size() == 1 || rawlinklist.constFirst() == m_context) { @@ -953,12 +960,8 @@ QtXmlToSphinx::LinkContext *QtXmlToSphinx::handleLinkStart(const QString &type, // Module, external web page or reference if (result->linkRef == m_parameters.moduleName) result->type = LinkContext::Module; - else if (result->linkRef.startsWith(QLatin1String("http"))) - result->type = LinkContext::External; else result->type = LinkContext::Reference; - } else if (type == QLatin1String("external")) { - result->type = LinkContext::External; } else { result->type = LinkContext::Reference; } -- cgit v1.2.3