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 1920 of file commentcnv.l.

1921{
1922 QCString fileName { fn };
1923 yyscan_t yyscanner;
1924 commentcnvYY_state extra(&inBuf,outBuf);
1925 commentcnvYYlex_init_extra(&extra,&yyscanner);
1926#ifdef FLEX_DEBUG
1927 commentcnvYYset_debug(Debug::isFlagSet(Debug::Lex_commentcnv)?1:0,yyscanner);
1928#endif
1929 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1930 //printf("convertCppComments(%s)\n",qPrint(fileName));
1931 yyextra->inBufPos = 0;
1932 yyextra->col = 0;
1933 yyextra->mlBrief = Config_getBool(MULTILINE_CPP_IS_BRIEF);
1934 yyextra->skip = FALSE;
1935 yyextra->fileName = fileName;
1936 yyextra->lang = getLanguageFromFileName(fileName);
1937 yyextra->pythonDocString = FALSE;
1938 yyextra->lineNr = 1;
1939 yyextra->raiseLevel = 0;
1940 yyextra->raiseLabel = "";
1941 yyextra->raiseIncrement = 0;
1942 yyextra->raisePrefix = "";
1943 yyextra->insertCppCommentMarker=false;
1944 yyextra->expandedAliases.clear();
1945 while (!yyextra->condStack.empty()) yyextra->condStack.pop();
1946 clearCommentStack(yyscanner);
1947 yyextra->vhdl = FALSE;
1948
1949 DebugLex debugLex(Debug::Lex_commentcnv,__FILE__, qPrint(fileName));
1950 yyextra->isFixedForm = FALSE;
1951 if (yyextra->lang==SrcLangExt::Fortran)
1952 {
1954 yyextra->isFixedForm = recognizeFixedForm(QCString(inBuf),fmt);
1955 }
1956
1957 if (yyextra->lang==SrcLangExt::Markdown)
1958 {
1959 yyextra->nestingCount=0;
1960 BEGIN(CComment);
1961 yyextra->commentStack.push(yyextra->lineNr);
1962 }
1963 else
1964 {
1965 BEGIN(Scan);
1966 }
1967 yylex(yyscanner);
1968 while (!yyextra->condStack.empty())
1969 {
1970 const commentcnvYY_CondCtx &ctx = yyextra->condStack.top();
1971 QCString sectionInfo(" ");
1972 if (ctx.sectionId!=" ") sectionInfo.sprintf(" with label '%s' ",ctx.sectionId.stripWhiteSpace().data());
1973 warn(yyextra->fileName,ctx.lineNr,"Conditional section{}does not have "
1974 "a corresponding \\endcond command within this file.",sectionInfo.data());
1975 yyextra->condStack.pop();
1976 }
1977 if (yyextra->nestingCount>0 && yyextra->lang!=SrcLangExt::Markdown && yyextra->lang!=SrcLangExt::Fortran)
1978 {
1979 QCString lines;
1980 bool first = true;
1981 while (!yyextra->commentStack.empty())
1982 {
1983 int lineNr = yyextra->commentStack.top();
1984 if (!first) lines += ", ";
1985 lines += QCString().setNum(lineNr);
1986 first = false;
1987 yyextra->commentStack.pop();
1988 }
1989 warn(yyextra->fileName,yyextra->lineNr,"Reached end of file while still inside a (nested) comment. "
1990 "Nesting level {} (possible line reference(s): {})",yyextra->nestingCount,lines);
1991 }
1992 yyextra->nestingCount = 0;
1994 {
1995 Debug::print(Debug::CommentCnv,0,"-----------\nCommentCnv: {}\n"
1996 "output=[\n{}]\n-----------\n",fileName,yyextra->outBuf
1997 );
1998 }
1999 commentcnvYYlex_destroy(yyscanner);
2000}
@ Lex_commentcnv
Definition debug.h:53
@ CommentCnv
Definition debug.h:31
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
Definition debug.h:76
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:97
Definition message.h:144
const char * qPrint(const char *s)
Definition qcstring.h:672
#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:5645
bool recognizeFixedForm(const QCString &contents, FortranFormat format)
Definition util.cpp:6767
FortranFormat convertFileNameFortranParserCode(QCString fn)
Definition util.cpp:6820

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(), warn, and yylex().

Referenced by generateHtmlForComment(), and parseFile().