summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2023-03-16 19:42:17 +0000
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-03-17 10:39:01 +0000
commit758ca4c4d5e655dd1fa0da32092b498b97f2f095 (patch)
tree6bd43f99edc99f49ff48a97cc8a0dced122a0340
parentd8c73ea2bdb6bff1200928d34fb1460166023384 (diff)
downloadqttools-758ca4c4d5e655dd1fa0da32092b498b97f2f095.tar.gz
qdoc: C++ marker: Allow single quote as a separator in integer literals
Since C++14, single quotes can appear in integer literals as separators to improve readability. When quoting a file that contains such a literal, QDoc interpreted the single quote as a delimiter for a char, and kept reading ahead for the closing quote. This interfered with correct marking up of C++ code and ultimately caused a warning: (qdoc) warning: Something is wrong with qdoc's handling of marked code as the plain code and marked-up code end up having different number of lines. Fixes: QTBUG-111973 Change-Id: Icd2d95973f9cee72eb1c9e3f2d79df0af643dbaa Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit f47a4b17f778e790f9713c9e34ff5919861f49d5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qdoc/cppcodemarker.cpp2
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/examples-manifest.xml1
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/test-demos-demo-example.html23
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/test.qhp2
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/demo.cpp11
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/doc/src/demo.qdoc2
-rw-r--r--tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp1
7 files changed, 41 insertions, 1 deletions
diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp
index 7d4e8c4ed..32b14d24b 100644
--- a/src/qdoc/cppcodemarker.cpp
+++ b/src/qdoc/cppcodemarker.cpp
@@ -430,7 +430,7 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */,
do {
finish = i;
readChar();
- } while (!atEOF && (ch.isLetterOrNumber() || ch == '.'));
+ } while (!atEOF && (ch.isLetterOrNumber() || ch == '.' || ch == '\''));
tag = QStringLiteral("number");
} else {
switch (ch.unicode()) {
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/examples-manifest.xml b/tests/auto/qdoc/generatedoutput/expected_output/examples-manifest.xml
index 0a32be836..563e3c5a3 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/examples-manifest.xml
+++ b/tests/auto/qdoc/generatedoutput/expected_output/examples-manifest.xml
@@ -9,6 +9,7 @@
<example docUrl="qthelp://org.qt-project.test.001/test/test-demos-demo-example.html" imageUrl="qthelp://org.qt-project.test.001/test/images/leonardo-da-vinci.png" isTest="true" name="Demo" projectPath="test/demos/demo/demo.pro">
<description><![CDATA[No description available]]></description>
<tags>test</tags>
+ <fileToOpen mainFile="true">test/demos/demo/demo.cpp</fileToOpen>
</example>
<example docUrl="qthelp://org.qt-project.test.001/test/test-componentset-example.html" isTest="true" name="QML Documentation Example" projectPath="tutorials/componentset/componentset.pro">
<description><![CDATA[Example for documenting QML types.]]></description>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/test-demos-demo-example.html b/tests/auto/qdoc/generatedoutput/expected_output/test-demos-demo-example.html
new file mode 100644
index 000000000..c29408d19
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/test-demos-demo-example.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+<!-- demo.qdoc -->
+ <title>Demo | Test 0.0.1</title>
+</head>
+<body>
+<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
+<h1 class="title">Demo</h1>
+<!-- $$$demos/demo-description -->
+<div class="descr" id="details">
+<p class="centerAlign"><img src="images/leonardo-da-vinci.png" alt="" /></p><pre class="cpp" translate="no"> <span class="keyword">if</span> (n <span class="operator">&gt;</span> <span class="number">1'000</span>)
+ <span class="keyword">return</span> <span class="keyword">true</span>;</pre>
+<p>Files:</p>
+<ul>
+<li><a href="test-demos-demo-demo-cpp.html" translate="no">demos/demo/demo.cpp</a></li>
+<li><a href="test-demos-demo-demo-pro.html" translate="no">demos/demo/demo.pro</a></li>
+</ul>
+</div>
+<!-- @@@demos/demo -->
+</body>
+</html>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/test.qhp b/tests/auto/qdoc/generatedoutput/expected_output/test.qhp
index 417f5a7fb..7ef863788 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/test.qhp
+++ b/tests/auto/qdoc/generatedoutput/expected_output/test.qhp
@@ -195,6 +195,8 @@
<file>test-componentset-progressbar-qml.html</file>
<file>test-componentset-switch-qml.html</file>
<file>test-componentset-tabwidget-qml.html</file>
+ <file>test-demos-demo-demo-cpp.html</file>
+ <file>test-demos-demo-demo-pro.html</file>
<file>test-demos-demo-example.html</file>
<file>test-demos-hidden-example.html</file>
<file>test-empty-qmlmodule.html</file>
diff --git a/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/demo.cpp b/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/demo.cpp
new file mode 100644
index 000000000..906c6292f
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/demo.cpp
@@ -0,0 +1,11 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+bool isOverThousand(int n)
+{
+//! [integer literal with separator]
+ if (n > 1'000)
+ return true;
+//! [integer literal with separator]
+ return false;
+}
diff --git a/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/doc/src/demo.qdoc b/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/doc/src/demo.qdoc
index 82f3352c2..21ebc5588 100644
--- a/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/doc/src/demo.qdoc
+++ b/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/doc/src/demo.qdoc
@@ -6,4 +6,6 @@
\title Demo
\image leonardo-da-vinci.png
//! Icon made by Smashicons from www.flaticon.com
+
+ \snippet demos/demo/demo.cpp integer literal with separator
*/
diff --git a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
index 5c013639a..e8aadeffd 100644
--- a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
+++ b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
@@ -352,6 +352,7 @@ void tst_generatedOutput::examplesManifestXmlAndQhp()
{
testAndCompare("testdata/configs/examples-qhp.qdocconf",
"examples-manifest.xml "
+ "test-demos-demo-example.html "
"test.qhp");
}