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

Root node of documentation tree. More...

#include <src/docnode.h>

Inheritance diagram for DocRoot:
Collaboration diagram for DocRoot:

Public Member Functions

 DocRoot (DocParser *parser, bool indent, bool sl)
void parse ()
bool indent () const
bool singleLine () const
bool isEmpty () const
Public Member Functions inherited from DocCompoundNode
 DocCompoundNode (DocParser *parser, DocNodeVariant *parent)
DocNodeListchildren ()
const DocNodeListchildren () const
Public Member Functions inherited from DocNode
 DocNode (DocParser *parser, DocNodeVariant *parent)
 ~DocNode ()=default
DocNodeVariantparent ()
const DocNodeVariantparent () const
DocNodeVariantthisVariant ()
const DocNodeVariantthisVariant () const
void setThisVariant (DocNodeVariant *thisVariant)
DocParserparser ()
const DocParserparser () const
void setParent (DocNodeVariant *parent)
bool isPreformatted () const

Private Attributes

bool m_indent = false
bool m_singleLine = false

Additional Inherited Members

Protected Types inherited from DocNode
enum  RefType { Unknown , Anchor , Section , Table }
Protected Member Functions inherited from DocNode
void setInsidePreformatted (bool p)

Detailed Description

Root node of documentation tree.

Definition at line 1307 of file docnode.h.

Constructor & Destructor Documentation

◆ DocRoot()

DocRoot::DocRoot ( DocParser * parser,
bool indent,
bool sl )
inline

Definition at line 1310 of file docnode.h.

DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:140
DocParser * parser()
Definition docnode.h:97
bool indent() const
Definition docnode.h:1313
bool m_singleLine
Definition docnode.h:1319
bool m_indent
Definition docnode.h:1318

References DocCompoundNode::DocCompoundNode(), indent(), m_indent, m_singleLine, and DocNode::parser().

Member Function Documentation

◆ indent()

bool DocRoot::indent ( ) const
inline

Definition at line 1313 of file docnode.h.

1313{ return m_indent; }

References m_indent.

Referenced by DocRoot(), and RTFDocVisitor::operator()().

◆ isEmpty()

bool DocRoot::isEmpty ( ) const
inline

Definition at line 1315 of file docnode.h.

1315{ return children().empty(); }
DocNodeList & children()
Definition docnode.h:142
bool empty() const
checks whether the container is empty
Definition growvector.h:140

References DocCompoundNode::children(), and GrowVector< T >::empty().

◆ parse()

void DocRoot::parse ( )

Definition at line 6068 of file docnode.cpp.

