Doxygen
Loading...
Searching...
No Matches
docparser.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <cassert>
#include <ctype.h>
#include "classlist.h"
#include "cmdmapper.h"
#include "config.h"
#include "debug.h"
#include "dir.h"
#include "docparser.h"
#include "docparser_p.h"
#include "doxygen.h"
#include "filedef.h"
#include "fileinfo.h"
#include "groupdef.h"
#include "namespacedef.h"
#include "message.h"
#include "pagedef.h"
#include "portable.h"
#include "printdocvisitor.h"
#include "util.h"
#include "indexlist.h"
#include "trace.h"
#include "stringutil.h"
Include dependency graph for docparser.cpp:

Go to the source code of this file.

Macros

#define AUTO_TRACE(...)
#define AUTO_TRACE_ADD(...)
#define AUTO_TRACE_EXIT(...)
#define CHECK_FOR_COMMAND(str, action)

Functions

IDocParserPtr createDocParser ()
 factory function to create a parser
static QCString extractCopyDocId (const char *data, size_t &j, size_t len)
static size_t isCopyBriefOrDetailsCmd (const char *data, size_t i, size_t len, bool &brief)
static size_t isVerbatimSection (const char *data, size_t i, size_t len, QCString &endMarker)
static size_t skipToEndMarker (const char *data, size_t i, size_t len, const QCString &endMarker)
IDocNodeASTPtr validatingParseDoc (IDocParser &parserIntf, const QCString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const QCString &input, const DocOptions &options)
IDocNodeASTPtr validatingParseTitle (IDocParser &parserIntf, const QCString &fileName, int lineNr, const QCString &input)
IDocNodeASTPtr validatingParseText (IDocParser &parserIntf, const QCString &input)
IDocNodeASTPtr createRef (IDocParser &parserIntf, const QCString &target, const QCString &context, const QCString &srcFile, int srcLine)
void docFindSections (const QCString &input, const Definition *d, const QCString &fileName)

Macro Definition Documentation

◆ AUTO_TRACE

#define AUTO_TRACE ( ...)
Value:
(void)0

Definition at line 47 of file docparser.cpp.

◆ AUTO_TRACE_ADD

#define AUTO_TRACE_ADD ( ...)
Value:
(void)0

Definition at line 48 of file docparser.cpp.

◆ AUTO_TRACE_EXIT

#define AUTO_TRACE_EXIT ( ...)
Value:
(void)0

Definition at line 49 of file docparser.cpp.

◆ CHECK_FOR_COMMAND

#define CHECK_FOR_COMMAND ( str,
action )
Value:
do if ((i+sizeof(str)<len) && literal_at(data+i+1,str)) \
{ j=i+sizeof(str); action; } while(0)
bool literal_at(const char *data, const char(&str)[N])
returns TRUE iff data points to a substring that matches string literal str
Definition stringutil.h:98

Definition at line 2016 of file docparser.cpp.

2016#define CHECK_FOR_COMMAND(str,action) \
2017 do if ((i+sizeof(str)<len) && literal_at(data+i+1,str)) \
2018 { j=i+sizeof(str); action; } while(0)

Referenced by isCopyBriefOrDetailsCmd(), and isVerbatimSection().

Function Documentation

◆ createDocParser()

◆ createRef()

IDocNodeASTPtr createRef ( IDocParser & parserIntf,
const QCString & target,
const QCString & context,
const QCString & srcFile,
int srcLine )

Definition at line 2442 of file docparser.cpp.

2443{
2444 DocParser *parser = dynamic_cast<DocParser*>(&parserIntf);
2445 assert(parser!=nullptr);
2446 if (parser==nullptr) return nullptr;
2447 if (!srcFile.isEmpty())
2448 {
2449 parser->context.fileName = srcFile;
2450 parser->tokenizer.setFileName(srcFile);
2451 parser->tokenizer.setLineNr(srcLine);
2452 }
2453 return std::make_unique<DocNodeAST>(DocRef(parser,nullptr,target,context));
2454}
DocTokenizer tokenizer
DocParserContext context
Node representing a reference to some item.
Definition docnode.h:787
void setLineNr(int lineno)
void setFileName(const QCString &fileName)
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:167
QCString fileName
Definition docparser_p.h:71

References DocParser::context, DocParserContext::fileName, QCString::isEmpty(), DocTokenizer::setFileName(), DocTokenizer::setLineNr(), and DocParser::tokenizer.

