DoxygenGenerator: Ignore attributes in declarations

Otherwise the doxygen generation will not work.

Change-Id: I07889d84c179ec0ad931d9790f9270ebbd6d259d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Leander Schulten
2020-03-18 09:19:09 +01:00
parent 1352ec636f
commit 794f3a5f55

View File

@@ -33,6 +33,7 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QDebug> #include <QDebug>
#include <QRegularExpression>
#include <QTextBlock> #include <QTextBlock>
#include <QTextCursor> #include <QTextCursor>
#include <QTextDocument> #include <QTextDocument>
@@ -81,7 +82,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
const QTextCursor initialCursor = cursor; const QTextCursor initialCursor = cursor;
const QChar &c = cursor.document()->characterAt(cursor.position()); const QChar &c = cursor.document()->characterAt(cursor.position());
if (!c.isLetter() && c != QLatin1Char('_')) if (!c.isLetter() && c != QLatin1Char('_') && c != QLatin1Char('['))
return QString(); return QString();
// Try to find what would be the declaration we are interested in. // Try to find what would be the declaration we are interested in.
@@ -109,8 +110,12 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
QString declCandidate = cursor.selectedText(); QString declCandidate = cursor.selectedText();
if (declCandidate.startsWith(QLatin1String("Q_INVOKABLE"))) // remove attributes like [[nodiscard]] because
declCandidate = declCandidate.mid(11); // Document::Ptr::parse(Document::ParseDeclaration) fails on attributes
static QRegularExpression attribute("\\[\\s*\\[.*\\]\\s*\\]");
declCandidate.replace(attribute, "");
declCandidate.replace("Q_INVOKABLE", "");
declCandidate.replace(QChar::ParagraphSeparator, QLatin1Char('\n')); declCandidate.replace(QChar::ParagraphSeparator, QLatin1Char('\n'));