diff options
author | Topi Reinio <topi.reinio@qt.io> | 2023-01-03 20:48:04 +0000 |
---|---|---|
committer | Topi Reiniƶ <topi.reinio@qt.io> | 2023-01-05 12:18:25 +0000 |
commit | 03af089b10e510f2e7eec4776cf9b126d520f901 (patch) | |
tree | 3e6afee941ba19dafce54c193a69478cafd34546 | |
parent | f95c699b4896dd1d790cf2367437b6ceb811ccf3 (diff) | |
download | qttools-03af089b10e510f2e7eec4776cf9b126d520f901.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.
Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-109735
Change-Id: I23e5703bdf518ecf8511075a295b3c404704a065
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Luca Di Sera <luca.disera@qt.io>
-rw-r--r-- | src/qdoc/docparser.cpp | 11 | ||||
-rw-r--r-- | tests/auto/qdoc/generatedoutput/testdata/includefromexampledirs/excludes/parentinclude.qdoc | 5 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/qdoc/docparser.cpp b/src/qdoc/docparser.cpp index c6883fd6e..2bc296e1f 100644 --- a/src/qdoc/docparser.cpp +++ b/src/qdoc/docparser.cpp @@ -1346,9 +1346,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; } @@ -1363,9 +1365,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 */ /*! |