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)
 

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 4681 of file commentscan.l.

4681 : p(std::make_unique<Private>())
4682{
4683 commentscanYYlex_init_extra(&p->extra,&p->yyscanner);
4684#ifdef FLEX_DEBUG
4685 commentscanYYset_debug(Debug::isFlagSet(Debug::Lex_commentscan)?1:0,p->yyscanner);
4686#endif
4687}
std::unique_ptr< Private > p
@ Lex_commentscan
Definition debug.h:53
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:135

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

◆ ~CommentScanner()

CommentScanner::~CommentScanner ( )

Definition at line 4689 of file commentscan.l.

4690{
4691 commentscanYYlex_destroy(p->yyscanner);
4692}

References p.

Member Function Documentation

◆ close()

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

Definition at line 4912 of file commentscan.l.

4913{
4914 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4915 yyextra->docGroup.close(e,fileName,lineNr,foundInline,implicit);
4916}

References p.

◆ enterCompound()

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

Definition at line 4894 of file commentscan.l.

4895{
4896 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4897 yyextra->docGroup.enterCompound(fileName,lineNr,name);
4898}

References p.

◆ enterFile()

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

Definition at line 4882 of file commentscan.l.

4883{
4884 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4885 yyextra->docGroup.enterFile(fileName,lineNr);
4886}

References p.

Referenced by generateHtmlForComment().

◆ initGroupInfo()

void CommentScanner::initGroupInfo ( Entry * entry)

Definition at line 4876 of file commentscan.l.

4877{
4878 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4879 yyextra->docGroup.initGroupInfo(entry);
4880}

References p.

◆ leaveCompound()

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

Definition at line 4900 of file commentscan.l.

4901{
4902 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4903 yyextra->docGroup.leaveCompound(fileName,lineNr,name);
4904}

References p.

◆ leaveFile()

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

Definition at line 4888 of file commentscan.l.

4889{
4890 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4891 yyextra->docGroup.leaveFile(fileName,lineNr);
4892}

References p.

Referenced by generateHtmlForComment().

◆ open()

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

Definition at line 4906 of file commentscan.l.

4907{
4908 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4909 yyextra->docGroup.open(e,fileName,lineNr,implicit);
4910}

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 4694 of file commentscan.l.

