diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-06-05 10:27:11 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-09-05 09:34:39 +0200 |
| commit | 752c1161d75f8c01e2c6c6b07ba02e9a62e65b10 (patch) | |
| tree | 98ee15ed2be45f1ec29a8f5fba48a270fd07fc41 | |
| parent | 9b0dc50ff1e8d5234eac94263659c68c2cb9524f (diff) | |
Documentation: Adapt paths for 6.8
Adapt to qttools/c51980bb0d9658f2ade4de1900d07b08e88cb52d.
Task-number: QTBUG-77650
Task-number: PYSIDE-2620
Change-Id: Icc083c9b3d768093f45caa5d7a3c54aec5eb2d4f
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| -rw-r--r-- | sources/pyside6/doc/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | sources/pyside6/doc/qdoc_spawner.py.in | 2 | ||||
| -rw-r--r-- | sources/shiboken6/ApiExtractor/qtdocparser.cpp | 37 | ||||
| -rw-r--r-- | sources/shiboken6/ApiExtractor/qtdocparser.h | 2 | ||||
| -rw-r--r-- | sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp | 7 | ||||
| -rw-r--r-- | sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp | 9 |
6 files changed, 47 insertions, 12 deletions
diff --git a/sources/pyside6/doc/CMakeLists.txt b/sources/pyside6/doc/CMakeLists.txt index 4cc4f2e8e..73f305c25 100644 --- a/sources/pyside6/doc/CMakeLists.txt +++ b/sources/pyside6/doc/CMakeLists.txt @@ -246,7 +246,7 @@ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${DOC_BASE_DIR}/PySide6/Q --api-version=${SUPPORTED_QT_VERSION} --typesystem-paths="${QDOC_TYPESYSTEM_PATH}" --library-source-dir=${QT_SRC_DIR} - --documentation-data-dir=${DOC_DATA_DIR}/webxml + --documentation-data-dir=${DOC_DATA_DIR} --output-directory=${CMAKE_CURRENT_BINARY_DIR}/${DOC_BASE_DIR} --documentation-code-snippets-dir=${CODE_SNIPPET_ROOT} --snippets-path-rewrite=${QT_ROOT_PATH}:${CODE_SNIPPET_ROOT} diff --git a/sources/pyside6/doc/qdoc_spawner.py.in b/sources/pyside6/doc/qdoc_spawner.py.in index d9d434366..59c6e8f2a 100644 --- a/sources/pyside6/doc/qdoc_spawner.py.in +++ b/sources/pyside6/doc/qdoc_spawner.py.in @@ -81,7 +81,7 @@ if __name__ == "__main__": args = parser.parse_args() - core_index = Path(args.doc_data_dir) / "webxml" / "qtcore-index.webxml" + core_index = Path(args.doc_data_dir) / "qtcore" / "webxml" / "qtcore-index.webxml" if core_index.is_file(): print(f"qdoc_spawner: {core_index} already exists, bailing out") sys.exit(0) diff --git a/sources/shiboken6/ApiExtractor/qtdocparser.cpp b/sources/shiboken6/ApiExtractor/qtdocparser.cpp index 120422182..b72de8b9c 100644 --- a/sources/shiboken6/ApiExtractor/qtdocparser.cpp +++ b/sources/shiboken6/ApiExtractor/qtdocparser.cpp @@ -37,6 +37,27 @@ Documentation QtDocParser::retrieveModuleDocumentation() return retrieveModuleDocumentation(packageName()); } +// Return the qdoc dir "PySide6.QtGui.QPainter" -> "qtgui/webxml" (QTBUG-119500) +QString QtDocParser::qdocModuleDir(const QString &pythonType) +{ + QString package = pythonType; + if (package.startsWith("PySide6."_L1)) + package.remove(0, 8); + auto dot = package.indexOf(u'.'); + if (dot != -1) + package.truncate(dot); + return package.toLower() + "/webxml"_L1; +} + +static QString xmlFileNameRoot(const AbstractMetaClassPtr &metaClass) +{ + QString className = metaClass->qualifiedCppName().toLower(); + className.replace("::"_L1, "-"_L1); + + return QtDocParser::qdocModuleDir(metaClass->typeEntry()->targetLangPackage()) + + u'/' + className; +} + static void formatPreQualifications(QTextStream &str, const AbstractMetaType &type) { if (type.isConstant()) @@ -208,12 +229,15 @@ static QString extractBrief(QString *value) // Find the webxml file for global functions/enums // by the doc-file typesystem attribute or via include file. static QString findGlobalWebXmLFile(const QString &documentationDataDirectory, + const QString &package, const QString &docFile, const Include &include) { QString result; + const QString root = documentationDataDirectory + u'/' + + QtDocParser::qdocModuleDir(package) + u'/'; if (!docFile.isEmpty()) { - result = documentationDataDirectory + u'/' + docFile; + result = root + docFile; if (!result.endsWith(webxmlSuffix)) result += webxmlSuffix; return QFileInfo::exists(result) ? result : QString{}; @@ -221,8 +245,7 @@ static QString findGlobalWebXmLFile(const QString &documentationDataDirectory, if (include.name().isEmpty()) return {}; // qdoc "\headerfile <QtLogging>" directive produces "qtlogging.webxml" - result = documentationDataDirectory + u'/' + - QFileInfo(include.name()).baseName() + webxmlSuffix; + result = root + QFileInfo(include.name()).baseName() + webxmlSuffix; if (QFileInfo::exists(result)) return result; // qdoc "\headerfile <qdrawutil.h>" produces "qdrawutil-h.webxml" @@ -237,7 +260,7 @@ void QtDocParser::fillGlobalFunctionDocumentation(const AbstractMetaFunctionPtr return; const QString sourceFileName = - findGlobalWebXmLFile(documentationDataDirectory(), te->docFile(), te->include()); + findGlobalWebXmLFile(documentationDataDirectory(), te->targetLangPackage(), te->docFile(), te->include()); if (sourceFileName.isEmpty()) return; @@ -260,7 +283,7 @@ void QtDocParser::fillGlobalEnumDocumentation(AbstractMetaEnum &e) { auto te = e.typeEntry(); const QString sourceFileName = - findGlobalWebXmLFile(documentationDataDirectory(), te->docFile(), te->include()); + findGlobalWebXmLFile(documentationDataDirectory(), te->targetLangPackage(), te->docFile(), te->include()); if (sourceFileName.isEmpty()) return; @@ -288,9 +311,7 @@ void QtDocParser::fillDocumentation(const AbstractMetaClassPtr &metaClass) context = context->enclosingClass(); } - QString sourceFileRoot = documentationDataDirectory() + u'/' - + metaClass->qualifiedCppName().toLower(); - sourceFileRoot.replace(u"::"_s, u"-"_s); + QString sourceFileRoot = documentationDataDirectory() + u'/' + xmlFileNameRoot(metaClass); QFileInfo sourceFile(sourceFileRoot + webxmlSuffix); if (!sourceFile.exists()) diff --git a/sources/shiboken6/ApiExtractor/qtdocparser.h b/sources/shiboken6/ApiExtractor/qtdocparser.h index f6ba5e47a..74c042a66 100644 --- a/sources/shiboken6/ApiExtractor/qtdocparser.h +++ b/sources/shiboken6/ApiExtractor/qtdocparser.h @@ -19,6 +19,8 @@ public: Documentation retrieveModuleDocumentation() override; Documentation retrieveModuleDocumentation(const QString& name) override; + static QString qdocModuleDir(const QString &pythonType); + private: static QString functionDocumentation(const QString &sourceFileName, const ClassDocumentation &classDocumentation, diff --git a/sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp b/sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp index 9cf2e0cc7..3858ab0ce 100644 --- a/sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp +++ b/sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp @@ -47,8 +47,13 @@ R"(<typesystem package="Foo"> // cannot handle Qt resources. QTemporaryDir tempDir(QDir::tempPath() + u"/shiboken_testmodifydocXXXXXX"_s); QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString())); + constexpr auto docDir = "foo/webxml/"_L1; constexpr auto docFileName = "a.xml"_L1; - QVERIFY(QFile::copy(u":/"_s + docFileName, tempDir.filePath(docFileName))); + { + QDir dir(tempDir.path()); + QVERIFY(dir.mkpath(docDir)); + } + QVERIFY(QFile::copy(u":/"_s + docFileName, tempDir.path() + u'/' + docDir + u'/' + docFileName)); QtDocParser docParser; docParser.setDocumentationDataDirectory(tempDir.path()); diff --git a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp index 98db5e96c..a68d5d276 100644 --- a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp @@ -1565,7 +1565,14 @@ QtXmlToSphinxLink QtDocGenerator::resolveLink(const QtXmlToSphinxLink &link) con QtXmlToSphinxDocGeneratorInterface::Image QtDocGenerator::resolveImage(const QString &href, const QString &context) const { - const QString &relativeSourceDir = href; + QString relativeSourceDir; + // FIXME PYSIDE 7: Is the doxygen code path still needed? + if (!m_options.doxygen) + relativeSourceDir = QtDocParser::qdocModuleDir(context); + if (!relativeSourceDir.isEmpty()) + relativeSourceDir += u'/'; + relativeSourceDir += href; + const QString source = m_options.parameters.docDataDir + u'/' + relativeSourceDir; if (!QFileInfo::exists(source)) throw Exception(msgCannotFindImage(href, context,source)); |