Referenced by convertMapFile(), replaceRef(), and LayoutNavEntry::url().

◆ docFindSections()

void docFindSections ( const QCString & input,
const Definition * d,
const QCString & fileName )

◆ extractCopyDocId()

QCString extractCopyDocId ( const char * data,
size_t & j,
size_t len )
static

Definition at line 1943 of file docparser.cpp.

1944{
1945 size_t s=j;
1946 int round=0;
1947 bool insideDQuote=FALSE;
1948 bool insideSQuote=FALSE;
1949 bool found=FALSE;
1950 while (j<len && !found)
1951 {
1952 if (!insideSQuote && !insideDQuote)
1953 {
1954 switch (data[j])
1955 {
1956 case '(': round++; break;
1957 case ')': round--; break;
1958 case '"': insideDQuote=TRUE; break;
1959 case '\'': insideSQuote=TRUE; break;
1960 case '\\': // fall through, begin of command
1961 case '@': // fall through, begin of command
1962 case '\t': // fall through
1963 case '\n':
1964 found=(round==0);
1965 break;
1966 case ' ': // allow spaces in cast operator (see issue #11169)
1967 found=(round==0) && (j<8 || !literal_at(data+j-8,"operator"));
1968 break;
1969 }
1970 }
1971 else if (insideSQuote) // look for single quote end
1972 {
1973 if (data[j]=='\'' && (j==0 || data[j]!='\\'))
1974 {
1975 insideSQuote=FALSE;
1976 }
1977 }
1978 else if (insideDQuote) // look for double quote end
1979 {
1980 if (data[j]=='"' && (j==0 || data[j]!='\\'))
1981 {
1982 insideDQuote=FALSE;
1983 }
1984 }
1985 if (!found) j++;
1986 }
1987
1988 // include const and volatile
1989 if (literal_at(data+j," const"))
1990 {
1991 j+=6;
1992 }
1993 else if (literal_at(data+j," volatile"))
1994 {
1995 j+=9;
1996 }
1997
1998 // allow '&' or '&&' or ' &' or ' &&' at the end
1999 size_t k=j;
2000 while (k<len && data[k]==' ') k++;
2001 if (k<len-1 && data[k]=='&' && data[k+1]=='&') j=k+2;
2002 else if (k<len && data[k]=='&' ) j=k+1;
2003
2004 // do not include punctuation added by Definition::_setBriefDescription()
2005 size_t e=j;
2006 if (j>0 && data[j-1]=='.') { e--; }
2007 QCString id(data+s,e-s);
2008 //printf("extractCopyDocId='%s' input='%s'\n",qPrint(id),&data[s]);
2009 return id;
2010}
This is an alternative implementation of QCString.
Definition qcstring.h:103
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34

References FALSE, literal_at(), and TRUE.

Referenced by DocParser::processCopyDoc().

◆ isCopyBriefOrDetailsCmd()

size_t isCopyBriefOrDetailsCmd ( const char * data,
size_t i,
size_t len,
bool & brief )
static

Definition at line 2020 of file docparser.cpp.

2021{
2022 size_t j=0;
2023 if (i==0 || (data[i-1]!='@' && data[i-1]!='\\')) // not an escaped command
2024 {
2025 CHECK_FOR_COMMAND("copybrief",brief=TRUE); // @copybrief or \copybrief
2026 CHECK_FOR_COMMAND("copydetails",brief=FALSE); // @copydetails or \copydetails
2027 }
2028 return j;
2029}
#define CHECK_FOR_COMMAND(str, action)

References CHECK_FOR_COMMAND, FALSE, and TRUE.

Referenced by DocParser::processCopyDoc().

◆ isVerbatimSection()

size_t isVerbatimSection ( const char * data,
size_t i,
size_t len,
QCString & endMarker )
static

Definition at line 2031 of file docparser.cpp.

