Skip to main content

The DocRef Class Reference

Node representing a reference to some item. More...

Declaration

class DocRef { ... }

Included Headers

#include <src/docnode.h>

Base class

classDocCompoundNode

Base class for nodes with children. More...

Public Constructors Index

DocRef (DocParser *parser, DocNodeVariant *parent, const QCString &target, const QCString &context)

Public Member Functions Index

voidparse ()
QCStringfile () const
QCStringrelPath () const
QCStringref () const
QCStringanchor () const
QCStringtargetTitle () const
SectionTypesectionType () const
boolhasLinkText () const
boolrefToAnchor () const
boolrefToSection () const
boolrefToTable () const
boolisSubPage () const

Private Member Attributes Index

RefTypem_refType = Unknown
SectionTypem_sectionType = SectionType::Anchor
boolm_isSubPage = false
QCStringm_file
QCStringm_relPath
QCStringm_ref
QCStringm_anchor
QCStringm_text

Description

Node representing a reference to some item.

Definition at line 777 of file docnode.h.

Public Constructors

DocRef()

DocRef::DocRef (DocParser * parser, DocNodeVariant * parent, const QCString & target, const QCString & context)

Declaration at line 780 of file docnode.h, definition at line 705 of file docnode.cpp.

707{
708 const Definition *compound = nullptr;
710 AUTO_TRACE("target='{}',context='{}'",target,context);
711 ASSERT(!target.isEmpty());
712 m_relPath = parser->context.relPath;
713 auto lang = parser->context.lang;
714 const SectionInfo *sec = SectionManager::instance().find(parser->context.prefix+target);
715 if (sec==nullptr && !parser->context.prefix.isEmpty())
716 {
717 sec = SectionManager::instance().find(target);
718 }
719
720 if (sec==nullptr && getLanguageFromFileName(target)==SrcLangExt::Markdown) // lookup as markdown file
721 {
723 }
724 if (sec) // ref to section or anchor
725 {
726 PageDef *pd = nullptr;
727 int secLevel = sec->type().level();
728 if (secLevel==SectionType::Page)
729 {
730 pd = Doxygen::pageLinkedMap->find(target);
731 }
732 m_text = sec->title();
733 if (m_text.isEmpty()) m_text = sec->label();
734
735 m_ref = sec->ref();
737 if (secLevel==SectionType::Anchor)
738 {
740 }
741 else if (secLevel==SectionType::Table)
742 {
744 }
745 else
746 {
748 }
749 m_isSubPage = pd && pd->hasParentPage();
750 if (secLevel!=SectionType::Page || m_isSubPage)
751 {
752 m_anchor = pd ? pd->getOutputFileBase() : sec->label();
753 }
754 m_sectionType = sec->type();
755 //printf("m_text=%s,m_ref=%s,m_file=%s,type=%d\n",
756 // qPrint(m_text),qPrint(m_ref),qPrint(m_file),m_refType);
757 AUTO_TRACE_EXIT("section");
758 return;
759 }
760 else if (resolveLink(context,target,true,&compound,anchor,lang,parser->context.prefix))
761 {
762 bool isFile = compound ?
765 FALSE;
766 m_text = linkToText(lang,target,isFile);
768 if (compound && compound->isLinkable()) // ref to compound
769 {
770 if (anchor.isEmpty() && /* compound link */
771 compound->definitionType()==Definition::TypeGroup && /* is group */
772 !toGroupDef(compound)->groupTitle().isEmpty() /* with title */
773 )
774 {
775 m_text=(toGroupDef(compound))->groupTitle(); // use group's title as link
776 }
777 else if (compound->definitionType()==Definition::TypeMember &&
778 toMemberDef(compound)->isObjCMethod())
779 {
780 // Objective C Method
781 const MemberDef *member = toMemberDef(compound);
782 bool localLink = parser->context.memberDef ? member->getClassDef()==parser->context.memberDef->getClassDef() : FALSE;
783 m_text = member->objCMethodName(localLink,parser->context.inSeeBlock);
784 }
785 else if (Config_getBool(HIDE_SCOPE_NAMES))
786 {
788 }
789
790 m_file = compound->getOutputFileBase();
791 m_ref = compound->getReference();
792 //printf("isFile=%d compound=%s (%d)\n",isFile,qPrint(compound->name()),
793 // compound->definitionType());
794 AUTO_TRACE_EXIT("compound");
795 return;
796 }
797 else if (compound && compound->definitionType()==Definition::TypeFile &&
798 toFileDef(compound)->generateSourceFile()
799 ) // undocumented file that has source code we can link to
800 {
801 m_file = compound->getSourceFileBase();
802 m_ref = compound->getReference();
803 AUTO_TRACE_EXIT("source");
804 return;
805 }
806 else
807 {
808 AUTO_TRACE_EXIT("compound '{}' not linkable",compound?compound->name():"none");
809 }
810 }
811 m_text = target;
812 warn_doc_error(parser->context.fileName,parser->tokenizer.getLineNr(),"unable to resolve reference to '{}' for \\ref command",
813 target);
814}

