diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-11-28 08:56:15 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-11-28 14:30:17 +0100 |
| commit | 4e779d0e361ba455479f868f73b52b62e4b82be7 (patch) | |
| tree | 48b6a44b4acc3ef8e4309aa6e2522005bd0be729 /sources/shiboken6/ApiExtractor/classdocumentation.cpp | |
| parent | 05b3c28099c1eaff74bba8b06004cc8205b24f45 (diff) | |
shiboken6: Add a documentation file hint to complex type entries
Complements ad5eb64daaaa1b927bcbf9e568738f417fef845f.
Add a doc-file attribute to complex type entries
(object/value/namespaces) like it was done for enums and free
functions by ad5eb64daaaa1b927bcbf9e568738f417fef845f.
This is mainly intended for namespaces that can be extended by other
modules.
Change the functions to parse WebXML to accept lists of files. Improve
the error message about not finding qdoc files.
Pick-to: 6.8
Task-number: PYSIDE-2918
Task-number: PYSIDE-1106
Change-Id: I2811e0715b7f44a4461876019580295f5af4ea06
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/classdocumentation.cpp')
| -rw-r--r-- | sources/shiboken6/ApiExtractor/classdocumentation.cpp | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/sources/shiboken6/ApiExtractor/classdocumentation.cpp b/sources/shiboken6/ApiExtractor/classdocumentation.cpp index 2f92b2e3c..199d6992a 100644 --- a/sources/shiboken6/ApiExtractor/classdocumentation.cpp +++ b/sources/shiboken6/ApiExtractor/classdocumentation.cpp @@ -195,23 +195,15 @@ static QString msgXmlError(const QString &fileName, const QXmlStreamReader &read return result; } -std::optional<ClassDocumentation> parseWebXml(const QString &fileName, QString *errorMessage) +static bool parseWebXmlHelper(QFile *file, ClassDocumentation *result, QString *errorMessage) { - ClassDocumentation result; - - QFile file(fileName); - if (!file.open(QIODevice::Text | QIODevice::ReadOnly)) { - *errorMessage = msgCannotOpenForReading(file); - return std::nullopt; - } - WebXmlCodeTag lastTag = WebXmlCodeTag::Other; - QXmlStreamReader reader(&file); + QXmlStreamReader reader(file); while (!reader.atEnd()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement: { const auto currentTag = tag(reader.name()); - parseWebXmlElement(currentTag, reader.attributes(), &result); + parseWebXmlElement(currentTag, reader.attributes(), result); switch (currentTag) { // Store relevant tags in lastTag case WebXmlCodeTag::Class: case WebXmlCodeTag::Function: @@ -225,16 +217,16 @@ std::optional<ClassDocumentation> parseWebXml(const QString &fileName, QString * QString *target = nullptr; switch (lastTag) { case WebXmlCodeTag::Class: - target = &result.description; + target = &result->description; break; case WebXmlCodeTag::Function: - target = &result.functions.last().description; + target = &result->functions.last().description; break; case WebXmlCodeTag::Enum: - target = &result.enums.last().description; + target = &result->enums.last().description; break; case WebXmlCodeTag::Property: - target = &result.properties.last().description; + target = &result->properties.last().description; default: break; } @@ -252,8 +244,24 @@ std::optional<ClassDocumentation> parseWebXml(const QString &fileName, QString * } if (reader.error() != QXmlStreamReader::NoError) { - *errorMessage= msgXmlError(fileName, reader); - return std::nullopt; + *errorMessage= msgXmlError(file->fileName(), reader); + return false; + } + + return result; +} + +std::optional<ClassDocumentation> parseWebXml(const QStringList &fileNames, QString *errorMessage) +{ + ClassDocumentation result; + for (const auto &fileName : fileNames) { + QFile file(fileName); + if (!file.open(QIODevice::Text | QIODevice::ReadOnly)) { + *errorMessage = msgCannotOpenForReading(file); + return std::nullopt; + } + if (!parseWebXmlHelper(&file, &result, errorMessage)) + return std::nullopt; } sortDocumentation(&result); |