4708{
4709 AUTO_TRACE("comment='{}' fileName={} lineNr={} isBrief={} isAutoBriefOn={} inInbody={}"
4710 " prot={} markdownSupport={}",Trace::trunc(comment),fileName,lineNr,isBrief,
4711 isAutoBriefOn,isInbody,prot,markdownSupport);
4712 yyscan_t yyscanner = p->yyscanner;
4713 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4714
4715 initParser(yyscanner);
4716 yyextra->guards = guards;
4717 yyextra->langParser = parser;
4718 yyextra->current = curEntry;
4719 yyextra->current->docLine = (lineNr > 1 ? lineNr : 1);
4720 if (comment.isEmpty()) return FALSE; // avoid empty strings
4721 yyextra->inputString = comment;
4722 yyextra->inputString.append(" ");
4723 yyextra->inputPosition = position;
4724 yyextra->lineNr = lineNr;
4725 yyextra->fileName = fileName;
4726 yyextra->protection = prot;
4727 yyextra->needNewEntry = FALSE;
4728 yyextra->xrefKind = XRef_None;
4729 yyextra->xrefAppendFlag = FALSE;
4730 yyextra->insidePre = FALSE;
4731 yyextra->parseMore = FALSE;
4732 yyextra->inBody = isInbody;
4733 yyextra->markdownSupport= markdownSupport;
4734 yyextra->outputXRef.clear();
4735 if (!isBrief && !isAutoBriefOn && !yyextra->current->doc.isEmpty())
4736 { // add newline separator between detailed comment blocks
4737 yyextra->current->doc += '\n';
4738 }
4739 setOutput(yyscanner, isBrief || isAutoBriefOn ? OutputBrief : OutputDoc );
4740 yyextra->briefEndsAtDot = isAutoBriefOn;
4741 yyextra->condCount = 0;
4742 yyextra->sectionLevel = 0;
4743 yyextra->spaceBeforeCmd.clear();
4744 yyextra->spaceBeforeIf.clear();
4745 yyextra->htmlContextStack.clear();
4746
4747 DebugLex debugLex(Debug::Lex_commentscan, __FILE__, !fileName.isEmpty() ? qPrint(fileName): nullptr);
4748 if (!yyextra->current->inbodyDocs.isEmpty() && isInbody) // separate in body fragments
4749 {
4750 char cmd[30];
4751 qsnprintf(cmd,30,"\n\n\\iline %d \\ilinebr ",lineNr);
4752 yyextra->current->inbodyDocs+=cmd;
4753 }
4754
4755 Debug::print(Debug::CommentScan,0,"-----------\nCommentScanner: %s:%d\n"
4756 "input=[\n%s]\n",qPrint(fileName),lineNr,qPrint(yyextra->inputString)
4757 );
4758
4759 commentscanYYrestart( nullptr, yyscanner );
4760 BEGIN( Comment );
4761 commentscanYYlex(yyscanner);
4762 setOutput(yyscanner, OutputDoc );
4763
4764 if (YY_START==OverloadParam) // comment ended with \overload
4765 {
4766 addOutput(yyscanner,getOverloadDocs());
4767 }
4768
4769 if (yyextra->insideParBlock)
4770 {
4771 warn(yyextra->fileName,yyextra->lineNr,
4772 "Documentation block ended while inside a \\parblock. Missing \\endparblock");
4773 }
4774
4775 yyextra->current->doc=stripLeadingAndTrailingEmptyLines(yyextra->current->doc,yyextra->current->docLine);
4776 yyextra->current->brief=stripLeadingAndTrailingEmptyLines(yyextra->current->brief,yyextra->current->docLine);
4777
4778 if (yyextra->current->section.isFileDoc() && yyextra->current->doc.isEmpty())
4779 {
4780 // to allow a comment block with just a @file command.
4781 yyextra->current->doc="\n\n";
4782 }
4783
4784 if (yyextra->current->section.isMemberGrp() &&
4785 yyextra->docGroup.isEmpty()) // @name section but no group started yet
4786 {
4787 yyextra->docGroup.open(yyextra->current,yyextra->fileName,yyextra->lineNr,true);
4788 }
4789
4790 Debug::print(Debug::CommentScan,0,"-----------\nCommentScanner: %s:%d\noutput=[\n"
4791 "brief=[line=%d\n%s]\ndocs=[line=%d\n%s]\ninbody=[line=%d\n%s]\n]\n===========\n",
4792 qPrint(fileName),lineNr,
4793 yyextra->current->briefLine,qPrint(yyextra->current->brief),
4794 yyextra->current->docLine,qPrint(yyextra->current->doc),
4795 yyextra->current->inbodyLine,qPrint(yyextra->current->inbodyDocs)
4796 );
4797
4798 checkFormula(yyscanner);
4799 prot = yyextra->protection;
4800
4801 yyextra->docGroup.addDocs(curEntry);
4802
4803 newEntryNeeded = yyextra->needNewEntry;
4804
4805 // if we did not proceed during this call, it does not make
4806 // sense to continue, since we get stuck. See bug 567346 for situations
4807 // were this happens
4808 if (yyextra->parseMore && position==yyextra->inputPosition) yyextra->parseMore=FALSE;
4809
4810 if (!yyextra->parseMore && !yyextra->guards->empty())
4811 {
4812 warn(yyextra->fileName,yyextra->lineNr,"Documentation block ended in the middle of a conditional section!");
4813 }
4814
4815 if (yyextra->parseMore) position=yyextra->inputPosition; else position=0;
4816
4817 lineNr = yyextra->lineNr;
4818 AUTO_TRACE_EXIT("position={} parseMore={} newEntryNeeded={}",
4819 position,yyextra->parseMore,newEntryNeeded);
4820
4821 return yyextra->parseMore;
4822}
@ CommentScan
Definition debug.h:31
static void print(DebugMask mask, int prio, const char *fmt,...)
Definition debug.cpp:81
int docLine
line number at which the documentation was found
Definition entry.h:201
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
void clear()
Definition qcstring.h:169
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:46
#define AUTO_TRACE_EXIT(...)
Definition docnode.cpp:48
#define warn(file, line, fmt,...)
Definition message.h:59
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:672
#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:5368
QCString getOverloadDocs()
Definition util.cpp:4440
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: