Doxygen
Loading...
Searching...
No Matches
commentcnv.h File Reference

First pass comment processing. More...

#include <string>
+ Include dependency graph for commentcnv.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void convertCppComments (const std::string &inBuf, std::string &outBuf, const std::string &fn)
 Converts the comments in a file.
 

Detailed Description

First pass comment processing.

Definition in file commentcnv.h.

Function Documentation

◆ convertCppComments()

void convertCppComments ( const std::string & inBuf,
std::string & outBuf,
const std::string & fn )

Converts the comments in a file.

Parameters
inBufinput buffer holding the file content.
outBufoutput buffer to which the results after conversion are written to.
fnthe name of the file from which the comments originate.

The following is converted:

  • C++ style multiline doxygen comments are converted to C style doxygen comments.
  • conditional sections are processed.
  • aliases are expanded.

This function does three things:

  1. It converts multi-line C++ style comment blocks (that are aligned) to C style comment blocks (if MULTILINE_CPP_IS_BRIEF is set to NO).
  2. It replaces aliases with their definition (see ALIASES)
  3. It handles conditional sections (cond...endcond blocks)

Definition at line 1915 of file commentcnv.l.

1916{
1917 QCString fileName { fn };
1918 yyscan_t yyscanner;
1919 commentcnvYY_state extra(&inBuf,outBuf);
1920 commentcnvYYlex_init_extra(&extra,&yyscanner);
1921#ifdef FLEX_DEBUG
1922 commentcnvYYset_debug(Debug::isFlagSet(Debug::Lex_commentcnv)?1:0,yyscanner);
1923#endif
1924 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1925 //printf("convertCppComments(%s)\n",qPrint(fileName));
1926 yyextra->inBufPos = 0;
1927 yyextra->col = 0;
1928 yyextra->mlBrief = Config_getBool(MULTILINE_CPP_IS_BRIEF);
1929 yyextra->skip = FALSE;
1930 yyextra->fileName = fileName;
1931 yyextra->lang = getLanguageFromFileName(fileName);
1932 yyextra->pythonDocString = FALSE;
1933 yyextra->lineNr = 1;
1934 yyextra->raiseLevel = 0;
1935 yyextra->raiseLabel = "";
1936 yyextra->raiseIncrement = 0;
1937 yyextra->raisePrefix = "";
1938 yyextra->insertCppCommentMarker=false;
1939 yyextra->expandedAliases.clear();
1940 while (!yyextra->condStack.empty()) yyextra->condStack.pop();
1941 clearCommentStack(yyscanner);
1942 yyextra->vhdl = FALSE;
1943
1944 DebugLex debugLex(Debug::Lex_commentcnv,__FILE__, qPrint(fileName));
1945 yyextra->isFixedForm = FALSE;
1946 if (yyextra->lang==SrcLangExt::Fortran)
1947 {
1949 yyextra->isFixedForm = recognizeFixedForm(QCString(inBuf),fmt);
1950 }
1951
1952 if (yyextra->lang==SrcLangExt::Markdown)
1953 {
1954 yyextra->nestingCount=0;
1955 BEGIN(CComment);
1956 yyextra->commentStack.push(yyextra->lineNr);
1957 }
1958 else
1959 {
1960 BEGIN(Scan);
1961 }
1962 yylex(yyscanner);
1963 while (!yyextra->condStack.empty())
1964 {
1965 const commentcnvYY_CondCtx &ctx = yyextra->condStack.top();
1966 QCString sectionInfo(" ");
1967 if (ctx.sectionId!=" ") sectionInfo.sprintf(" with label '%s' ",ctx.sectionId.stripWhiteSpace().data());
1968 warn(yyextra->fileName,ctx.lineNr,"Conditional section%sdoes not have "
1969 "a corresponding \\endcond command within this file.",sectionInfo.data());
1970 yyextra->condStack.pop();
1971 }
1972 if (yyextra->nestingCount>0 && yyextra->lang!=SrcLangExt::Markdown && yyextra->lang!=SrcLangExt::Fortran)
1973 {
1974 QCString tmp("(probable line reference: ");
1975 bool first = TRUE;
1976 while (!yyextra->commentStack.empty())
1977 {
1978 int lineNr = yyextra->commentStack.top();
1979 if (!first) tmp += ", ";
1980 tmp += QCString().setNum(lineNr);
1981 first = FALSE;
1982 yyextra->commentStack.pop();
1983 }
1984 tmp += ")";
1985 warn(yyextra->fileName,yyextra->lineNr,"Reached end of file while still inside a (nested) comment. "
1986 "Nesting level %d %s",yyextra->nestingCount,tmp.data());
1987 }
1988 yyextra->nestingCount = 0;
1990 {
1991 Debug::print(Debug::CommentCnv,0,"-----------\nCommentCnv: %s\n"
1992 "output=[\n%s]\n-----------\n",qPrint(fileName),qPrint(yyextra->outBuf)
1993 );
1994 }
1995 commentcnvYYlex_destroy(yyscanner);
1996}
@ Lex_commentcnv
Definition debug.h:52
@ CommentCnv
Definition debug.h:30
static void print(DebugMask mask, int prio, const char *fmt,...)
Definition debug.cpp:81
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:135
This is an alternative implementation of QCString.
Definition qcstring.h:101
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:245
QCString & setNum(short n)
Definition qcstring.h:444
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:159
yyguts_t * yyscan_t
Definition code.l:24
static void clearCommentStack(yyscan_t yyscanner)
#define Config_getBool(name)
Definition config.h:33
int yylex(void)
#define warn(file, line, fmt,...)
Definition message.h:59
Definition trace.h:153
const char * qPrint(const char *s)
Definition qcstring.h:672
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
@ Markdown
Definition types.h:57
@ Fortran
Definition types.h:53
FortranFormat
Definition types.h:410
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5549
bool recognizeFixedForm(const QCString &contents, FortranFormat format)
Definition util.cpp:6671
FortranFormat convertFileNameFortranParserCode(QCString fn)
Definition util.cpp:6724

References clearCommentStack(), Debug::CommentCnv, Config_getBool, convertFileNameFortranParserCode(), QCString::data(), FALSE, Fortran, getLanguageFromFileName(), Debug::isFlagSet(), Debug::Lex_commentcnv, commentcnvYY_CondCtx::lineNr, Markdown, Debug::print(), qPrint(), recognizeFixedForm(), commentcnvYY_CondCtx::sectionId, QCString::setNum(), QCString::sprintf(), QCString::stripWhiteSpace(), TRUE, warn, and yylex().

Referenced by generateHtmlForComment(), and parseFile().