aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-04-22 16:35:30 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-04-23 12:30:44 +0200
commitdce969be54a83dd42d10774f0d4d49b37f8b87b1 (patch)
treece89483e1bd747c4158b346c10efec323921e804
parent20a32f1a19b063da502926f477fbf2085542d7c0 (diff)
shiboken6: Fix injecting documentation for added functions with parameter names
Strip the parameter names from the modification signature so that it matches the C++ type signature. Change-Id: I8ca4e124e3c579d222d52f949f0d01b44eae92bf Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/shiboken6/ApiExtractor/modifications.cpp26
-rw-r--r--sources/shiboken6/ApiExtractor/modifications.h6
2 files changed, 28 insertions, 4 deletions
diff --git a/sources/shiboken6/ApiExtractor/modifications.cpp b/sources/shiboken6/ApiExtractor/modifications.cpp
index 263b1d3ac..e7d0aa8a1 100644
--- a/sources/shiboken6/ApiExtractor/modifications.cpp
+++ b/sources/shiboken6/ApiExtractor/modifications.cpp
@@ -436,6 +436,32 @@ AddedFunction::AddedFunctionPtr
return result;
}
+// Remove the parameter names enclosed in '@' from an added function signature
+// so that it matches the C++ type signature.
+static QString removeParameterNames(QString signature)
+{
+ while (true) {
+ const auto ampPos = signature.indexOf(u'@');
+ if (ampPos == -1)
+ break;
+ const auto closingAmpPos = signature.indexOf(u'@', ampPos + 1);
+ if (closingAmpPos == -1)
+ break;
+ signature.remove(ampPos, closingAmpPos - ampPos + 1);
+ }
+ return signature;
+}
+
+DocModification::DocModification(const QString &xpath, const QString &signature) :
+ m_xpath(xpath), m_signature(removeParameterNames(signature))
+{
+}
+
+DocModification::DocModification(TypeSystem::DocModificationMode mode, const QString &signature) :
+ m_signature(removeParameterNames(signature)), m_mode(mode)
+{
+}
+
void DocModification::setCode(const QString &code)
{
m_code = CodeSnipAbstract::fixSpaces(code);
diff --git a/sources/shiboken6/ApiExtractor/modifications.h b/sources/shiboken6/ApiExtractor/modifications.h
index 15c1c02f3..79b32c035 100644
--- a/sources/shiboken6/ApiExtractor/modifications.h
+++ b/sources/shiboken6/ApiExtractor/modifications.h
@@ -523,10 +523,8 @@ class DocModification
{
public:
DocModification() = default;
- explicit DocModification(const QString& xpath, const QString& signature) :
- m_xpath(xpath), m_signature(signature) {}
- explicit DocModification(TypeSystem::DocModificationMode mode, const QString& signature) :
- m_signature(signature), m_mode(mode) {}
+ explicit DocModification(const QString& xpath, const QString& signature);
+ explicit DocModification(TypeSystem::DocModificationMode mode, const QString& signature);
void setCode(const QString& code);
void setCode(QStringView code) { setCode(code.toString()); }