C++: Automatic Doxygen comment blocks generation

This improves our completion support for documentation
comments. It's now possible to have a Doxygen block
generated when hitting enter after a /** or /*! comment
start. A couple other related options are also available.

Task-number: QTCREATORBUG-2752
Task-number: QTCREATORBUG-3165

Change-Id: I1c81c0b4b370eb1d409ef72a9c7f22c357f202f4
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@nokia.com>
Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
This commit is contained in:
Leandro Melo
2011-12-07 15:05:02 +01:00
parent 24b4c12737
commit beede7d7cf
13 changed files with 723 additions and 15 deletions

View File

@@ -0,0 +1,71 @@
#ifndef DOXYGEGENERATOR_H
#define DOXYGEGENERATOR_H
#include "cpptools_global.h"
#include <cplusplus/Overview.h>
#include <QtCore/QLatin1String>
#include <QtGui/QTextCursor>
namespace CPlusPlus {
class DeclarationAST;
}
namespace CppTools {
class CPPTOOLS_EXPORT DoxygenGenerator
{
public:
DoxygenGenerator();
enum DocumentationStyle {
JavaStyle,
QtStyle
};
void setStyle(DocumentationStyle style);
void setStartComment(bool start);
void setGenerateBrief(bool gen);
void setAddLeadingAsterisks(bool add);
QString generate(QTextCursor cursor);
QString generate(QTextCursor cursor, CPlusPlus::DeclarationAST *decl);
private:
QChar startMark() const;
QChar styleMark() const;
enum Command {
BriefCommand,
ParamCommand,
ReturnCommand
};
static QString commandSpelling(Command command);
void writeStart(QString *comment) const;
void writeEnd(QString *comment) const;
void writeContinuation(QString *comment) const;
void writeNewLine(QString *comment) const;
void writeCommand(QString *comment,
Command command,
const QString &commandContent = QString()) const;
void writeBrief(QString *comment,
const QString &brief,
const QString &prefix = QString(),
const QString &suffix = QString());
void assignCommentOffset(QTextCursor cursor);
QString offsetString() const;
bool m_addLeadingAsterisks;
bool m_generateBrief;
bool m_startComment;
DocumentationStyle m_style;
CPlusPlus::Overview m_printer;
int m_commentOffset;
};
} // CppTools
#endif // DOXYGEGENERATOR_H