From 794f3a5f55e09c0cb3ecd43833f58d11b9fbc263 Mon Sep 17 00:00:00 2001 From: Leander Schulten Date: Wed, 18 Mar 2020 09:19:09 +0100 Subject: [PATCH] DoxygenGenerator: Ignore attributes in declarations Otherwise the doxygen generation will not work. Change-Id: I07889d84c179ec0ad931d9790f9270ebbd6d259d Reviewed-by: Christian Stenger --- src/plugins/cpptools/doxygengenerator.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/cpptools/doxygengenerator.cpp b/src/plugins/cpptools/doxygengenerator.cpp index 702f92e5247..398a31a8764 100644 --- a/src/plugins/cpptools/doxygengenerator.cpp +++ b/src/plugins/cpptools/doxygengenerator.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -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'));