2032{
2033 size_t j=0;
2034 if (i==0 || (data[i-1]!='@' && data[i-1]!='\\')) // not an escaped command
2035 {
2036 CHECK_FOR_COMMAND("dot",endMarker="enddot");
2037 CHECK_FOR_COMMAND("icode",endMarker="endicode");
2038 CHECK_FOR_COMMAND("code",endMarker="endcode");
2039 CHECK_FOR_COMMAND("msc",endMarker="endmsc");
2040 CHECK_FOR_COMMAND("mermaid",endMarker="endmermaid");
2041 CHECK_FOR_COMMAND("iverbatim",endMarker="endiverbatim");
2042 CHECK_FOR_COMMAND("verbatim",endMarker="endverbatim");
2043 CHECK_FOR_COMMAND("iliteral",endMarker="endiliteral");
2044 CHECK_FOR_COMMAND("latexonly",endMarker="endlatexonly");
2045 CHECK_FOR_COMMAND("htmlonly",endMarker="endhtmlonly");
2046 CHECK_FOR_COMMAND("xmlonly",endMarker="endxmlonly");
2047 CHECK_FOR_COMMAND("rtfonly",endMarker="endrtfonly");
2048 CHECK_FOR_COMMAND("manonly",endMarker="endmanonly");
2049 CHECK_FOR_COMMAND("docbookonly",endMarker="enddocbookonly");
2050 CHECK_FOR_COMMAND("startuml",endMarker="enduml");
2051 }
2052 //printf("isVerbatimSection(%s)=%d)\n",qPrint(QCString(&data[i]).left(10)),j);
2053 return j;
2054}

References CHECK_FOR_COMMAND.

Referenced by DocParser::processCopyDoc().

◆ skipToEndMarker()

size_t skipToEndMarker ( const char * data,
size_t i,
size_t len,
const QCString & endMarker )
static

Definition at line 2056 of file docparser.cpp.

2057{
2058 while (i<len)
2059 {
2060 if ((data[i]=='@' || data[i]=='\\') && // start of command character
2061 (i==0 || (data[i-1]!='@' && data[i-1]!='\\'))) // that is not escaped
2062 {
2063 if (i+endMarker.length()+1<=len && qstrncmp(data+i+1,endMarker.data(),endMarker.length())==0)
2064 {
2065 return i+endMarker.length()+1;
2066 }
2067 }
2068 i++;
2069 }
2070 // oops no endmarker found...
2071 return i<len ? i+1 : len;
2072}
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:170
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:176
int qstrncmp(const char *str1, const char *str2, size_t len)
Definition qcstring.h:75

References QCString::data(), QCString::length(), and qstrncmp().

Referenced by DocParser::processCopyDoc().

◆ validatingParseDoc()

IDocNodeASTPtr validatingParseDoc ( IDocParser & parserIntf,
const QCString & fileName,
int startLine,
const Definition * ctx,
const MemberDef * md,
const QCString & input,
const DocOptions & options )

Main entry point for the comment block parser.

Parameters
parserIntfThe parser object created via createDocParser()
fileNameFile in which the documentation block is found (or the name of the example file in case isExample is TRUE).
startLineLine at which the documentation block is found.
ctxClass or namespace to which this block belongs.
mdMember definition to which the documentation belongs. Can be 0.
inputString representation of the documentation block.
optionsOptional parameters.
Returns
An object representing the abstract syntax tree. Ownership of the pointer is handed over to the caller.

Definition at line 2188 of file docparser.cpp.

