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

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

#include <src/docnode.h>

Inheritance diagram for DocLink:
Collaboration diagram for DocLink:

Public Member Functions

 DocLink (DocParser *parser, DocNodeVariant *parent, const QCString &target)
QCString parse (bool, bool isXmlLink=FALSE)
QCString file () const
QCString relPath () const
QCString ref () const
QCString anchor () 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

QCString m_file
QCString m_relPath
QCString m_ref
QCString m_anchor
QCString m_refText

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

Node representing a link to some item.

Definition at line 758 of file docnode.h.

Constructor & Destructor Documentation

◆ DocLink()

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

Definition at line 996 of file docnode.cpp.

997{
998 const Definition *compound = nullptr;
999 QCString anchor;
1000 m_refText = target;
1001 m_relPath = parser->context.relPath;
1002 if (!m_refText.isEmpty() && m_refText.at(0)=='#')
1003 {
1004 m_refText = m_refText.right(m_refText.length()-1);
1005 }
1006 if (resolveLink(parser->context.context,stripKnownExtensions(target),
1007 parser->context.inSeeBlock,&compound,anchor,
1008 parser->context.lang,parser->context.prefix))
1009 {
1010 m_anchor = anchor;
1011 if (compound && compound->isLinkable())
1012 {
1013 m_file = compound->getOutputFileBase();
1014 m_ref = compound->getReference();
1015 }
1016 else if (compound && compound->definitionType()==Definition::TypeFile &&
1017 (toFileDef(compound))->generateSourceFile()
1018 ) // undocumented file that has source code we can link to
1019 {
1020 m_file = compound->getSourceFileBase();
1021 m_ref = compound->getReference();
1022 }
1023 return;
1024 }
1025
1026 // bogus link target
1027 warn_doc_error(parser->context.fileName,parser->tokenizer.getLineNr(),"unable to resolve link to '{}' for \\link command",
1028 target);
1029}
virtual bool isLinkable() const =0
virtual DefType definitionType() const =0
virtual QCString getReference() const =0
virtual QCString getSourceFileBase() const =0
virtual QCString getOutputFileBase() const =0
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:141
DocParser * parser()
Definition docnode.h:98
DocNodeVariant * parent()
Definition docnode.h:90
static QCString stripKnownExtensions(const QCString &text)
Definition docnode.cpp:105
FileDef * toFileDef(Definition *d)
Definition filedef.cpp:1966
#define warn_doc_error(file, line, fmt,...)
Definition message.h:112
bool resolveLink(const QCString &scName, const QCString &lr, bool, const Definition **resContext, QCString &resAnchor, SrcLangExt lang, const QCString &prefix)
Definition util.cpp:2724

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.

Member Function Documentation

◆ anchor()

◆ file()

◆ parse()

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

Definition at line 1032 of file docnode.cpp.

1033{
1034 AUTO_TRACE();
1035 QCString result;
1036 auto ns = AutoNodeStack(parser(),thisVariant());
1037
1038 Token tok = parser()->tokenizer.lex();
1039 while (!tok.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF))
1040 {
1041 if (!parser()->defaultHandleToken(thisVariant(),tok,children(),FALSE))
1042 {
1043 switch (tok.value())
1044 {
1045 case TokenRetval::TK_COMMAND_AT:
1046 // fall through
1047 case TokenRetval::TK_COMMAND_BS:
1048 switch (Mappers::cmdMapper->map(parser()->context.token->name))
1049 {
1051 if (isJavaLink)
1052 {
1053 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"'{{@link...' ended with '{:c}{}' command",
1054 tok.command_to_char(),parser()->context.token->name);
1055 }
1056 goto endlink;
1057 default:
1058 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Illegal command '{:c}{}' as part of a \\link",
1059 tok.command_to_char(),parser()->context.token->name);
1060 break;
1061 }
1062 break;
1063 case TokenRetval::TK_SYMBOL:
1064 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unsupported symbol '{}' found as part of a \\link",
1065 parser()->context.token->name);
1066 break;
1067 case TokenRetval::TK_HTMLTAG:
1068 if (parser()->context.token->name!="see" || !isXmlLink)
1069 {
1070 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected xml/html command {} found as part of a \\link",
1071 parser()->context.token->name);
1072 }
1073 goto endlink;
1074 case TokenRetval::TK_LNKWORD:
1075 case TokenRetval::TK_WORD:
1076 if (isJavaLink) // special case to detect closing }
1077 {
1078 QCString w = parser()->context.token->name;
1079 int p = 0;
1080 if (w=="}")
1081 {
1082 goto endlink;
1083 }
1084 else if ((p=w.find('}'))!=-1)
1085 {
1086 int l = static_cast<int>(w.length());
1087 children().append<DocWord>(parser(),thisVariant(),w.left(p));
1088 if (p<l-1) // something left after the } (for instance a .)
1089 {
1090 result=w.right(l-p-1);
1091 }
1092 goto endlink;
1093 }
1094 }
1096 break;
1097 default:
1098 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected token {}",tok.to_string());
1099 break;
1100 }
1101 }
1102 tok = parser()->tokenizer.lex();
1103 }
1104 if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
1105 {
1106 warn_doc_error(parser()->context.fileName,
1107 parser()->tokenizer.getLineNr(),
1108 "Unexpected end of comment while inside link command");
1109 }
1110endlink:
1111
1112 if (children().empty()) // no link text
1113 {
1114 children().append<DocWord>(parser(),thisVariant(),m_refText);
1115 }
1116
1118 return result;
1119}
DocNodeList & children()
Definition docnode.h:143
DocNodeVariant * thisVariant()
Definition docnode.h:93
DocTokenizer tokenizer
void handlePendingStyleCommands(DocNodeVariant *parent, DocNodeList &children)
DocParserContext context
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
QCString right(size_t len) const
Definition qcstring.h:234
QCString left(size_t len) const
Definition qcstring.h:229
TOKEN_SPECIFICATIONS RETVAL_SPECIFICATIONS const char * to_string() const
TokenRetval value() const
bool is_any_of(ARGS... args) const
char command_to_char() const
#define AUTO_TRACE(...)
Definition docnode.cpp:47
const Mapper< CommandType > * cmdMapper
#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:1396
TokenInfo * token
Definition docparser_p.h:95
QCString name

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()

◆ relPath()

QCString DocLink::relPath ( ) const
inline

Definition at line 764 of file docnode.h.

764{ return m_relPath; }

References m_relPath.

Referenced by HtmlDocVisitor::operator()().

Member Data Documentation

◆ m_anchor

QCString DocLink::m_anchor
private

Definition at line 772 of file docnode.h.

Referenced by anchor().

◆ m_file

QCString DocLink::m_file
private

Definition at line 769 of file docnode.h.

Referenced by DocLink(), and file().

◆ m_ref

QCString DocLink::m_ref
private

Definition at line 771 of file docnode.h.

Referenced by DocLink(), and ref().

◆ m_refText

QCString DocLink::m_refText
private

Definition at line 773 of file docnode.h.

Referenced by DocLink(), and parse().

◆ m_relPath

QCString DocLink::m_relPath
private

Definition at line 770 of file docnode.h.

Referenced by DocLink(), and relPath().


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