Differential D12220 Diff 32179 kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp
Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp
Show First 20 Lines • Show All 317 Lines • ▼ Show 20 Line(s) | 306 | if( !shorten && (!declarationComment.isEmpty() || doc) ) { | |||
---|---|---|---|---|---|
318 | QString comment = QString::fromUtf8(declarationComment); | 318 | QString comment = QString::fromUtf8(declarationComment); | ||
319 | if(!comment.isEmpty()) { | 319 | if(!comment.isEmpty()) { | ||
320 | // if the first paragraph does not contain a tag, we assume that this is a plain-text comment | 320 | // if the first paragraph does not contain a tag, we assume that this is a plain-text comment | ||
321 | if (!Qt::mightBeRichText(comment)) { | 321 | if (!Qt::mightBeRichText(comment)) { | ||
322 | // still might contain extra html tags for line breaks (this is the case for doxygen-style comments sometimes) | 322 | // still might contain extra html tags for line breaks (this is the case for doxygen-style comments sometimes) | ||
323 | // let's protect them from being removed completely | 323 | // let's protect them from being removed completely | ||
324 | comment.replace(QRegExp(QStringLiteral("<br */>")), QStringLiteral("\n")); | 324 | comment.replace(QRegExp(QStringLiteral("<br */>")), QStringLiteral("\n")); | ||
325 | comment = comment.toHtmlEscaped(); | 325 | comment = comment.toHtmlEscaped(); | ||
326 | comment = parseDoxygenCommands(comment); | ||||
326 | comment.replace(QLatin1Char('\n'), QLatin1String("<br />")); //Replicate newlines in html | 327 | comment.replace(QLatin1Char('\n'), QLatin1String("<br />")); //Replicate newlines in html | ||
327 | } | 328 | } | ||
328 | modifyHtml() += commentHighlight(comment); | 329 | modifyHtml() += commentHighlight(comment); | ||
329 | modifyHtml() += QStringLiteral("</p>"); | 330 | modifyHtml() += QStringLiteral("</p>"); | ||
330 | } | 331 | } | ||
331 | } | 332 | } | ||
332 | 333 | | |||
333 | if(!shorten && doc) { | 334 | if(!shorten && doc) { | ||
▲ Show 20 Lines • Show All 445 Lines • ▼ Show 20 Line(s) | 767 | if( classFunDecl ) { | |||
779 | if( classFunDecl->isAbstract() ) | 780 | if( classFunDecl->isAbstract() ) | ||
780 | details << QStringLiteral("abstract"); | 781 | details << QStringLiteral("abstract"); | ||
781 | } | 782 | } | ||
782 | } | 783 | } | ||
783 | 784 | | |||
784 | return details; | 785 | return details; | ||
785 | } | 786 | } | ||
786 | 787 | | |||
788 | QString AbstractDeclarationNavigationContext::parseDoxygenCommands(const QString& comment) | ||||
789 | { | ||||
790 | QStringList parsedLines; | ||||
791 | | ||||
792 | for( QString line : comment.split('\n') ) { | ||||
mwolffUnsubmitted Not Done mwolff: ```
for (auto lineRef : comment.splitRef(QLatin1Char('\n')) {
QString line = lineRef. | |||||
793 | line = line.trimmed(); | ||||
794 | | ||||
795 | line.replace(QRegExp("^(@param|\\\\param)\\[(in|out|in,out)\\] ([\\w]+) (.*)"), "\\2 <strong>\\3</strong>: <em>\\4</em>"); | ||||
please don't use QRegExp in new code, use QRegularExpression instead also, wrap all string literals in QStringLiteral mwolff: please don't use QRegExp in new code, use QRegularExpression instead
also, wrap all string… | |||||
796 | | ||||
797 | line.replace(QRegExp("^(@param|\\\\param) ([\\w]+) (.*)"), "<strong>\\2</strong>: <em>\\3</em>"); | ||||
798 | | ||||
799 | line.replace(QRegExp("^(@return|\\\\return|@returns|\\\\returns) (.*)"), "<strong>Returns</strong> <em>\\2</em>"); | ||||
800 | | ||||
801 | line.replace(QRegExp("^(@brief|\\\\brief) "), ""); | ||||
802 | | ||||
803 | line.replace(QRegExp("(@see|\\\\see|@sa|\\\\sa) "), "<strong>See also:</strong><br />"); | ||||
That should be <strong>\\2</strong> or so (including the appropriate regexp), right? croick: That should be `<strong>\\2</strong>` or so (including the appropriate regexp), right? | |||||
progwolff: Sorry, missed that one.
How about `<strong>See also:</strong><br />`?
{F5808686} | |||||
804 | | ||||
805 | line.replace(QRegExp("(@since|\\\\since) "), "<strong>Since</strong> "); | ||||
806 | | ||||
807 | line.replace(QRegExp("(@note|\\\\note) "), "<strong>Note:</strong> "); | ||||
808 | | ||||
809 | line.replace(QRegExp("(@todo|\\\\todo) "), "<strong>TODO:</strong> "); | ||||
810 | | ||||
811 | line.replace(QRegExp("(@bug|\\\\bug) "), "<strong>BUG:</strong> "); | ||||
812 | | ||||
813 | line.replace(QRegExp("(<em>.*)\\\\(a|e|em) ([\\w]+)(.*</em>)"), "\\1</em>\\3<em>\\4"); | ||||
814 | | ||||
815 | line.replace(QRegExp("\\\\(a|e|em) ([\\w]+)"), "<em>\\2</em>"); | ||||
816 | | ||||
817 | line.replace(QRegExp("\\\\(c|p) ([\\w]+)"), "<tt>\\2</tt>"); | ||||
818 | | ||||
819 | line.replace(QRegExp("(@code|\\\\code)(\\{[^\\}]*\\})?"), "<pre><tt>"); | ||||
820 | | ||||
821 | line.replace(QRegExp("(@endcode|\\\\endcode)"), "</tt></pre>"); | ||||
822 | | ||||
823 | line.replace(QRegExp("\\\\f\\$(((?!\\\\f\\$).)*)\\\\f\\$"), "<tt>\\1</tt>"); | ||||
824 | | ||||
825 | line.replace(QRegExp("\\\\f\\["), "<pre><tt>"); | ||||
826 | line.replace(QRegExp("\\\\f\\]"), "</tt></pre>"); | ||||
827 | | ||||
828 | line.replace(QRegExp("\\\\f\\{[^\\}]*\\}\\{"), "<pre><tt>"); | ||||
829 | line.replace(QRegExp("\\\\f\\}"), "</tt></pre>"); | ||||
830 | | ||||
831 | line.replace(QRegExp("\\\\([$@\\\\&~<>#%\\\"\\.\\]|::|--|---)"), "\\1"); | ||||
832 | | ||||
833 | line.replace("\\n", "<br />"); | ||||
834 | | ||||
835 | parsedLines << line; | ||||
836 | } | ||||
837 | | ||||
838 | return parsedLines.join("<br />"); | ||||
839 | } | ||||
840 | | ||||
787 | } | 841 | } |