2195{
2196 DocParser *parser = dynamic_cast<DocParser*>(&parserIntf);
2197 assert(parser!=nullptr);
2198 if (parser==nullptr) return nullptr;
2199 //printf("validatingParseDoc(%s,%s)=[%s]\n",ctx?qPrint(ctx->name()):"<none>",
2200 // md?qPrint(md->name()):"<none>",
2201 // qPrint(input));
2202 //printf("========== validating %s at line %d\n",qPrint(fileName),startLine);
2203 //printf("---------------- input --------------------\n%s\n----------- end input -------------------\n",qPrint(input));
2204
2205 // set initial token
2206 parser->context.token = parser->tokenizer.resetToken();
2207
2208 if (ctx && ctx!=Doxygen::globalScope &&
2211 )
2212 )
2213 {
2215 }
2216 else if (ctx && ctx->definitionType()==Definition::TypePage)
2217 {
2218 const Definition *scope = (toPageDef(ctx))->getPageScope();
2219 if (scope && scope!=Doxygen::globalScope)
2220 {
2221 parser->context.context = substitute(scope->name(),getLanguageSpecificSeparator(scope->getLanguage(),true),"::");
2222 }
2223 }
2224 else if (ctx && ctx->definitionType()==Definition::TypeGroup)
2225 {
2226 const Definition *scope = (toGroupDef(ctx))->getGroupScope();
2227 if (scope && scope!=Doxygen::globalScope)
2228 {
2229 parser->context.context = substitute(scope->name(),getLanguageSpecificSeparator(scope->getLanguage(),true),"::");
2230 }
2231 }
2232 else
2233 {
2234 parser->context.context = "";
2235 }
2236 parser->context.scope = ctx;
2237 parser->context.lang = getLanguageFromFileName(fileName);
2238
2239 if (options.indexWords() && Doxygen::searchIndex.enabled())
2240 {
2241 if (md)
2242 {
2243 parser->context.searchUrl=md->getOutputFileBase();
2244 Doxygen::searchIndex.setCurrentDoc(md,md->anchor(),false);
2245 }
2246 else if (ctx)
2247 {
2248 parser->context.searchUrl=ctx->getOutputFileBase();
2249 Doxygen::searchIndex.setCurrentDoc(ctx,ctx->anchor(),false);
2250 }
2251 }
2252 else
2253 {
2254 parser->context.searchUrl="";
2255 }
2256
2257 parser->context.fileName = fileName;
2258 parser->context.relPath = (!options.linkFromIndex() && ctx) ?
2260 QCString("");
2261 //printf("ctx->name=%s relPath=%s\n",qPrint(ctx->name()),qPrint(parser->context.relPath));
2262 parser->context.memberDef = md;
2263 while (!parser->context.nodeStack.empty()) parser->context.nodeStack.pop();
2264 while (!parser->context.styleStack.empty()) parser->context.styleStack.pop();
2265 while (!parser->context.initialStyleStack.empty()) parser->context.initialStyleStack.pop();
2266 parser->context.inSeeBlock = FALSE;
2267 parser->context.inCodeStyle = FALSE;
2268 parser->context.xmlComment = FALSE;
2269 parser->context.insideHtmlLink = FALSE;
2270 parser->context.includeFileText = "";
2271 parser->context.includeFileOffset = 0;
2272 parser->context.includeFileLength = 0;
2273 parser->context.isExample = options.isExample();
2274 parser->context.exampleName = options.exampleName();
2275 parser->context.hasParamCommand = FALSE;
2276 parser->context.hasReturnCommand = FALSE;
2277 parser->context.retvalsFound.clear();
2278 parser->context.paramsFound.clear();
2279 parser->context.markdownSupport = options.markdownSupport();
2280 parser->context.autolinkSupport = options.autolinkSupport();
2281 if (md)
2282 {
2283 const ArgumentList &al=md->isDocsForDefinition() ? md->argumentList() : md->declArgumentList();
2284 parser->context.numParameters = static_cast<int>(al.size());
2285 }
2286 else
2287 {
2288 parser->context.numParameters = 0;
2289 }
2290 parser->context.paramPosition = 1;
2291
2292 //printf("Starting comment block at %s:%d\n",qPrint(parser->context.fileName),startLine);
2293 parser->tokenizer.setFileName(fileName);
2294 parser->tokenizer.setLineNr(startLine);
2295 size_t ioLen = input.length();
2296 QCString inpStr = parser->processCopyDoc(input.data(),ioLen);
2297 if (inpStr.isEmpty() || inpStr.at(inpStr.length()-1)!='\n')
2298 {
2299 inpStr+='\n';
2300 }
2301 //printf("processCopyDoc(in='%s' out='%s')\n",qPrint(input),qPrint(inpStr));
2302 parser->tokenizer.init(inpStr.data(),parser->context.fileName,
2304
2305 // build abstract syntax tree
2306 auto ast = std::make_unique<DocNodeAST>(DocRoot(parser,md!=nullptr,options.singleLine()));
2307 std::get<DocRoot>(ast->root).parse();
2308
2310 {
2311 // pretty print the result
2312 std::visit(PrintDocVisitor{},ast->root);
2313 }
2314
2315 if (md && md->isFunction())
2316 {
2317 parser->checkUnOrMultipleDocumentedParams();
2318 }
2320
2321 // reset token
2322 parser->tokenizer.resetToken();
2323
2324 //printf(">>>>>> end validatingParseDoc(%s,%s)\n",ctx?qPrint(ctx->name()):"<none>",
2325 // md?qPrint(md->name()):"<none>");
2326
2327 return ast;
2328}
This class represents an function or template argument list.
Definition arguments.h:65
size_t size() const
Definition arguments.h:100
@ PrintTree
Definition debug.h:34
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:133
The common base class of all entity definitions found in the sources.
Definition definition.h:77
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
virtual DefType definitionType() const =0
virtual QCString anchor() const =0
virtual QCString qualifiedName() const =0
virtual QCString getOutputFileBase() const =0
virtual const QCString & name() const =0
QCString processCopyDoc(const char *data, size_t &len)
Root node of documentation tree.
Definition docnode.h:1318
void init(const char *input, const QCString &fileName, bool markdownSupport, bool insideHtmlLink)
TokenInfo * resetToken()
static NamespaceDefMutable * globalScope
Definition doxygen.h:121
static SearchIndexIntf searchIndex
Definition doxygen.h:124
virtual const ArgumentList & argumentList() const =0
virtual bool isFunction() const =0
virtual bool isDocsForDefinition() const =0
virtual void detectUndocumentedParams(bool hasParamCommand, bool hasReturnCommand) const =0
virtual const ArgumentList & declArgumentList() const =0
char & at(size_t i)
Returns a reference to the character at index i.
Definition qcstring.h:597
GroupDef * toGroupDef(Definition *d)
PageDef * toPageDef(Definition *d)
Definition pagedef.cpp:502
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition qcstring.cpp:571
bool autolinkSupport() const
Definition docoptions.h:32
bool linkFromIndex() const
Definition docoptions.h:30
bool markdownSupport() const
Definition docoptions.h:31
QCString exampleName() const
Definition docoptions.h:28
bool indexWords() const
Definition docoptions.h:26
bool singleLine() const
Definition docoptions.h:29
bool isExample() const
Definition docoptions.h:27
StringMultiSet retvalsFound
Definition docparser_p.h:76
DocStyleChangeStack styleStack
Definition docparser_p.h:68
size_t includeFileLength
Definition docparser_p.h:90
DocNodeStack nodeStack
Definition docparser_p.h:67
StringMultiSet paramsFound
Definition docparser_p.h:77
QCString exampleName
Definition docparser_p.h:82
const Definition * scope
Definition docparser_p.h:61
QCString includeFileText
Definition docparser_p.h:88
TokenInfo * token
Definition docparser_p.h:95
DocStyleChangeStack initialStyleStack
Definition docparser_p.h:69
SrcLangExt lang
Definition docparser_p.h:85
QCString searchUrl
Definition docparser_p.h:83
size_t includeFileOffset
Definition docparser_p.h:89
const MemberDef * memberDef
Definition docparser_p.h:80
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5231
QCString relativePathToRoot(const QCString &name)
Definition util.cpp:3600
QCString getLanguageSpecificSeparator(SrcLangExt lang, bool classScope)
Returns the scope separator to use given the programming language lang.
Definition util.cpp:5915

