Skip to main content

The commentcnv.h File Reference

First pass comment processing. More...

Included Headers

#include <string>

Functions Index

voidconvertCppComments (const std::string &inBuf, std::string &outBuf, const std::string &fn)

Converts the comments in a file. More...

Description

First pass comment processing.

Functions

convertCppComments()

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

Converts the comments in a file.

Parameters
inBuf

input buffer holding the file content.

outBuf

output buffer to which the results after conversion are written to.

fn

the 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)

Declaration at line 37 of file commentcnv.h, definition at line 1964 of file commentcnv.l.

1964void convertCppComments(const std::string &inBuf,std::string &outBuf,const std::string &fn)
1965{
1966 QCString fileName { fn };
1967 yyscan_t yyscanner;
1968 commentcnvYY_state extra(&inBuf,outBuf);
1969 commentcnvYYlex_init_extra(&extra,&yyscanner);
1970#ifdef FLEX_DEBUG
1971 commentcnvYYset_debug(Debug::isFlagSet(Debug::Lex_commentcnv)?1:0,yyscanner);
1972#endif
1973 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1974 //printf("convertCppComments(%s)\n",qPrint(fileName));
1975 yyextra->inBufPos = 0;
1976 yyextra->col = 0;
1977 yyextra->mlBrief = Config_getBool(MULTILINE_CPP_IS_BRIEF);
1978 yyextra->skip = FALSE;
1979 yyextra->fileName = fileName;
1980 yyextra->lang = getLanguageFromFileName(fileName);
1981 yyextra->pythonDocString = FALSE;
1982 yyextra->lineNr = 1;
1983 yyextra->raiseLevel = 0;
1984 yyextra->raiseLabel = "";
1985 yyextra->raiseIncrement = 0;
1986 yyextra->raisePrefix = "";
1987 yyextra->insertCppCommentMarker=false;
1988 yyextra->expandedAliases.clear();
1989 while (!yyextra->condStack.empty()) yyextra->condStack.pop();
1990 clearCommentStack(yyscanner);
1991 yyextra->vhdl = FALSE;
1992
1993 DebugLex debugLex(Debug::Lex_commentcnv,__FILE__, qPrint(fileName));
1994 yyextra->isFixedForm = FALSE;
1995 if (yyextra->lang==SrcLangExt::Fortran)
1996 {
1998 yyextra->isFixedForm = recognizeFixedForm(QCString(inBuf),fmt);
1999 }
2000
2001 if (yyextra->lang==SrcLangExt::Markdown)
2002 {
2003 yyextra->nestingCount=0;
2004 BEGIN(CComment);
2005 yyextra->commentStack.push(yyextra->lineNr);
2006 }
2007 else
2008 {
2009 BEGIN(Scan);
2010 }
2011 yylex(yyscanner);
2012 while (!yyextra->condStack.empty())
2013 {
2014 const commentcnvYY_CondCtx &ctx = yyextra->condStack.top();
2015 QCString sectionInfo(" ");
2016 if (ctx.sectionId!=" ") sectionInfo.sprintf(" with label '%s' ",ctx.sectionId.stripWhiteSpace().data());
2017 warn(yyextra->fileName,ctx.lineNr,"Conditional section{}does not have "
2018 "a corresponding \\endcond command within this file.",sectionInfo.data());
2019 yyextra->condStack.pop();
2020 }
2021 if (yyextra->nestingCount>0 && yyextra->lang!=SrcLangExt::Markdown && yyextra->lang!=SrcLangExt::Fortran)
2022 {
2023 QCString lines;
2024 bool first = true;
2025 while (!yyextra->commentStack.empty())
2026 {
2027 int lineNr = yyextra->commentStack.top();
2028 if (!first) lines += ", ";
2029 lines += QCString().setNum(lineNr);
2030 first = false;
2031 yyextra->commentStack.pop();
2032 }
2033 warn(yyextra->fileName,yyextra->lineNr,"Reached end of file while still inside a (nested) comment. "
2034 "Nesting level {} (possible line reference(s): {})",yyextra->nestingCount,lines);
2035 }
2036 yyextra->nestingCount = 0;
2038 {
2039 Debug::print(Debug::CommentCnv,0,"-----------\nCommentCnv: {}\n"
2040 "output=[\n{}]\n-----------\n",fileName,yyextra->outBuf
2041 );
2042 }
2043 commentcnvYYlex_destroy(yyscanner);
2044}

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

Referenced by generateHtmlForComment and parseFile.


Generated via doxygen2docusaurus by Doxygen 1.14.0.