aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/classdocumentation.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-12-12 08:26:18 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-12-19 12:29:45 +0100
commit1e2f45da078e36487c3bb9bd0d63f67a29ef3f3d (patch)
treebfdda4ce8c392f6c68f38ef7fdb147ac65be1053 /sources/shiboken6/ApiExtractor/classdocumentation.cpp
parentad5eb64daaaa1b927bcbf9e568738f417fef845f (diff)
Documentation: Adapt struct ClassDocumentation for header documents
Global functions and enumeration appear as WebXml documents with a <header> element instead of class <class>. Extend the ClassDocumentation and its parse to represent that. Change the parsing to return an optional and remove the operator bool. Task-number: PYSIDE-1106 Change-Id: I2e0413904dd8a5859aa9ed2aea9522aa5f24e939 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/classdocumentation.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/classdocumentation.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/sources/shiboken6/ApiExtractor/classdocumentation.cpp b/sources/shiboken6/ApiExtractor/classdocumentation.cpp
index 2008d83d2..8c1297593 100644
--- a/sources/shiboken6/ApiExtractor/classdocumentation.cpp
+++ b/sources/shiboken6/ApiExtractor/classdocumentation.cpp
@@ -85,7 +85,7 @@ qsizetype ClassDocumentation::indexOfProperty(const QString &name) const
enum class WebXmlTag
{
- Class, Description, Enum, Function, Parameter, Property, Typedef, Other
+ Class, Description, Enum, Function, Header, Parameter, Property, Typedef, Other
};
static WebXmlTag tag(QStringView name)
@@ -98,6 +98,8 @@ static WebXmlTag tag(QStringView name)
return WebXmlTag::Function;
if (name == u"description")
return WebXmlTag::Description;
+ if (name == u"header")
+ return WebXmlTag::Header;
if (name == u"parameter")
return WebXmlTag::Parameter;
if (name == u"property")
@@ -113,6 +115,11 @@ static void parseWebXmlElement(WebXmlTag tag, const QXmlStreamAttributes &attrib
switch (tag) {
case WebXmlTag::Class:
cd->name = attributes.value(u"name"_s).toString();
+ cd->type = ClassDocumentation::Class;
+ break;
+ case WebXmlTag::Header:
+ cd->name = attributes.value(u"name"_s).toString();
+ cd->type = ClassDocumentation::Header;
break;
case WebXmlTag::Enum: {
EnumDocumentation ed;
@@ -185,14 +192,14 @@ static QString msgXmlError(const QString &fileName, const QXmlStreamReader &read
return result;
}
-ClassDocumentation parseWebXml(const QString &fileName, QString *errorMessage)
+std::optional<ClassDocumentation> parseWebXml(const QString &fileName, QString *errorMessage)
{
ClassDocumentation result;
QFile file(fileName);
if (!file.open(QIODevice::Text | QIODevice::ReadOnly)) {
*errorMessage = msgCannotOpenForReading(file);
- return result;
+ return std::nullopt;
}
WebXmlTag lastTag = WebXmlTag::Other;
@@ -206,6 +213,7 @@ ClassDocumentation parseWebXml(const QString &fileName, QString *errorMessage)
case WebXmlTag::Class:
case WebXmlTag::Function:
case WebXmlTag::Enum:
+ case WebXmlTag::Header:
case WebXmlTag::Property:
case WebXmlTag::Typedef:
lastTag = currentTag;
@@ -242,7 +250,7 @@ ClassDocumentation parseWebXml(const QString &fileName, QString *errorMessage)
if (reader.error() != QXmlStreamReader::NoError) {
*errorMessage= msgXmlError(fileName, reader);
- return {};
+ return std::nullopt;
}
sortDocumentation(&result);
@@ -363,16 +371,11 @@ QDebug operator<<(QDebug debug, const ClassDocumentation &c)
QDebugStateSaver saver(debug);
debug.noquote();
debug.nospace();
- debug << "Class(";
- if (c) {
- debug << c.name << ", ";
- formatDescription(debug, c.description);
- formatList(debug, ", enums", c.enums);
- formatList(debug, ", properties", c.properties);
- formatList(debug, ", functions", c.functions);
- } else {
- debug << "invalid";
- }
+ debug << "Class(" << c.name << ", ";
+ formatDescription(debug, c.description);
+ formatList(debug, ", enums", c.enums);
+ formatList(debug, ", properties", c.properties);
+ formatList(debug, ", functions", c.functions);
debug << ')';
return debug;
}