References DocNode::Anchor, SectionType::Anchor, anchor, ASSERT, AUTO_TRACE, AUTO_TRACE_EXIT, Config_getBool, Definition::definitionType, DocCompoundNode::DocCompoundNode, FALSE, SectionInfo::fileName, LinkedMap< T, Hash, KeyEqual, Map >::find, MemberDef::getClassDef, getLanguageFromFileName, Definition::getOutputFileBase, Definition::getReference, Definition::getSourceFileBase, PageDef::hasParentPage, SectionManager::instance, QCString::isEmpty, Definition::isLinkable, SectionInfo::label, SectionType::level, linkToText, m_anchor, m_file, m_isSubPage, m_ref, m_refType, m_relPath, m_sectionType, m_text, markdownFileNameToId, Definition::name, MemberDef::objCMethodName, SectionType::Page, Doxygen::pageLinkedMap, DocNode::parent, DocNode::parser, SectionInfo::ref, resolveLink, DocNode::Section, stripKnownExtensions, stripScope, DocNode::Table, SectionType::Table, SectionInfo::title, toFileDef, toGroupDef, toMemberDef, TRUE, SectionInfo::type, Definition::TypeFile, Definition::TypeGroup, Definition::TypeMember, Definition::TypePage, DocNode::Unknown and warn_doc_error.

Public Member Functions

anchor()

file()

hasLinkText()

isSubPage()

bool DocRef::isSubPage ()
inline

parse()

void DocRef::parse ()

Declaration at line 781 of file docnode.h, definition at line 857 of file docnode.cpp.

858{
859 AUTO_TRACE();
860 auto ns = AutoNodeStack(parser(),thisVariant());
861
862 Token tok = parser()->tokenizer.lex();
863 while (!tok.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF))
864 {
865 if (!parser()->defaultHandleToken(thisVariant(),tok,children()))
866 {
867 switch (tok.value())
868 {
869 case TokenRetval::TK_HTMLTAG:
870 break;
871 default:
873 break;
874 }
875 }
876 tok=parser()->tokenizer.lex();
877 }
878
879 if (children().empty() && !m_text.isEmpty())
880 {
881 QCString text = m_text;
882 if (parser()->context.insideHtmlLink)
883 {
884 // we already in a link/title only output anchor
885 text = m_anchor;
886 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),
887 "Potential recursion while resolving \\ref command!");
888 }
892 parser()->popContext();
896 }
897
899}

References AUTO_TRACE, DocCompoundNode::children, DocParser::context, DocParser::errorHandleDefaultToken, FALSE, flattenParagraphs, DocParser::handlePendingStyleCommands, DocParserContext::insideHtmlLink, DocParser::internalValidatingParseDoc, Token::is_any_of, DocTokenizer::lex, m_anchor, m_text, DocNode::parser, DocParser::popContext, DocParser::pushContext, DocTokenizer::setStatePara, DocNode::thisVariant, DocParser::tokenizer, TRUE, Token::value and warn_doc_error.

ref()

refToAnchor()

bool DocRef::refToAnchor ()
inline

Definition at line 789 of file docnode.h.

789 bool refToAnchor() const { return m_refType==Anchor; }

References DocNode::Anchor and m_refType.

Referenced by PrintDocVisitor::operator().

refToSection()

bool DocRef::refToSection ()
inline

Definition at line 790 of file docnode.h.

790 bool refToSection() const { return m_refType==Section; }

References m_refType and DocNode::Section.

Referenced by LatexDocVisitor::operator() and PrintDocVisitor::operator().

refToTable()

bool DocRef::refToTable ()
inline

Definition at line 791 of file docnode.h.

791 bool refToTable() const { return m_refType==Table; }

References m_refType and DocNode::Table.

Referenced by LatexDocVisitor::operator() and PrintDocVisitor::operator().

relPath()

QCString DocRef::relPath ()
inline

Definition at line 783 of file docnode.h.

783 QCString relPath() const { return m_relPath; }

Reference m_relPath.

Referenced by HtmlDocVisitor::operator().

sectionType()

SectionType DocRef::sectionType ()
inline

Definition at line 787 of file docnode.h.

Reference m_sectionType.

Referenced by LatexDocVisitor::operator().

targetTitle()

Private Member Attributes

m_anchor

QCString DocRef::m_anchor

Definition at line 801 of file docnode.h.

Referenced by anchor, DocRef and parse.

m_file

QCString DocRef::m_file

Definition at line 798 of file docnode.h.

Referenced by DocRef and file.

m_isSubPage

bool DocRef::m_isSubPage = false

Definition at line 797 of file docnode.h.

797 bool m_isSubPage = false;

Referenced by DocRef and isSubPage.

m_ref

QCString DocRef::m_ref

Definition at line 800 of file docnode.h.

Referenced by DocRef and ref.

m_refType

RefType DocRef::m_refType = Unknown

Definition at line 795 of file docnode.h.

Referenced by DocRef, refToAnchor, refToSection and refToTable.

m_relPath

QCString DocRef::m_relPath

Definition at line 799 of file docnode.h.

Referenced by DocRef and relPath.

m_sectionType

SectionType DocRef::m_sectionType = SectionType::Anchor

Definition at line 796 of file docnode.h.

Referenced by DocRef and sectionType.

m_text

QCString DocRef::m_text

Definition at line 802 of file docnode.h.

Referenced by DocRef, parse and targetTitle.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.