summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2022-12-09 11:43:02 +0000
committerTopi Reiniƶ <topi.reinio@qt.io>2022-12-12 08:11:16 +0000
commit404821bbdee8d885d60b18d3b11ad11b2bcdfd30 (patch)
treeef3164c6b419098630edb5764ca5f4c4896e6b25 /tests
parentf003dd86a9b7a6edea2d0266ba8284871c480dd8 (diff)
downloadqttools-404821bbdee8d885d60b18d3b11ad11b2bcdfd30.tar.gz
qdoc: Avoid invalid links generated for QML value types
In .index files, a 'qml-module-name' attribute was incorrectly added for QML (value) types that did not use the \inqmlmodule command. Instead of omitting the attribute, its value was set to the name of the type itself. This caused incorrect linking to "<type>-qmlmodule.html" in some cases. Drop the attribute for QML types that do not provide the module information. Also drop it for QML modules as it's duplicate information to the 'name' attribute. Add a test for ensuring that autolinking to QML types loaded from .index works correctly. Pick-to: 6.4 Change-Id: Idb00999774eb2411f406148011e4542d8038c6cd Reviewed-by: Luca Di Sera <luca.disera@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/index-linking.html10
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/properties/testcpp.index4
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/indexlinking/linking.qdoc16
3 files changed, 28 insertions, 2 deletions
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/index-linking.html b/tests/auto/qdoc/generatedoutput/expected_output/index-linking.html
index 09d3ef0fd..694a3f061 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/index-linking.html
+++ b/tests/auto/qdoc/generatedoutput/expected_output/index-linking.html
@@ -11,6 +11,7 @@
<h3 id="toc">Contents</h3>
<ul>
<li class="level1"><a href="#qml-properties">QML properties</a></li>
+<li class="level1"><a href="#auto-linking-to-types-in-code-snippets">Auto-linking to types in code snippets</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
@@ -21,6 +22,15 @@
<ol class="A" type="A"><li>Property group: <a href="https://doc.qt.io/QmlPropertyGroups/qml-qdoc-test-parent.html#group-prop" translate="no">Parent::group</a>.</li>
<li>Property in a group: <a href="https://doc.qt.io/QmlPropertyGroups/qml-qdoc-test-parent.html#group.c-prop" translate="no">QDoc.Test::Parent::group.c</a>.</li>
</ol>
+<h2 id="auto-linking-to-types-in-code-snippets">Auto-linking to types in code snippets</h2>
+<pre class="qml" translate="no">import QtQuick
+
+<span class="type"><a href="https://doc.qt.io/QmlPropertyGroups/qml-uicomponents-progressbar.html" translate="no">ProgressBar</a></span> {
+ <span class="comment">// Linking to int value type</span>
+ property <span class="type"><a href="https://doc.qt.io/QmlPropertyGroups/qml-int.html" translate="no">int</a></span> <span class="name">progress</span>: <span class="number">0</span>
+}</pre>
+<pre class="cpp" translate="no"><span class="comment">// 'int' should not link anywhere in C++ code</span>
+<span class="type">int</span> main() { <span class="type">int</span> x{<span class="number">0</span>}; <span class="keyword">return</span> x; }</pre>
</div>
<!-- @@@index-linking.html -->
</body>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/properties/testcpp.index b/tests/auto/qdoc/generatedoutput/expected_output/properties/testcpp.index
index 8a9d8c067..3a7ea6d8b 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/properties/testcpp.index
+++ b/tests/auto/qdoc/generatedoutput/expected_output/properties/testcpp.index
@@ -105,7 +105,7 @@
</property>
</class>
</namespace>
- <qmlclass name="TheType" qml-module-name="TheType" href="qml-thetype.html" status="active" access="public" location="properties.qdoc" documented="true" title="TheType" fulltitle="TheType" subtitle="">
+ <qmlclass name="TheType" href="qml-thetype.html" status="active" access="public" location="properties.qdoc" documented="true" title="TheType" fulltitle="TheType" subtitle="">
<qmlproperty name="name" fullname="TheType::name" href="qml-thetype.html#name-prop" status="active" access="public" location="properties.qdoc" documented="true" type="string" attached="false" writable="false" brief="Read-only status of this property is resolved from Q_PROPERTY"/>
</qmlclass>
<group name="cpptypes" href="cpptypes.html" status="active" location="classlists.qdoc" documented="true" seen="true" title="Test C++ Types"/>
@@ -114,6 +114,6 @@
<contents name="linking-to-function-like-things" title="Linking to function-like things" level="1"/>
<contents name="section" title="section()" level="2"/>
</module>
- <qmlmodule name="TheModule" qml-module-name="TheModule" href="themodule-qmlmodule.html" status="internal" seen="false" title=""/>
+ <qmlmodule name="TheModule" href="themodule-qmlmodule.html" status="internal" seen="false" title=""/>
</namespace>
</INDEX>
diff --git a/tests/auto/qdoc/generatedoutput/testdata/indexlinking/linking.qdoc b/tests/auto/qdoc/generatedoutput/testdata/indexlinking/linking.qdoc
index d65f2ef68..fe60bc7a6 100644
--- a/tests/auto/qdoc/generatedoutput/testdata/indexlinking/linking.qdoc
+++ b/tests/auto/qdoc/generatedoutput/testdata/indexlinking/linking.qdoc
@@ -11,6 +11,22 @@
\li Property in a group: \l [QmlPropertyGroups]
QDoc.Test::Parent::group.c.
\endlist
+
+ \section1 Auto-linking to types in code snippets
+
+ \qml
+ import QtQuick
+
+ ProgressBar {
+ // Linking to int value type
+ property int progress: 0
+ }
+ \endqml
+
+ \code
+ // 'int' should not link anywhere in C++ code
+ int main() { int x{0}; return x; }
+ \endcode
*/
/*!