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

2105{
2106 QCString fileName { fn };
2107 yyscan_t yyscanner;
2108 commentcnvYY_state extra(&inBuf,outBuf);
2109 commentcnvYYlex_init_extra(&extra,&yyscanner);
2110#ifdef FLEX_DEBUG
2111 commentcnvYYset_debug(Debug::isFlagSet(Debug::Lex_commentcnv)?1:0,yyscanner);
2112#endif
2113 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2114 //printf("convertCppComments(%s)\n",qPrint(fileName));
2115 yyextra->inBufPos = 0;
2116 yyextra->col = 0;
2117 yyextra->mlBrief = Config_getBool(MULTILINE_CPP_IS_BRIEF);
2118 yyextra->skip = FALSE;
2119 yyextra->fileName = fileName;
2120 yyextra->lang = getLanguageFromFileName(fileName);
2121 yyextra->pythonDocString = FALSE;
2122 yyextra->lineNr = 1;
2123 yyextra->raiseLevel = 0;
2124 yyextra->raiseLabel = "";
2125 yyextra->raiseIncrement = 0;
2126 yyextra->raisePrefix = "";
2127 yyextra->insertCppCommentMarker=false;
2128 yyextra->expandedAliases.clear();
2129 while (!yyextra->condStack.empty()) yyextra->condStack.pop();
2130 clearCommentStack(yyscanner);
2131 yyextra->vhdl = FALSE;
2132
2133 DebugLex debugLex(Debug::Lex_commentcnv,__FILE__, qPrint(fileName));
2134 yyextra->isFixedForm = FALSE;
2135 if (yyextra->lang==SrcLangExt::Fortran)
2136 {
2138 yyextra->isFixedForm = recognizeFixedForm(inBuf,fmt);
2139 }
2140
2141 if (yyextra->lang==SrcLangExt::Markdown)
2142 {
2143 yyextra->nestingCount=0;
2144 BEGIN(CComment);
2145 yyextra->commentStack.push(yyextra->lineNr);
2146 }
2147 else
2148 {
2149 BEGIN(Scan);
2150 }
2151 yylex(yyscanner);
2152 while (!yyextra->condStack.empty())
2153 {
2154 const commentcnvYY_CondCtx &ctx = yyextra->condStack.top();
2155 QCString sectionInfo(" ");
2156 if (ctx.sectionId!=" ") sectionInfo.sprintf(" with label '%s' ",ctx.sectionId.stripWhiteSpace().data());
2157 warn(yyextra->fileName,ctx.lineNr,"Conditional section{}does not have "
2158 "a corresponding \\endcond command within this file.",sectionInfo.data());
2159 yyextra->condStack.pop();
2160 }
2161 if (yyextra->nestingCount>0 && yyextra->lang!=SrcLangExt::Markdown && yyextra->lang!=SrcLangExt::Fortran)
2162 {
2163 QCString lines;
2164 bool first = true;
2165 while (!yyextra->commentStack.empty())
2166 {
2167 int lineNr = yyextra->commentStack.top();
2168 if (!first) lines += ", ";
2169 lines += QCString().setNum(lineNr);
2170 first = false;
2171 yyextra->commentStack.pop();
2172 }
2173 warn(yyextra->fileName,yyextra->lineNr,"Reached end of file while still inside a (nested) comment. "
2174 "Nesting level {} (possible line reference(s): {})",yyextra->nestingCount,lines);
2175 }
2176 yyextra->nestingCount = 0;
2178 {
2179 Debug::print(Debug::CommentCnv,0,"-----------\nCommentCnv: {}\n"
2180 "output=[\n{}]\n-----------\n",fileName,yyextra->outBuf
2181 );
2182 }
2183 commentcnvYYlex_destroy(yyscanner);
2184}
@ 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:260
QCString & setNum(short n)
Definition qcstring.h:459
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:172
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:687
#define FALSE
Definition qcstring.h:34
FortranFormat
Definition types.h:572
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5194
bool recognizeFixedForm(const QCString &contents, FortranFormat format)
Definition util.cpp:6346
FortranFormat convertFileNameFortranParserCode(QCString fn)
Definition util.cpp:6399

Referenced by generateHtmlForComment(), and parseFile().