diff options
author | Topi Reinio <topi.reinio@qt.io> | 2020-05-06 13:08:08 +0200 |
---|---|---|
committer | Cherry-pick Bot <cherrypickbot@codereview.qt-project.org> | 2020-05-06 12:50:10 +0000 |
commit | c7755a190ec9484ff97804de75d484e0a1d20cef (patch) | |
tree | a0824472dbba50adf020fb309dc3de02cd6eb046 | |
parent | ceb313d955294db3cd43a30bcd0bb56674868d62 (diff) |
qdoc: Fix parsing of QML signals that take parameters
The signature of a QML signal can resemble that of a method, so we
need to parse it as such.
Fixes: QTBUG-84034
Change-Id: I8506cd3c2cb469053c750ef6d2335cd1b85c3f1a
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
(cherry picked from commit 87cffaf9ed4022ac05d3a91d9f26ed1415bdecf6)
Reviewed-by: Cherry-pick Bot
5 files changed, 59 insertions, 1 deletions
diff --git a/src/qdoc/qmlvisitor.cpp b/src/qdoc/qmlvisitor.cpp index aac45dd43..d91d3036d 100644 --- a/src/qdoc/qmlvisitor.cpp +++ b/src/qdoc/qmlvisitor.cpp @@ -188,7 +188,7 @@ bool QmlDocVisitor::applyDocumentation(QQmlJS::SourceLocation location, Node *no } } else qDebug() << " FAILED TO PARSE QML OR JS PROPERTY:" << topic << args; - } else if (topic.endsWith(QLatin1String("method"))) { + } else if (topic.endsWith(QLatin1String("method")) || topic == COMMAND_QMLSIGNAL) { if (node->isFunction()) { FunctionNode *fn = static_cast<FunctionNode *>(node); QmlSignatureParser qsp(fn, args, doc.location()); diff --git a/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-doctest.xml b/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-doctest.xml index b3904a048..23ad2c40c 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-doctest.xml +++ b/tests/auto/qdoc/generatedoutput/expected_output/docbook/qml-qdoc-test-doctest.xml @@ -65,6 +65,22 @@ </db:programlisting> </db:section> </db:section> +<db:section xml:id="signal-documentation"> +<db:title>Signal Documentation</db:title> +<db:section xml:id="completed-signal"> +<db:title>completed()</db:title> +<db:note> +<db:para>The corresponding handler is <db:code>onCompleted</db:code>.</db:para> +</db:note> +</db:section> +<db:section xml:id="foo-signal"> +<db:title>foo(var <db:emphasis>bar</db:emphasis>)</db:title> +<db:para>Signal with parameter <db:code role="parameter">bar</db:code>.</db:para> +<db:note> +<db:para>The corresponding handler is <db:code>onFoo</db:code>.</db:para> +</db:note> +</db:section> +</db:section> <db:section xml:id="method-documentation"> <db:title>Method Documentation</db:title> <db:section xml:id="fail-method"> diff --git a/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-doctest.html b/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-doctest.html index e1475d5fb..29ee16b1f 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-doctest.html +++ b/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-doctest.html @@ -11,6 +11,7 @@ <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#properties">Properties</a></li> +<li class="level1"><a href="#signals">Signals</a></li> <li class="level1"><a href="#methods">Methods</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> <li class="level2"><a href="#introduction">Introduction</a></li> @@ -32,6 +33,12 @@ <li class="fn"><b><b><a href="qml-qdoc-test-doctest.html#active-prop">active</a></b></b> : bool</li> <li class="fn"><b><b><a href="qml-qdoc-test-doctest.html#name-prop">name</a></b></b> : string</li> </ul> +<a name="signals"></a> +<h2 id="signals">Signals</h2> +<ul> +<li class="fn"><b><b><a href="qml-qdoc-test-doctest.html#completed-signal">completed</a></b></b>()</li> +<li class="fn"><b><b><a href="qml-qdoc-test-doctest.html#foo-signal">foo</a></b></b>(var <i>bar</i>)</li> +</ul> <a name="methods"></a> <h2 id="methods">Methods</h2> <ul> @@ -70,6 +77,28 @@ }</pre> </div></div><!-- @@@name --> <br/> +<h2>Signal Documentation</h2> +<!-- $$$completed[overload1]$$$completed --> +<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>()</p></td></tr> +</table></div></div> +<div class="qmldoc"><p><b>Note: </b>The corresponding handler is <code>onCompleted</code>.</p> +</div></div><!-- @@@completed --> +<br/> +<!-- $$$foo[overload1]$$$foovar --> +<div class="qmlitem"><div class="qmlproto"> +<div class="table"><table class="qmlname"> +<tr valign="top" class="odd" id="foo-signal"> +<td class="tblQmlFuncNode"><p> +<a name="foo-signal"></a><span class="name">foo</span>(<span class="type">var</span> <i>bar</i>)</p></td></tr> +</table></div></div> +<div class="qmldoc"><p>Signal with parameter <i>bar</i>.</p> +<p><b>Note: </b>The corresponding handler is <code>onFoo</code>.</p> +</div></div><!-- @@@foo --> +<br/> <h2>Method Documentation</h2> <!-- $$$fail[overload1]$$$fail --> <div class="qmlitem"><div class="qmlproto"> diff --git a/tests/auto/qdoc/generatedoutput/expected_output/test.qhp b/tests/auto/qdoc/generatedoutput/expected_output/test.qhp index 387e018ae..5f0d0d8cd 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/test.qhp +++ b/tests/auto/qdoc/generatedoutput/expected_output/test.qhp @@ -70,6 +70,7 @@ <keyword name="anotherObsoleteMember" id="Test::anotherObsoleteMember" ref="testqdoc-test-obsolete.html#anotherObsoleteMember"/> <keyword name="children" id="AbstractParent::children" ref="qml-qdoc-test-abstractparent.html#children-prop"/> <keyword name="color" id="ProgressBar::color" ref="qml-uicomponents-progressbar.html#color-prop"/> + <keyword name="completed" id="DocTest::completed" ref="qml-qdoc-test-doctest.html#completed-signal"/> <keyword name="completed" id="Type::completed" ref="qml-qdoc-test-type.html#completed-signal"/> <keyword name="configured" id="Type::configured" ref="qml-qdoc-test-type.html#configured-signal"/> <keyword name="copy" id="Type::copy" ref="qml-qdoc-test-type.html#copy-method"/> @@ -79,6 +80,7 @@ <keyword name="enable" id="Type::enable" ref="qml-qdoc-test-type.html#enable-method"/> <keyword name="fail" id="DocTest::fail" ref="qml-qdoc-test-doctest.html#fail-method"/> <keyword name="fifth" id="Type::fifth" ref="qml-qdoc-test-type.html#fifth-prop"/> + <keyword name="foo" id="DocTest::foo" ref="qml-qdoc-test-doctest.html#foo-signal"/> <keyword name="fourth" id="Type::fourth" ref="qml-qdoc-test-type.html#fourth-prop"/> <keyword name="group.first" id="Type::group.first" ref="qml-qdoc-test-type.html#group.first-prop"/> <keyword name="group.second" id="Type::group.second" ref="qml-qdoc-test-type.html#group.second-prop"/> diff --git a/tests/auto/qdoc/generatedoutput/testdata/qml/DocTest.qml b/tests/auto/qdoc/generatedoutput/testdata/qml/DocTest.qml index 1ddafcfe4..2e581335e 100644 --- a/tests/auto/qdoc/generatedoutput/testdata/qml/DocTest.qml +++ b/tests/auto/qdoc/generatedoutput/testdata/qml/DocTest.qml @@ -43,6 +43,17 @@ Item { id: testCase /*! + \qmlsignal QDocTest::completed + */ + signal completed + + /*! + \qmlsignal DocTest::test(var bar) + Signal with parameter \a bar. + */ + signal foo(var bar) + + /*! \qmlproperty string DocTest::name Name of the test. |