summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2023-01-03 20:48:04 +0000
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-01-31 15:20:31 +0000
commit2b97e15e85368b7cdc75bc396fb0dd11fd7c9641 (patch)
tree98689144a7bf2f9daf25678aa16232bab91bb0e6
parent39baa4c1fdd7968ed5a9b5671d8f9dab845df9bd (diff)
qdoc: Allow snippet marker comments to be indented
Snippet marker tags must follow a QDoc-style comment sequence '//!' - but there's no need to require these comments to start from the beginning of the line. Allow whitespace to appear before the comment by trimming the line before comparison. Fixes: QTBUG-109735 Change-Id: I23e5703bdf518ecf8511075a295b3c404704a065 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Luca Di Sera <luca.disera@qt.io> (cherry picked from commit 03af089b10e510f2e7eec4776cf9b126d520f901) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qdoc/docparser.cpp11
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/includefromexampledirs/excludes/parentinclude.qdoc5
2 files changed, 10 insertions, 6 deletions
diff --git a/src/qdoc/docparser.cpp b/src/qdoc/docparser.cpp
index c76f0df5a..c5341ac91 100644
--- a/src/qdoc/docparser.cpp
+++ b/src/qdoc/docparser.cpp
@@ -1331,9 +1331,11 @@ void DocParser::include(const QString &fileName, const QString &identifier, cons
QStringList lineBuffer = includedContent.split(QLatin1Char('\n'));
int i = 0;
int startLine = -1;
+ QStringView trimmedLine;
while (i < lineBuffer.size()) {
- if (lineBuffer[i].startsWith("//!")) {
- if (lineBuffer[i].contains(identifier)) {
+ trimmedLine = QStringView{lineBuffer[i]}.trimmed();
+ if (trimmedLine.startsWith(QLatin1String("//!"))) {
+ if (trimmedLine.contains(identifier)) {
startLine = i + 1;
break;
}
@@ -1348,9 +1350,10 @@ void DocParser::include(const QString &fileName, const QString &identifier, cons
QString result;
i = startLine;
do {
- if (lineBuffer[i].startsWith("//!")) {
+ trimmedLine = QStringView{lineBuffer[i]}.trimmed();
+ if (trimmedLine.startsWith(QLatin1String("//!"))) {
if (i < lineBuffer.size()) {
- if (lineBuffer[i].contains(identifier)) {
+ if (trimmedLine.contains(identifier)) {
break;
}
}
diff --git a/tests/auto/qdoc/generatedoutput/testdata/includefromexampledirs/excludes/parentinclude.qdoc b/tests/auto/qdoc/generatedoutput/testdata/includefromexampledirs/excludes/parentinclude.qdoc
index 1cc47fd56..04007ac12 100644
--- a/tests/auto/qdoc/generatedoutput/testdata/includefromexampledirs/excludes/parentinclude.qdoc
+++ b/tests/auto/qdoc/generatedoutput/testdata/includefromexampledirs/excludes/parentinclude.qdoc
@@ -12,11 +12,12 @@
*/
/*!
-//! children-qmlproperty
+ //! --- Observe the indented snippet tag:
+ //! children-qmlproperty
\qmlproperty list<Child> AbstractParent::children
\qmldefault
\brief Children of the type.
-//! children-qmlproperty
+ //! children-qmlproperty
*/
/*!