Doxygen
Loading...
Searching...
No Matches
CommentScanner Class Reference

#include <src/commentscan.h>

Classes

struct  Private

Public Member Functions

 CommentScanner ()
 ~CommentScanner ()
bool parseCommentBlock (OutlineParserInterface *parser, Entry *curEntry, const QCString &comment, const QCString &fileName, int &lineNr, bool isBrief, bool isJavadocStyle, bool isInbody, Protection &prot, int &position, bool &newEntryNeeded, bool markdownEnabled, GuardedSectionStack *guards)
 Invokes the comment block parser with the request to parse a single comment block.
void initGroupInfo (Entry *entry)
void enterFile (const QCString &fileName, int lineNr)
void leaveFile (const QCString &fileName, int lineNr)
void enterCompound (const QCString &fileName, int line, const QCString &name)
void leaveCompound (const QCString &fileName, int line, const QCString &name)
void open (Entry *e, const QCString &fileName, int line, bool implicit=false)
void close (Entry *e, const QCString &fileName, int line, bool foundInline, bool implicit=false)

Static Public Member Functions

static bool isCommand (const QCString &cmdName)

Private Attributes

std::unique_ptr< Privatep

Detailed Description

Definition at line 53 of file commentscan.h.

Constructor & Destructor Documentation

◆ CommentScanner()

CommentScanner::CommentScanner ( )

Definition at line 4944 of file commentscan.l.

4944 : p(std::make_unique<Private>())
4945{
4946 commentscanYYlex_init_extra(&p->extra,&p->yyscanner);
4947#ifdef FLEX_DEBUG
4948 commentscanYYset_debug(Debug::isFlagSet(Debug::Lex_commentscan)?1:0,p->yyscanner);
4949#endif
4950}
std::unique_ptr< Private > p
@ Lex_commentscan
Definition debug.h:55
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:133

References Debug::isFlagSet(), Debug::Lex_commentscan, and p.

◆ ~CommentScanner()

CommentScanner::~CommentScanner ( )

Definition at line 4952 of file commentscan.l.

4953{
4954 commentscanYYlex_destroy(p->yyscanner);
4955}

References p.

Member Function Documentation

◆ close()

void CommentScanner::close ( Entry * e,
const QCString & fileName,
int line,
bool foundInline,
bool implicit = false )

Definition at line 5175 of file commentscan.l.

5176{
5177 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
5178 yyextra->docGroup.close(e,fileName,lineNr,foundInline,implicit);
5179}

References p.

◆ enterCompound()

void CommentScanner::enterCompound ( const QCString & fileName,
int line,
const QCString & name )

Definition at line 5157 of file commentscan.l.

5158{
5159 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
5160 yyextra->docGroup.enterCompound(fileName,lineNr,name);
5161}

References p.

◆ enterFile()

void CommentScanner::enterFile ( const QCString & fileName,
int lineNr )

Definition at line 5145 of file commentscan.l.

5146{
5147 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
5148 yyextra->docGroup.enterFile(fileName,lineNr);
5149}

References p.

Referenced by generateHtmlForComment().

◆ initGroupInfo()

void CommentScanner::initGroupInfo ( Entry * entry)

Definition at line 5139 of file commentscan.l.

5140{
5141 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
5142 yyextra->docGroup.initGroupInfo(entry);
5143}

References p.

◆ isCommand()

bool CommentScanner::isCommand ( const QCString & cmdName)
static

Definition at line 5181 of file commentscan.l.

5182{
5183 return (docCmdMap.find(cmdName.str()) != docCmdMap.end());
5184}
const std::string & str() const
Definition qcstring.h:556
static const std::unordered_map< std::string, DocCmdMap > docCmdMap

References docCmdMap, and QCString::str().

Referenced by Markdown::Private::processLink().

◆ leaveCompound()

void CommentScanner::leaveCompound ( const QCString & fileName,
int line,
const QCString & name )

Definition at line 5163 of file commentscan.l.

5164{
5165 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
5166 yyextra->docGroup.leaveCompound(fileName,lineNr,name);
5167}

References p.

◆ leaveFile()

void CommentScanner::leaveFile ( const QCString & fileName,
int lineNr )

Definition at line 5151 of file commentscan.l.

5152{
5153 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
5154 yyextra->docGroup.leaveFile(fileName,lineNr);
5155}

References p.

Referenced by generateHtmlForComment().

◆ open()

void CommentScanner::open ( Entry * e,
const QCString & fileName,
int line,
bool implicit = false )

Definition at line 5169 of file commentscan.l.

5170{
5171 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
5172 yyextra->docGroup.open(e,fileName,lineNr,implicit);
5173}

References p.

◆ parseCommentBlock()

