Skip to main content

The DocLink Class Reference

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

Declaration

class DocLink { ... }

Included Headers

#include <src/docnode.h>

Base class

classDocCompoundNode

Base class for nodes with children. More...

Public Constructors Index

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

Public Member Functions Index

QCStringparse (bool, bool isXmlLink=FALSE)
QCStringfile () const
QCStringrelPath () const
QCStringref () const
QCStringanchor () const

Private Member Attributes Index

QCStringm_file
QCStringm_relPath
QCStringm_ref
QCStringm_anchor
QCStringm_refText

Description

Node representing a link to some item.

Definition at line 758 of file docnode.h.

Public Constructors

DocLink()

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

Declaration at line 761 of file docnode.h, definition at line 962 of file docnode.cpp.

963{
964 const Definition *compound = nullptr;
966 m_refText = target;
967 m_relPath = parser->context.relPath;
968 if (!m_refText.isEmpty() && m_refText.at(0)=='#')
969 {
970 m_refText = m_refText.right(m_refText.length()-1);
971 }
972 if (resolveLink(parser->context.context,stripKnownExtensions(target),
973 parser->context.inSeeBlock,&compound,anchor,
974 parser->context.lang,parser->context.prefix))
975 {
976 m_anchor = anchor;
977 if (compound && compound->isLinkable())
978 {
979 m_file = compound->getOutputFileBase();
980 m_ref = compound->getReference();
981 }
982 else if (compound && compound->definitionType()==Definition::TypeFile &&
983 (toFileDef(compound))->generateSourceFile()
984 ) // undocumented file that has source code we can link to
985 {
986 m_file = compound->getSourceFileBase();
987 m_ref = compound->getReference();
988 }
989 return;
990 }
991
992 // bogus link target
993 warn_doc_error(parser->context.fileName,parser->tokenizer.getLineNr(),"unable to resolve link to '{}' for \\link command",
994 target);
995}

References anchor, Definition::definitionType, DocCompoundNode::DocCompoundNode, Definition::getReference, Definition::getSourceFileBase, m_file, m_ref, m_refText, m_relPath, DocNode::parent, DocNode::parser, resolveLink, stripKnownExtensions, toFileDef and Definition::TypeFile.

Public Member Functions

anchor()

file()

parse()

QCString DocLink::parse (bool isJavaLink, bool isXmlLink=FALSE)

Declaration at line 762 of file docnode.h, definition at line 998 of file docnode.cpp.

998QCString DocLink::parse(bool isJavaLink,bool isXmlLink)
999{
1000 AUTO_TRACE();
1001 QCString result;
1002 auto ns = AutoNodeStack(parser(),thisVariant());
1003
1004 Token tok = parser()->tokenizer.lex();
1005 while (!tok.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF))
1006 {
1007 if (!parser()->defaultHandleToken(thisVariant(),tok,children(),FALSE))
1008 {
1009 switch (tok.value())
1010 {
1011 case TokenRetval::TK_COMMAND_AT:
1012 // fall through
1013 case TokenRetval::TK_COMMAND_BS:
1014 switch (Mappers::cmdMapper->map(parser()->context.token->name))
1015 {
1017 if (isJavaLink)
1018 {
1019 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"'{{@link...' ended with '{:c}{}' command",
1020 tok.command_to_char(),parser()->context.token->name);
1021 }
1022 goto endlink;
1023 default:
1024 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Illegal command '{:c}{}' as part of a \\link",
1025 tok.command_to_char(),parser()->context.token->name);
1026 break;
1027 }
1028 break;
1029 case TokenRetval::TK_SYMBOL:
1030 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unsupported symbol '{}' found as part of a \\link",
1031 parser()->context.token->name);
1032 break;
1033 case TokenRetval::TK_HTMLTAG:
1034 if (parser()->context.token->name!="see" || !isXmlLink)
1035 {
1036 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected xml/html command {} found as part of a \\link",
1037 parser()->context.token->name);
1038 }
1039 goto endlink;
1040 case TokenRetval::TK_LNKWORD:
1041 case TokenRetval::TK_WORD:
1042 if (isJavaLink) // special case to detect closing }
1043 {
1045 int p = 0;
1046 if (w=="}")
1047 {
1048 goto endlink;
1049 }
1050 else if ((p=w.find('}'))!=-1)
1051 {
1052 int l = static_cast<int>(w.length());
1054 if (p<l-1) // something left after the } (for instance a .)
1055 {
1056 result=w.right(l-p-1);
1057 }
1058 goto endlink;
1059 }
1060 }
1062 break;
1063 default:
1064 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected token {}",tok.to_string());
1065 break;
1066 }
1067 }
1068 tok = parser()->tokenizer.lex();
1069 }
1070 if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
1071 {
1072 warn_doc_error(parser()->context.fileName,
1073 parser()->tokenizer.getLineNr(),
1074 "Unexpected end of comment while inside link command");
1075 }
1076endlink:
1077
1078 if (children().empty()) // no link text
1079 {
1081 }
1082
1084 return result;
1085}

References DocNodeList::append, AUTO_TRACE, DocCompoundNode::children, CMD_ENDLINK, Mappers::cmdMapper, Token::command_to_char, DocParser::context, FALSE, QCString::find, DocParser::handlePendingStyleCommands, Token::is_any_of, QCString::left, QCString::length, DocTokenizer::lex, m_refText, TokenInfo::name, DocNode::parser, QCString::right, DocNode::thisVariant, Token::to_string, DocParserContext::token, DocParser::tokenizer, Token::value and warn_doc_error.

ref()

QCString DocLink::ref ()
inline

relPath()

QCString DocLink::relPath ()
inline

Definition at line 764 of file docnode.h.

764 QCString relPath() const { return m_relPath; }

Reference m_relPath.

Referenced by HtmlDocVisitor::operator().

Private Member Attributes

m_anchor

QCString DocLink::m_anchor

Definition at line 772 of file docnode.h.

Referenced by anchor.

m_file

QCString DocLink::m_file

Definition at line 769 of file docnode.h.

Referenced by DocLink and file.

m_ref

QCString DocLink::m_ref

Definition at line 771 of file docnode.h.

Referenced by DocLink and ref.

m_refText

QCString DocLink::m_refText

Definition at line 773 of file docnode.h.

Referenced by DocLink and parse.

m_relPath

QCString DocLink::m_relPath

Definition at line 770 of file docnode.h.

Referenced by DocLink and relPath.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.