References Definition::anchor(), MemberDef::argumentList(), QCString::at(), DocOptions::autolinkSupport(), DocParserContext::autolinkSupport, DocParser::checkUnOrMultipleDocumentedParams(), DocParser::context, DocParserContext::context, QCString::data(), MemberDef::declArgumentList(), Definition::definitionType(), MemberDef::detectUndocumentedParams(), DocOptions::exampleName(), DocParserContext::exampleName, FALSE, DocParserContext::fileName, Definition::getLanguage(), getLanguageFromFileName(), getLanguageSpecificSeparator(), Definition::getOutputFileBase(), Doxygen::globalScope, DocParserContext::hasParamCommand, DocParserContext::hasReturnCommand, DocParserContext::includeFileLength, DocParserContext::includeFileOffset, DocParserContext::includeFileText, DocParserContext::inCodeStyle, DocOptions::indexWords(), DocTokenizer::init(), DocParserContext::initialStyleStack, DocParserContext::inSeeBlock, DocParserContext::insideHtmlLink, MemberDef::isDocsForDefinition(), QCString::isEmpty(), DocOptions::isExample(), DocParserContext::isExample, Debug::isFlagSet(), MemberDef::isFunction(), DocParserContext::lang, QCString::length(), DocOptions::linkFromIndex(), DocOptions::markdownSupport(), DocParserContext::markdownSupport, DocParserContext::memberDef, Definition::name(), DocParserContext::nodeStack, DocParserContext::numParameters, DocParserContext::paramPosition, DocParserContext::paramsFound, Debug::PrintTree, DocParser::processCopyDoc(), Definition::qualifiedName(), relativePathToRoot(), DocParserContext::relPath, DocTokenizer::resetToken(), DocParserContext::retvalsFound, DocParserContext::scope, Doxygen::searchIndex, DocParserContext::searchUrl, DocTokenizer::setFileName(), DocTokenizer::setLineNr(), DocOptions::singleLine(), ArgumentList::size(), DocParserContext::styleStack, substitute(), toGroupDef(), DocParserContext::token, DocParser::tokenizer, toPageDef(), Definition::TypeClass, Definition::TypeGroup, Definition::TypeNamespace, Definition::TypePage, and DocParserContext::xmlComment.

