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

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 empty () const
Public Member Functions inherited from DocCompoundNode
 DocCompoundNode (DocParser *parser, DocNodeVariant *parent)
DocNodeList & children ()
const DocNodeList & children () const
Public Member Functions inherited from DocNode
 DocNode (DocParser *parser, DocNodeVariant *parent)
 ~DocNode ()=default
DocNodeVariant * parent ()
const DocNodeVariant * parent () const
DocNodeVariant * thisVariant ()
const DocNodeVariant * thisVariant () const
void setThisVariant (DocNodeVariant *thisVariant)
DocParser * parser ()
const DocParser * parser () 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 ,
  Requirement
}
Protected Member Functions inherited from DocNode
void setInsidePreformatted (bool p)

Detailed Description

Root node of documentation tree.

Definition at line 1317 of file docnode.h.

Constructor & Destructor Documentation

◆ DocRoot()

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

Definition at line 1320 of file docnode.h.

DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:141
DocParser * parser()
Definition docnode.h:97
bool indent() const
Definition docnode.h:1323
bool m_singleLine
Definition docnode.h:1329
bool m_indent
Definition docnode.h:1328

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

Member Function Documentation

◆ empty()

bool DocRoot::empty ( ) const
inline

Definition at line 1325 of file docnode.h.

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

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

◆ indent()

bool DocRoot::indent ( ) const
inline

Definition at line 1323 of file docnode.h.

1323{ return m_indent; }

References m_indent.

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

◆ parse()

void DocRoot::parse ( )

Definition at line 6368 of file docnode.cpp.

6369{
6370 AUTO_TRACE();
6371 auto ns = AutoNodeStack(parser(),thisVariant());
6373 Token retval = Token::make_TK_NONE();
6374
6375 // first parse any number of paragraphs
6376 bool isFirst=true;
6377 DocPara *lastPar = nullptr;
6378 do
6379 {
6380 {
6381 children().append<DocPara>(parser(),thisVariant());
6382 DocPara *par = children().get_last<DocPara>();
6383 if (isFirst) { par->markFirst(); isFirst=false; }
6384 retval=par->parse();
6385 if (par->empty() && par->attribs().empty())
6386 {
6387 children().pop_back();
6388 }
6389 else
6390 {
6391 lastPar = par;
6392 }
6393 }
6394 auto checkParagraph = [this,&retval](Token t,int level,const char *sectionType,const char *parentSectionType) {
6395 if (retval == t)
6396 {
6397 if (!AnchorGenerator::instance().isGenerated(parser()->context.token->sectionId.str()))
6398 {
6399 warn_doc_error(parser()->context.fileName,
6400 parser()->tokenizer.getLineNr(),
6401 "found {} command (id: '{}') outside of {} context!",
6402 sectionType,parser()->context.token->sectionId,parentSectionType);
6403 }
6404 while (retval==t)
6405 {
6406 if (!parser()->context.token->sectionId.empty())
6407 {
6408 const SectionInfo *sec=SectionManager::instance().find(parser()->context.token->sectionId);
6409 if (sec)
6410 {
6411 children().append<DocSection>(parser(),thisVariant(),
6412 level,
6414 retval = children().get_last<DocSection>()->parse();
6415 }
6416 else
6417 {
6418 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Invalid {} id '{}'; ignoring {}",
6419 sectionType,parser()->context.token->sectionId,sectionType);
6420 retval = Token::make_TK_NONE();
6421 }
6422 }
6423 else
6424 {
6425 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Missing id for {}; ignoring {}",sectionType,sectionType);
6426 retval = Token::make_TK_NONE();
6427 }
6428 }
6429 }
6430 };
6431 checkParagraph(Token::make_RetVal_SubSubParagraph(), 6, "subsubparagraph", "subparagraph" );
6432 checkParagraph(Token::make_RetVal_SubParagraph(), 5, "subparagraph", "paragraph" );
6433 checkParagraph(Token::make_RetVal_Paragraph(), 4, "paragraph", "subsubsection" );
6434 checkParagraph(Token::make_RetVal_Subsubsection(), 3, "subsubsection", "subsection" );
6435 checkParagraph(Token::make_RetVal_Subsection(), 2, "subsection", "section" );
6436
6437 if (retval.is(TokenRetval::TK_LISTITEM))
6438 {
6439 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Invalid list item found");
6440 }
6441 if (retval.is(TokenRetval::RetVal_Internal))
6442 {
6443 children().append<DocInternal>(parser(),thisVariant());
6444 retval = children().get_last<DocInternal>()->parse(1);
6445 }
6446 } while (!retval.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF,TokenRetval::RetVal_Section));
6447 if (lastPar) lastPar->markLast();
6448
6449 //printf("DocRoot::parse() retval=%d %d\n",retval,TokenRetval::RetVal_Section);
6450 // then parse any number of level1 sections
6451 while (retval.is(TokenRetval::RetVal_Section))
6452 {
6453 if (!parser()->context.token->sectionId.empty())
6454 {
6455 const SectionInfo *sec=SectionManager::instance().find(parser()->context.token->sectionId);
6456 if (sec)
6457 {
6458 children().append<DocSection>(parser(),thisVariant(),
6459 1,
6461 retval = children().get_last<DocSection>()->parse();
6462 }
6463 else
6464 {
6465 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Invalid section id '{}'; ignoring section",parser()->context.token->sectionId);
6466 retval = Token::make_TK_NONE();
6467 }
6468 }
6469 else
6470 {
6471 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Missing id for section; ignoring section");
6472 retval = Token::make_TK_NONE();
6473 }
6474 }
6475
6477}
static AnchorGenerator & instance()
Returns the singleton instance.
Definition anchor.cpp:41
DocNodeVariant * thisVariant()
Definition docnode.h:92
void append(Args &&... args)
Append a new DocNodeVariant to the list by constructing it with type T and parameters Args.
Definition docnode.h:1404
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1415
void markLast(bool v=true)
Definition docnode.h:1095
DocTokenizer tokenizer
DocParserContext context
void handleUnclosedStyleCommands()
void parse()
Definition docnode.cpp:6368
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:179
bool is(TokenRetval rv) const
bool is_any_of(ARGS... args) const
DString sectionId
#define AUTO_TRACE(...)
Definition docnode.cpp:53
#define warn_doc_error(file, line, fmt,...)
Definition message.h:112
TokenInfo * token
Definition docparser_p.h:94

References DocNodeList::append(), AUTO_TRACE, DocCompoundNode::children(), DocParser::context, 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, and warn_doc_error.

Referenced by parse().

◆ singleLine()

bool DocRoot::singleLine ( ) const
inline

Definition at line 1324 of file docnode.h.

1324{ return m_singleLine; }

References m_singleLine.

Referenced by RTFDocVisitor::operator()().

Member Data Documentation

◆ m_indent

bool DocRoot::m_indent = false
private

Definition at line 1328 of file docnode.h.

Referenced by DocRoot(), and indent().

◆ m_singleLine

bool DocRoot::m_singleLine = false
private

Definition at line 1329 of file docnode.h.

Referenced by DocRoot(), and singleLine().


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