diff options
author | Topi Reinio <topi.reinio@qt.io> | 2023-01-03 20:48:04 +0000 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-01-31 15:20:31 +0000 |
commit | 2b97e15e85368b7cdc75bc396fb0dd11fd7c9641 (patch) | |
tree | 98689144a7bf2f9daf25678aa16232bab91bb0e6 /src | |
parent | 39baa4c1fdd7968ed5a9b5671d8f9dab845df9bd (diff) | |
download | qttools-2b97e15e85368b7cdc75bc396fb0dd11fd7c9641.tar.gz |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/qdoc/docparser.cpp | 11 |
1 files changed, 7 insertions, 4 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; } } |