forked from qt-creator/qt-creator
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:
@@ -33,6 +33,7 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
#include <QTextBlock>
|
||||
#include <QTextCursor>
|
||||
#include <QTextDocument>
|
||||
@@ -81,7 +82,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
|
||||
const QTextCursor initialCursor = cursor;
|
||||
|
||||
const QChar &c = cursor.document()->characterAt(cursor.position());
|
||||
if (!c.isLetter() && c != QLatin1Char('_'))
|
||||
if (!c.isLetter() && c != QLatin1Char('_') && c != QLatin1Char('['))
|
||||
return QString();
|
||||
|
||||
// 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();
|
||||
|
||||
if (declCandidate.startsWith(QLatin1String("Q_INVOKABLE")))
|
||||
declCandidate = declCandidate.mid(11);
|
||||
// remove attributes like [[nodiscard]] because
|
||||
// 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'));
|
||||
|
||||
|
Reference in New Issue
Block a user