bool CommentScanner::parseCommentBlock ( OutlineParserInterface * parser,
Entry * curEntry,
const QCString & comment,
const QCString & fileName,
int & lineNr,
bool isBrief,
bool isJavadocStyle,
bool isInbody,
Protection & prot,
int & position,
bool & newEntryNeeded,
bool markdownEnabled,
GuardedSectionStack * guards )

Invokes the comment block parser with the request to parse a single comment block.

Parameters
[in]parserThe language parse that invoked this function. The comment block parse may invoke ParserInterface::parsePrototype() in order to parse the argument of a @fn command.
[in]curEntryThe Entry to which the comment block belongs. Any information (like documentation) that is found in the comment block will be stored in this entry.
[in]commentA string representing the actual comment block. Note that leading *'s are already stripped from the comment block.
[in]fileNameThe name of the file in which the comment is found. Mainly used for producing warnings.
[in,out]lineNrThe line number at which the comment block was found. When the function returns it will be set to the last line parsed.
[in]isBriefTRUE iff this comment block represents a brief description.
[in]isJavadocStyleTRUE iff this comment block is in "Javadoc" style. This means that it starts as a brief description until the end of the sentences is found and then proceeds as a detailed description.
[in]isInbodyTRUE iff this comment block is located in the body of a function.
[in,out]protThe protection level in which this comment block was found. Commands in the comment block may override this.
[in,out]positionThe character position within comment where the comment block starts. Typically used in case the comment block contains multiple structural commands.
[out]newEntryNeededBoolean that is TRUE if the comment block parser finds that a the comment block finishes the entry and a new one needs to be started.
[in]markdownEnabledIndicates if markdown specific processing should be done.
[in,out]guardsTracks nested conditional sections (if,ifnot,..)
Returns
TRUE if the comment requires further processing. The parameter newEntryNeeded will typically be true in this case and position will indicate the offset inside the comment string where to proceed parsing. FALSE indicates no further processing is needed.

Definition at line 4957 of file commentscan.l.

