aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-05-04 13:19:37 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-05-17 08:55:55 +0000
commit6033f4a3425268b8c4aa1f61f7bd8b247a1ff380 (patch)
tree2e9e1c70a07d169c70512def593355b48aeabb3a /sources/shiboken2/ApiExtractor
parenta1ee1b664909b1a620be2e63894597fdbbb7e84e (diff)
Docs: Point to Qt online documentation for QML types
If a -qmlmodule.webxml file exists, insert a link to the Qt online documentation. Task-number: PYSIDE-363 Change-Id: I49a46ed097e8f7136b39f38e2206a2229dd08e41 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor')
-rw-r--r--sources/shiboken2/ApiExtractor/qtdocparser.cpp36
1 files changed, 30 insertions, 6 deletions
diff --git a/sources/shiboken2/ApiExtractor/qtdocparser.cpp b/sources/shiboken2/ApiExtractor/qtdocparser.cpp
index 8917f801e..abcd2ced5 100644
--- a/sources/shiboken2/ApiExtractor/qtdocparser.cpp
+++ b/sources/shiboken2/ApiExtractor/qtdocparser.cpp
@@ -206,18 +206,28 @@ void QtDocParser::fillDocumentation(AbstractMetaClass* metaClass)
}
}
+static QString qmlReferenceLink(const QFileInfo &qmlModuleFi)
+{
+ QString result;
+ QTextStream(&result) << "<para>The module also provides <link"
+ << " type=\"page\""
+ << " page=\"http://doc.qt.io/qt-5/" << qmlModuleFi.baseName() << ".html\""
+ << ">QML types</link>.</para>";
+ return result;
+}
+
Documentation QtDocParser::retrieveModuleDocumentation(const QString& name)
{
// TODO: This method of acquiring the module name supposes that the target language uses
// dots as module separators in package names. Improve this.
QString moduleName = name;
moduleName.remove(0, name.lastIndexOf(QLatin1Char('.')) + 1);
- QString sourceFile = documentationDataDirectory() + QLatin1Char('/')
- + moduleName.toLower() + QLatin1String(".xml");
+ const QString prefix = documentationDataDirectory() + QLatin1Char('/')
+ + moduleName.toLower();
+ QString sourceFile = prefix + QLatin1String(".xml");
if (!QFile::exists(sourceFile))
- sourceFile = documentationDataDirectory() + QLatin1Char('/')
- + moduleName.toLower() + QLatin1String("-module.webxml");
+ sourceFile = prefix + QLatin1String("-module.webxml");
if (!QFile::exists(sourceFile)) {
qCWarning(lcShiboken).noquote().nospace()
<< "Can't find qdoc file for module " << name << ", tried: "
@@ -231,8 +241,22 @@ Documentation QtDocParser::retrieveModuleDocumentation(const QString& name)
// Module documentation
QString query = QLatin1String("/WebXML/document/module[@name=\"")
+ moduleName + QLatin1String("\"]/description");
- const Documentation doc = getDocumentation(xquery, query, DocModificationList());
- if (doc.isEmpty())
+ Documentation doc = getDocumentation(xquery, query, DocModificationList());
+ if (doc.isEmpty()) {
qCWarning(lcShiboken(), "%s", qPrintable(msgCannotFindDocumentation(sourceFile, "module", name, query)));
+ return doc;
+ }
+
+ // If a QML module info file exists, insert a link to the Qt docs.
+ const QFileInfo qmlModuleFi(prefix + QLatin1String("-qmlmodule.webxml"));
+ if (qmlModuleFi.isFile()) {
+ QString docString = doc.value();
+ const int pos = docString.lastIndexOf(QLatin1String("</description>"));
+ if (pos != -1) {
+ docString.insert(pos, qmlReferenceLink(qmlModuleFi));
+ doc.setValue(docString);
+ }
+ }
+
return doc;
}