6069{
6070 AUTO_TRACE();
6071 auto ns = AutoNodeStack(parser(),thisVariant());
6073 Token retval = Token::make_TK_NONE();
6074
6075 // first parse any number of paragraphs
6076 bool isFirst=TRUE;
6077 DocPara *lastPar = nullptr;
6078 do
6079 {
6080 {
6081 children().append<DocPara>(parser(),thisVariant());
6082 DocPara *par = children().get_last<DocPara>();
6083 if (isFirst) { par->markFirst(); isFirst=FALSE; }
6084 retval=par->parse();
6085 if (par->isEmpty() && par->attribs().empty())
6086 {
6087 children().pop_back();
6088 }
6089 else
6090 {
6091 lastPar = par;
6092 }
6093 }
6094 auto checkParagraph = [this,&retval](Token t,int level,const char *sectionType,const char *parentSectionType) {
6095 if (retval == t)
6096 {
6097 if (!AnchorGenerator::instance().isGenerated(parser()->context.token->sectionId.str()))
6098 {
6099 warn_doc_error(parser()->context.fileName,
6100 parser()->tokenizer.getLineNr(),
6101 "found {} command (id: '{}') outside of {} context!",
6102 sectionType,parser()->context.token->sectionId,parentSectionType);
6103 }
6104 while (retval==t)
6105 {
6106 if (!parser()->context.token->sectionId.isEmpty())
6107 {
6108 const SectionInfo *sec=SectionManager::instance().find(parser()->context.token->sectionId);
6109 if (sec)
6110 {
6111 children().append<DocSection>(parser(),thisVariant(),
6112 level,
6114 retval = children().get_last<DocSection>()->parse();
6115 }
6116 else
6117 {
6118 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Invalid {} id '{}'; ignoring {}",
6119 sectionType,parser()->context.token->sectionId,sectionType);
6120 retval = Token::make_TK_NONE();
6121 }
6122 }
6123 else
6124 {
6125 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Missing id for {}; ignoring {}",sectionType,sectionType);
6126 retval = Token::make_TK_NONE();
6127 }
6128 }
6129 }
6130 };
6131 checkParagraph(Token::make_RetVal_SubSubParagraph(), 6, "subsubparagraph", "subparagraph" );
6132 checkParagraph(Token::make_RetVal_SubParagraph(), 5, "subparagraph", "paragraph" );
6133 checkParagraph(Token::make_RetVal_Paragraph(), 4, "paragraph", "subsubsection" );
6134 checkParagraph(Token::make_RetVal_Subsubsection(), 3, "subsubsection", "subsection" );
6135 checkParagraph(Token::make_RetVal_Subsection(), 2, "subsection", "section" );
6136
6137 if (retval.is(TokenRetval::TK_LISTITEM))
6138 {
6139 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Invalid list item found");
6140 }
6141 if (retval.is(TokenRetval::RetVal_Internal))
6142 {
6143 children().append<DocInternal>(parser(),thisVariant());
6144 retval = children().get_last<DocInternal>()->parse(1);
6145 }
6146 } while (!retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF,TokenRetval::RetVal_Section));
6147 if (lastPar) lastPar->markLast();
6148
6149 //printf("DocRoot::parse() retval=%d %d\n",retval,TokenRetval::RetVal_Section);
6150 // then parse any number of level1 sections
6151 while (retval.is(TokenRetval::RetVal_Section))
6152 {
6153 if (!parser()->context.token->sectionId.isEmpty())
6154 {
6155 const SectionInfo *sec=SectionManager::instance().find(parser()->context.token->sectionId);
6156 if (sec)
6157 {
6158 children().append<DocSection>(parser(),thisVariant(),
6159 1,
6161 retval = children().get_last<DocSection>()->parse();
6162 }
6163 else
6164 {
6165 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Invalid section id '{}'; ignoring section",parser()->context.token->sectionId);
6166 retval = Token::make_TK_NONE();
6167 }
6168 }
6169 else
6170 {
6171 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Missing id for section; ignoring section");
6172 retval = Token::make_TK_NONE();
6173 }
6174 }
6175
6177}
static AnchorGenerator & instance()
Returns the singleton instance.
Definition anchor.cpp:38
DocNodeVariant * thisVariant()
Definition docnode.h:92
void markLast(bool v=TRUE)
Definition docnode.h:1081
DocTokenizer tokenizer
DocParserContext context
void handleUnclosedStyleCommands()
void parse()
Definition docnode.cpp:6068
void setStatePara()
void pop_back()
removes the last element
Definition growvector.h:115
const T * find(const std::string &key) const
Definition linkedmap.h:47
static SectionManager & instance()
returns a reference to the singleton
Definition section.h:175
bool is(TokenRetval rv) const
bool is_any_of(ARGS... args) const
#define AUTO_TRACE(...)
Definition docnode.cpp:46
#define warn_doc_error(file, line, fmt,...)
Definition message.h:112
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
void append(Args &&... args)
Append a new DocNodeVariant to the list by constructing it with type T and parameters Args.
Definition docnode.h:1394
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1405
TokenInfo * token
Definition docparser_p.h:92
QCString sectionId

References DocNodeList::append(), AUTO_TRACE, DocCompoundNode::children(), DocParser::context, FALSE, LinkedMap< T, Hash, KeyEqual, Map >::find(), DocNodeList::get_last(), DocParser::handleUnclosedStyleCommands(), AnchorGenerator::instance(), SectionManager::instance(), Token::is(), Token::is_any_of(), DocPara::markLast(), parse(), DocNode::parser(), GrowVector< T >::pop_back(), TokenInfo::sectionId, DocTokenizer::setStatePara(), DocNode::thisVariant(), DocParserContext::token, DocParser::tokenizer, TRUE, and warn_doc_error.

Referenced by parse().

◆ singleLine()

bool DocRoot::singleLine ( ) const
inline

Definition at line 1314 of file docnode.h.

1314{ return m_singleLine; }

References m_singleLine.

Referenced by RTFDocVisitor::operator()().

Member Data Documentation

◆ m_indent

bool DocRoot::m_indent = false
private

Definition at line 1318 of file docnode.h.

Referenced by DocRoot(), and indent().

◆ m_singleLine

bool DocRoot::m_singleLine = false
private

Definition at line 1319 of file docnode.h.

Referenced by DocRoot(), and singleLine().


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