4971{
4972 AUTO_TRACE("comment='{}' fileName={} lineNr={} isBrief={} isAutoBriefOn={} inInbody={}"
4973 " prot={} markdownSupport={}",Trace::trunc(comment),fileName,lineNr,isBrief,
4974 isAutoBriefOn,isInbody,prot,markdownSupport);
4975 yyscan_t yyscanner = p->yyscanner;
4976 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4977
4978 initParser(yyscanner);
4979 yyextra->guards = guards;
4980 yyextra->langParser = parser;
4981 yyextra->current = curEntry;
4982 yyextra->current->docLine = (lineNr > 1 ? lineNr : 1);
4983 if (comment.isEmpty()) return FALSE; // avoid empty strings
4984 yyextra->inputString = comment;
4985 yyextra->inputString.append(" ");
4986 yyextra->inputPosition = position;
4987 yyextra->lineNr = lineNr;
4988 yyextra->fileName = fileName;
4989 yyextra->protection = prot;
4990 yyextra->needNewEntry = FALSE;
4991 yyextra->xrefKind = XRef_None;
4992 yyextra->xrefAppendFlag = FALSE;
4993 yyextra->insidePre = FALSE;
4994 yyextra->parseMore = FALSE;
4995 yyextra->inBody = isInbody;
4996 yyextra->markdownSupport= markdownSupport;
4997 yyextra->outputXRef.clear();
4998 if (!isBrief && !isAutoBriefOn && !yyextra->current->doc.isEmpty())
4999 { // add newline separator between detailed comment blocks
5000 yyextra->current->doc += '\n';
5001 }
5002 setOutput(yyscanner, isBrief || isAutoBriefOn ? OutputBrief : OutputDoc );
5003 yyextra->briefEndsAtDot = isAutoBriefOn;
5004 yyextra->condCount = 0;
5005 yyextra->sectionLevel = 0;
5006 yyextra->spaceBeforeCmd.clear();
5007 yyextra->spaceBeforeIf.clear();
5008 yyextra->htmlContextStack.clear();
5009
5010 DebugLex debugLex(Debug::Lex_commentscan, __FILE__, !fileName.isEmpty() ? qPrint(fileName): nullptr);
5011 if (!yyextra->current->inbodyDocs.isEmpty() && isInbody) // separate in body fragments
5012 {
5013 char cmd[30];
5014 qsnprintf(cmd,30,"\n\n\\iline %d \\ilinebr ",lineNr);
5015 yyextra->current->inbodyDocs+=cmd;
5016 }
5017
5018 Debug::print(Debug::CommentScan,0,"-----------\nCommentScanner: {}:{}\n"
5019 "input=[\n{}]\n",fileName,lineNr,yyextra->inputString
5020 );
5021
5022 commentscanYYrestart( nullptr, yyscanner );
5023 BEGIN( Comment );
5024 commentscanYYlex(yyscanner);
5025 setOutput(yyscanner, OutputDoc );
5026
5027 if (YY_START==OverloadParam) // comment ended with \overload
5028 {
5029 addOutput(yyscanner,getOverloadDocs());
5030 }
5031
5032 if (yyextra->insideParBlock)
5033 {
5034 warn(yyextra->fileName,yyextra->lineNr,
5035 "Documentation block ended while inside a \\parblock. Missing \\endparblock");
5036 }
5037
5038 yyextra->current->doc=stripLeadingAndTrailingEmptyLines(yyextra->current->doc,yyextra->current->docLine);
5039 yyextra->current->brief=stripLeadingAndTrailingEmptyLines(yyextra->current->brief,yyextra->current->docLine);
5040
5041 if (yyextra->current->section.isFileDoc() && yyextra->current->doc.isEmpty())
5042 {
5043 // to allow a comment block with just a @file command.
5044 yyextra->current->doc="\n\n";
5045 }
5046
5047 if (yyextra->current->section.isMemberGrp() &&
5048 yyextra->docGroup.isEmpty()) // @name section but no group started yet
5049 {
5050 yyextra->docGroup.open(yyextra->current,yyextra->fileName,yyextra->lineNr,true);
5051 }
5052
5053 Debug::print(Debug::CommentScan,0,"-----------\nCommentScanner: {}:{}\noutput=[\n"
5054 "brief=[line={}\n{}]\ndocs=[line={}\n{}]\ninbody=[line={}\n{}]\n]\n===========\n",
5055 fileName,lineNr,
5056 yyextra->current->briefLine,yyextra->current->brief,
5057 yyextra->current->docLine,yyextra->current->doc,
5058 yyextra->current->inbodyLine,yyextra->current->inbodyDocs
5059 );
5060
5061 checkFormula(yyscanner);
5062 prot = yyextra->protection;
5063
5064 yyextra->docGroup.addDocs(curEntry);
5065
5066 newEntryNeeded = yyextra->needNewEntry;
5067
5068 // if we did not proceed during this call, it does not make
5069 // sense to continue, since we get stuck. See bug 567346 for situations
5070 // were this happens
5071 if (yyextra->parseMore && position==yyextra->inputPosition) yyextra->parseMore=FALSE;
5072
5073 if (!yyextra->parseMore && !yyextra->guards->empty())
5074 {
5075 warn(yyextra->fileName,yyextra->lineNr,"Documentation block ended in the middle of a conditional section!");
5076 }
5077
5078 if (yyextra->parseMore) position=yyextra->inputPosition; else position=0;
5079
5080 lineNr = yyextra->lineNr;
5081 AUTO_TRACE_EXIT("position={} parseMore={} newEntryNeeded={}",
5082 position,yyextra->parseMore,newEntryNeeded);
5083
5084 return yyextra->parseMore;
5085}
@ CommentScan
Definition debug.h:32
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
Definition debug.h:77
int docLine
line number at which the documentation was found
Definition entry.h:202
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:167
void clear()
Definition qcstring.h:186
yyguts_t * yyscan_t
Definition code.l:24
@ XRef_None
static void setOutput(yyscan_t yyscanner, OutputContext ctx)
static void initParser(yyscan_t yyscanner)
static void addOutput(yyscan_t yyscanner, const char *s)
@ OutputDoc
@ OutputBrief
static void checkFormula(yyscan_t yyscanner)
#define AUTO_TRACE(...)
Definition docnode.cpp:48
#define AUTO_TRACE_EXIT(...)
Definition docnode.cpp:50
#define warn(file, line, fmt,...)
Definition message.h:97
QCString trunc(const QCString &s, size_t numChars=15)
Definition trace.h:56
#define qsnprintf
Definition qcstring.h:49
const char * qPrint(const char *s)
Definition qcstring.h:691
#define FALSE
Definition qcstring.h:34
QCString stripLeadingAndTrailingEmptyLines(const QCString &s, int &docLine)
Special version of QCString::stripWhiteSpace() that only strips completely blank lines.
Definition util.cpp:5050
QCString getOverloadDocs()
Definition util.cpp:4110
const char * comment

References addOutput(), AUTO_TRACE, AUTO_TRACE_EXIT, checkFormula(), comment, Debug::CommentScan, Entry::docLine, FALSE, getOverloadDocs(), initParser(), QCString::isEmpty(), Debug::Lex_commentscan, OutputBrief, OutputDoc, p, Debug::print(), qPrint(), qsnprintf, setOutput(), stripLeadingAndTrailingEmptyLines(), Trace::trunc(), warn, and XRef_None.

Referenced by generateHtmlForComment(), and CitationManager::generatePage().

Member Data Documentation

◆ p

std::unique_ptr<Private> CommentScanner::p
private

The documentation for this class was generated from the following files: