summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2020-06-04 13:32:01 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-06-04 13:28:13 +0000
commit73385a4d45d0b95e3806f78346755d1b008227b4 (patch)
tree94655f3ea05c78872347de6c422d095b073194f0
parentb7a6b1f290ae6f9dc9922590f8976f355da4913b (diff)
qdoc: Ensure QML method parameter types are generated correctly
QDoc uses a simplified method of parsing the parameters for QML methods and macros. This code had issues, resulting in parameter types being dropped from the output in certain cases. Fixes: QTBUG-84364 Change-Id: I245dd423ab0583ae826594a618d85c2876543077 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit be0ba30d995ac7504d3ec69145ea425d1e68e7df) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qdoc/parameters.cpp28
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-abstractparent.xml4
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-child.xml4
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-type.xml2
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/includefromexampledirs/qml-qdoc-test-abstractparent-members.html2
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/includefromexampledirs/qml-qdoc-test-abstractparent.html6
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-abstractparent.html8
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-child.html8
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-type-members.html2
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-type.html6
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/qml/parent.qdoc4
11 files changed, 31 insertions, 43 deletions
diff --git a/src/qdoc/parameters.cpp b/src/qdoc/parameters.cpp
index 7dfe018f6..736f50483 100644
--- a/src/qdoc/parameters.cpp
+++ b/src/qdoc/parameters.cpp
@@ -458,9 +458,8 @@ QString Parameters::rawSignature(bool names, bool values) const
Parse the parameter \a signature by splitting the string,
and store the individual parameters in the parameter vector.
- This method of parsing the parameter signature probably
- doesn't work for all cases. Investigate doing using the
- more robust way in parse().
+ This method of parsing is naive but sufficient for QML methods
+ and macros.
*/
void Parameters::set(const QString &signature)
{
@@ -468,25 +467,14 @@ void Parameters::set(const QString &signature)
if (!signature.isEmpty()) {
QStringList commaSplit = signature.split(',');
parameters_.resize(commaSplit.size());
- for (int i = 0; i < commaSplit.size(); i++) {
- QStringList blankSplit = commaSplit[i].split(' ');
- QString pName = blankSplit.last();
- blankSplit.removeLast();
- QString pType;
- if (blankSplit.size() > 1)
- pType = blankSplit.join(' ');
+ int i = 0;
+ for (const auto &item : qAsConst(commaSplit)) {
+ QStringList blankSplit = item.split(' ');
+ QString pName = blankSplit.takeLast();
+ QString pType = blankSplit.join(' ');
if (pType.isEmpty() && pName == QLatin1String("..."))
qSwap(pType, pName);
- else {
- int i = 0;
- while (i < pName.length() && !pName.at(i).isLetter())
- i++;
- if (i > 0) {
- pType += QChar(' ') + pName.left(i);
- pName = pName.mid(i);
- }
- }
- parameters_[i].set(pType, pName);
+ parameters_[i++].set(pType, pName);
}
}
}
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-abstractparent.xml b/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-abstractparent.xml
index 111ea3ad9..479b70685 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-abstractparent.xml
+++ b/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-abstractparent.xml
@@ -46,8 +46,8 @@
<db:section xml:id="method-documentation">
<db:title>Method Documentation</db:title>
<db:section xml:id="rear-method">
-<db:title>void rear(<db:emphasis>child</db:emphasis>)</db:title>
-<db:para>Do some abstract parenting on <db:code role="parameter">child</db:code>.</db:para>
+<db:title>void rear(Child <db:emphasis>child</db:emphasis>, var <db:emphasis>method</db:emphasis>)</db:title>
+<db:para>Do some abstract parenting on <db:code role="parameter">child</db:code> using a specific <db:code role="parameter">method</db:code>.</db:para>
</db:section>
</db:section>
</db:article>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-child.xml b/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-child.xml
index ef832021e..657c54d0d 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-child.xml
+++ b/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-child.xml
@@ -46,8 +46,8 @@
<db:section xml:id="method-documentation">
<db:title>Method Documentation</db:title>
<db:section xml:id="rear-method">
-<db:title>void rear(<db:emphasis>child</db:emphasis>)</db:title>
-<db:para>Do some abstract parenting on <db:code role="parameter">child</db:code>.</db:para>
+<db:title>void rear(Child <db:emphasis>child</db:emphasis>, var <db:emphasis>method</db:emphasis>)</db:title>
+<db:para>Do some abstract parenting on <db:code role="parameter">child</db:code> using a specific <db:code role="parameter">method</db:code>.</db:para>
</db:section>
</db:section>
</db:article>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-type.xml b/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-type.xml
index 59ed97a01..32287511b 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-type.xml
+++ b/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-type.xml
@@ -133,7 +133,7 @@
<db:section xml:id="signal-documentation">
<db:title>Signal Documentation</db:title>
<db:section xml:id="completed-signal">
-<db:title>completed(<db:emphasis>status</db:emphasis>)</db:title>
+<db:title>completed(int <db:emphasis>status</db:emphasis>)</db:title>
<db:para>This signal is emitted when the operation completed with <db:code role="parameter">status</db:code>.</db:para>
<db:note>
<db:para>The corresponding handler is <db:code>onCompleted</db:code>.</db:para>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/includefromexampledirs/qml-qdoc-test-abstractparent-members.html b/tests/auto/qdoc/generatedoutput/expected_output/includefromexampledirs/qml-qdoc-test-abstractparent-members.html
index f9d64de75..e8ecfbb69 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/includefromexampledirs/qml-qdoc-test-abstractparent-members.html
+++ b/tests/auto/qdoc/generatedoutput/expected_output/includefromexampledirs/qml-qdoc-test-abstractparent-members.html
@@ -11,7 +11,7 @@
<p>This is the complete list of members for <a href="qml-qdoc-test-abstractparent.html">AbstractParent</a>, including inherited members.</p>
<ul>
<li class="fn"><b><b><a href="qml-qdoc-test-abstractparent.html#children-prop">children</a></b></b> : list&lt;Child&gt; [default]</li>
-<li class="fn">void <b><b><a href="qml-qdoc-test-abstractparent.html#rear-method">rear</a></b></b>(<i>child</i>)</li>
+<li class="fn">void <b><b><a href="qml-qdoc-test-abstractparent.html#rear-method">rear</a></b></b>(Child <i>child</i>)</li>
</ul>
</body>
</html>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/includefromexampledirs/qml-qdoc-test-abstractparent.html b/tests/auto/qdoc/generatedoutput/expected_output/includefromexampledirs/qml-qdoc-test-abstractparent.html
index f7c294ae0..ae0e10d6d 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/includefromexampledirs/qml-qdoc-test-abstractparent.html
+++ b/tests/auto/qdoc/generatedoutput/expected_output/includefromexampledirs/qml-qdoc-test-abstractparent.html
@@ -34,7 +34,7 @@
<a name="methods"></a>
<h2 id="methods">Methods</h2>
<ul>
-<li class="fn">void <b><b><a href="qml-qdoc-test-abstractparent.html#rear-method">rear</a></b></b>(<i>child</i>)</li>
+<li class="fn">void <b><b><a href="qml-qdoc-test-abstractparent.html#rear-method">rear</a></b></b>(Child <i>child</i>)</li>
</ul>
<!-- $$$AbstractParent-description -->
<a name="details"></a>
@@ -54,12 +54,12 @@
</div></div><!-- @@@children -->
<br/>
<h2>Method Documentation</h2>
-<!-- $$$rear[overload1]$$$rear -->
+<!-- $$$rear[overload1]$$$rearChild -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="rear-method">
<td class="tblQmlFuncNode"><p>
-<a name="rear-method"></a><span class="type">void</span> <span class="name">rear</span>(<i>child</i>)</p></td></tr>
+<a name="rear-method"></a><span class="type">void</span> <span class="name">rear</span>(<span class="type"><a href="qml-qdoc-test-child.html">Child</a></span> <i>child</i>)</p></td></tr>
</table></div></div>
<div class="qmldoc"><p>Do some abstract parenting on <i>child</i>.</p>
<p>Test include file that is part of the sourcedirs.</p>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-abstractparent.html b/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-abstractparent.html
index 3668112ee..04fde634b 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-abstractparent.html
+++ b/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-abstractparent.html
@@ -34,7 +34,7 @@
<a name="methods"></a>
<h2 id="methods">Methods</h2>
<ul>
-<li class="fn">void <b><b><a href="qml-qdoc-test-abstractparent.html#rear-method">rear</a></b></b>(<i>child</i>)</li>
+<li class="fn">void <b><b><a href="qml-qdoc-test-abstractparent.html#rear-method">rear</a></b></b>(Child <i>child</i>, var <i>method</i>)</li>
</ul>
<!-- $$$AbstractParent-description -->
<a name="details"></a>
@@ -52,14 +52,14 @@
</div></div><!-- @@@children -->
<br/>
<h2>Method Documentation</h2>
-<!-- $$$rear[overload1]$$$rear -->
+<!-- $$$rear[overload1]$$$rearChildvar -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="rear-method">
<td class="tblQmlFuncNode"><p>
-<a name="rear-method"></a><span class="type">void</span> <span class="name">rear</span>(<i>child</i>)</p></td></tr>
+<a name="rear-method"></a><span class="type">void</span> <span class="name">rear</span>(<span class="type"><a href="qml-qdoc-test-child.html">Child</a></span> <i>child</i>, <span class="type">var</span> <i>method</i>)</p></td></tr>
</table></div></div>
-<div class="qmldoc"><p>Do some abstract parenting on <i>child</i>.</p>
+<div class="qmldoc"><p>Do some abstract parenting on <i>child</i> using a specific <i>method</i>.</p>
</div></div><!-- @@@rear -->
<br/>
</body>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-child.html b/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-child.html
index 22f38cc9c..c21e6e4e8 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-child.html
+++ b/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-child.html
@@ -34,7 +34,7 @@
<a name="methods"></a>
<h2 id="methods">Methods</h2>
<ul>
-<li class="fn">void <b><b><a href="qml-qdoc-test-child.html#rear-method">rear</a></b></b>(<i>child</i>)</li>
+<li class="fn">void <b><b><a href="qml-qdoc-test-child.html#rear-method">rear</a></b></b>(Child <i>child</i>, var <i>method</i>)</li>
</ul>
<!-- $$$Child-description -->
<a name="details"></a>
@@ -52,14 +52,14 @@
</div></div><!-- @@@children -->
<br/>
<h2>Method Documentation</h2>
-<!-- $$$rear[overload1]$$$rear -->
+<!-- $$$rear[overload1]$$$rearChildvar -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="rear-method">
<td class="tblQmlFuncNode"><p>
-<a name="rear-method"></a><span class="type">void</span> <span class="name">rear</span>(<i>child</i>)</p></td></tr>
+<a name="rear-method"></a><span class="type">void</span> <span class="name">rear</span>(<span class="type"><a href="qml-qdoc-test-child.html">Child</a></span> <i>child</i>, <span class="type">var</span> <i>method</i>)</p></td></tr>
</table></div></div>
-<div class="qmldoc"><p>Do some abstract parenting on <i>child</i>.</p>
+<div class="qmldoc"><p>Do some abstract parenting on <i>child</i> using a specific <i>method</i>.</p>
</div></div><!-- @@@rear -->
<br/>
</body>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-type-members.html b/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-type-members.html
index 91cfa8643..c3866cc66 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-type-members.html
+++ b/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-type-members.html
@@ -21,7 +21,7 @@
<li class="fn"><b><b><a href="qml-qdoc-test-type.html#id-prop">id</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qdoc-test-type.html#name-prop">name</a></b></b> : string</li>
<li class="fn"><b><b><a href="qml-qdoc-test-type.html#type-attached-prop">type</a></b></b> : enumeration [attached]</li>
-<li class="fn"><b><b><a href="qml-qdoc-test-type.html#completed-signal">completed</a></b></b>(<i>status</i>)</li>
+<li class="fn"><b><b><a href="qml-qdoc-test-type.html#completed-signal">completed</a></b></b>(int <i>status</i>)</li>
<li class="fn"><b><b><a href="qml-qdoc-test-type.html#configured-signal">configured</a></b></b>() [attached]</li>
<li class="fn">Type <b><b><a href="qml-qdoc-test-type.html#copy-method">copy</a></b></b>(<i>a</i>)</li>
<li class="fn"><b><b><a href="qml-qdoc-test-type.html#disable-method">disable</a></b></b>()</li>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-type.html b/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-type.html
index f18e97082..21d07d25f 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-type.html
+++ b/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-type.html
@@ -50,7 +50,7 @@
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<ul>
-<li class="fn"><b><b><a href="qml-qdoc-test-type.html#completed-signal">completed</a></b></b>(<i>status</i>)</li>
+<li class="fn"><b><b><a href="qml-qdoc-test-type.html#completed-signal">completed</a></b></b>(int <i>status</i>)</li>
</ul>
<a name="attached-signals"></a>
<h2 id="attached-signals">Attached Signals</h2>
@@ -135,12 +135,12 @@
</div></div><!-- @@@type -->
<br/>
<h2>Signal Documentation</h2>
-<!-- $$$completed[overload1]$$$completed -->
+<!-- $$$completed[overload1]$$$completedint -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="completed-signal">
<td class="tblQmlFuncNode"><p>
-<a name="completed-signal"></a><span class="name">completed</span>(<i>status</i>)</p></td></tr>
+<a name="completed-signal"></a><span class="name">completed</span>(<span class="type"><a href="qml-int.html">int</a></span> <i>status</i>)</p></td></tr>
</table></div></div>
<div class="qmldoc"><p>This signal is emitted when the operation completed with <i>status</i>.</p>
<p><b>Note: </b>The corresponding handler is <code>onCompleted</code>.</p>
diff --git a/tests/auto/qdoc/generatedoutput/testdata/qml/parent.qdoc b/tests/auto/qdoc/generatedoutput/testdata/qml/parent.qdoc
index fed18491c..a2842f0d6 100644
--- a/tests/auto/qdoc/generatedoutput/testdata/qml/parent.qdoc
+++ b/tests/auto/qdoc/generatedoutput/testdata/qml/parent.qdoc
@@ -40,8 +40,8 @@
*/
/*!
- \qmlmethod void AbstractParent::rear(Child child)
- \brief Do some abstract parenting on \a child.
+ \qmlmethod void AbstractParent::rear(Child child, var method)
+ \brief Do some abstract parenting on \a child using a specific \a method.
*/
/*!