Referenced by addPerlModDocBlock(), generateBriefDoc(), OutputList::generateDoc(), generateHtmlOutput(), getSQLDocBlock(), parseCommentAsText(), ConceptDefImpl::writeBriefDescription(), DirDefImpl::writeBriefDescription(), FileDefImpl::writeBriefDescription(), GroupDefImpl::writeBriefDescription(), ModuleDefImpl::writeBriefDescription(), NamespaceDefImpl::writeBriefDescription(), MemberDefImpl::writeDeclaration(), ClassDefImpl::writeDeclarationLink(), ConceptDefImpl::writeDeclarationLink(), ModuleDefImpl::writeDeclarationLink(), MemberList::writePlainDeclarations(), and writeXMLDocBlock().

◆ validatingParseText()

IDocNodeASTPtr validatingParseText ( IDocParser & parser,
const QCString & input )

Main entry point for parsing simple text fragments. These fragments are limited to words, whitespace and symbols.

Definition at line 2383 of file docparser.cpp.

2384{
2385 DocParser *parser = dynamic_cast<DocParser*>(&parserIntf);
2386 assert(parser!=nullptr);
2387 if (parser==nullptr) return nullptr;
2388
2389 // set initial token
2390 parser->context.token = parser->tokenizer.resetToken();
2391
2392 //printf("------------ input ---------\n%s\n"
2393 // "------------ end input -----\n",input);
2394 //parser->context.token = new TokenInfo;
2395 parser->context.context = "";
2396 parser->context.fileName = "<parseText>";
2397 parser->context.relPath = "";
2398 parser->context.memberDef = nullptr;
2399 while (!parser->context.nodeStack.empty()) parser->context.nodeStack.pop();
2400 while (!parser->context.styleStack.empty()) parser->context.styleStack.pop();
2401 while (!parser->context.initialStyleStack.empty()) parser->context.initialStyleStack.pop();
2402 parser->context.inSeeBlock = FALSE;
2403 parser->context.inCodeStyle = FALSE;
2404 parser->context.xmlComment = FALSE;
2405 parser->context.insideHtmlLink = FALSE;
2406 parser->context.includeFileText = "";
2407 parser->context.includeFileOffset = 0;
2408 parser->context.includeFileLength = 0;
2409 parser->context.isExample = FALSE;
2410 parser->context.exampleName = "";
2411 parser->context.hasParamCommand = FALSE;
2412 parser->context.hasReturnCommand = FALSE;
2413 parser->context.retvalsFound.clear();
2414 parser->context.paramsFound.clear();
2415 parser->context.searchUrl="";
2416 parser->context.lang = SrcLangExt::Unknown;
2417 parser->context.markdownSupport = Config_getBool(MARKDOWN_SUPPORT);
2418 parser->context.autolinkSupport = FALSE;
2419
2420
2421 auto ast = std::make_unique<DocNodeAST>(DocText(parser));
2422
2423 if (!input.isEmpty())
2424 {
2425 parser->tokenizer.setLineNr(1);
2426 parser->tokenizer.init(input.data(),parser->context.fileName,
2428
2429 // build abstract syntax tree
2430 std::get<DocText>(ast->root).parse();
2431
2433 {
2434 // pretty print the result
2435 std::visit(PrintDocVisitor{},ast->root);
2436 }
2437 }
2438
2439 return ast;
2440}
Root node of a text fragment.
Definition docnode.h:1309
#define Config_getBool(name)
Definition config.h:33

References DocParserContext::autolinkSupport, Config_getBool, DocParser::context, DocParserContext::context, QCString::data(), DocParserContext::exampleName, FALSE, DocParserContext::fileName, DocParserContext::hasParamCommand, DocParserContext::hasReturnCommand, DocParserContext::includeFileLength, DocParserContext::includeFileOffset, DocParserContext::includeFileText, DocParserContext::inCodeStyle, DocTokenizer::init(), DocParserContext::initialStyleStack, DocParserContext::inSeeBlock, DocParserContext::insideHtmlLink, QCString::isEmpty(), DocParserContext::isExample, Debug::isFlagSet(), DocParserContext::lang, DocParserContext::markdownSupport, DocParserContext::memberDef, DocParserContext::nodeStack, DocParserContext::paramsFound, Debug::PrintTree, DocParserContext::relPath, DocTokenizer::resetToken(), DocParserContext::retvalsFound, DocParserContext::searchUrl, DocTokenizer::setLineNr(), DocParserContext::styleStack, DocParserContext::token, DocParser::tokenizer, and DocParserContext::xmlComment.

Referenced by RTFGenerator::endIndexSection(), and OutputList::parseText().

◆ validatingParseTitle()

IDocNodeASTPtr validatingParseTitle ( IDocParser & parserIntf,
const QCString & fileName,
int lineNr,
const QCString & input )

Main entry point for parsing titles. These allow limited markup commands

Definition at line 2330 of file docparser.cpp.

2331{
2332 DocParser *parser = dynamic_cast<DocParser*>(&parserIntf);
2333 assert(parser!=nullptr);
2334 if (parser==nullptr) return nullptr;
2335
2336 // set initial token
2337 parser->context.token = parser->tokenizer.resetToken();
2338
2339 //printf("------------ input ---------\n%s\n"
2340 // "------------ end input -----\n",input);
2341 parser->context.context = "";
2342 parser->context.fileName = fileName;
2343 parser->context.relPath = "";
2344 parser->context.memberDef = nullptr;
2345 while (!parser->context.nodeStack.empty()) parser->context.nodeStack.pop();
2346 while (!parser->context.styleStack.empty()) parser->context.styleStack.pop();
2347 while (!parser->context.initialStyleStack.empty()) parser->context.initialStyleStack.pop();
2348 parser->context.inSeeBlock = FALSE;
2349 parser->context.inCodeStyle = FALSE;
2350 parser->context.xmlComment = FALSE;
2351 parser->context.insideHtmlLink = FALSE;
2352 parser->context.includeFileText = "";
2353 parser->context.includeFileOffset = 0;
2354 parser->context.includeFileLength = 0;
2355 parser->context.isExample = FALSE;
2356 parser->context.exampleName = "";
2357 parser->context.hasParamCommand = FALSE;
2358 parser->context.hasReturnCommand = FALSE;
2359 parser->context.retvalsFound.clear();
2360 parser->context.paramsFound.clear();
2361 parser->context.searchUrl="";
2362 parser->context.lang = SrcLangExt::Unknown;
2363 parser->context.markdownSupport = Config_getBool(MARKDOWN_SUPPORT);
2364 parser->context.autolinkSupport = false;
2365
2366 auto ast = std::make_unique<DocNodeAST>(DocTitle(parser,nullptr));
2367
2368 if (!input.isEmpty())
2369 {
2370 // build abstract syntax tree from title string
2371 std::get<DocTitle>(ast->root).parseFromString(nullptr,input);
2372
2374 {
2375 // pretty print the result
2376 std::visit(PrintDocVisitor{},ast->root);
2377 }
2378 }
2379
2380 return ast;
2381}
Node representing a simple section title.
Definition docnode.h:608

References DocParserContext::autolinkSupport, Config_getBool, DocParser::context, DocParserContext::context, DocParserContext::exampleName, FALSE, DocParserContext::fileName, DocParserContext::hasParamCommand, DocParserContext::hasReturnCommand, DocParserContext::includeFileLength, DocParserContext::includeFileOffset, DocParserContext::includeFileText, DocParserContext::inCodeStyle, DocParserContext::initialStyleStack, DocParserContext::inSeeBlock, DocParserContext::insideHtmlLink, QCString::isEmpty(), DocParserContext::isExample, Debug::isFlagSet(), DocParserContext::lang, DocParserContext::markdownSupport, DocParserContext::memberDef, DocParserContext::nodeStack, DocParserContext::paramsFound, Debug::PrintTree, DocParserContext::relPath, DocTokenizer::resetToken(), DocParserContext::retvalsFound, DocParserContext::searchUrl, DocParserContext::styleStack, DocParserContext::token, DocParser::tokenizer, and DocParserContext::xmlComment.

Referenced by parseCommentAsHtml().