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 767 of file docnode.h.

Constructor & Destructor Documentation

◆ DocLink()

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

Definition at line 997 of file docnode.cpp.

998{
999 const Definition *compound = nullptr;
1000 QCString anchor;
1001 m_refText = target;
1002 m_relPath = parser->context.relPath;
1003 if (!m_refText.isEmpty() && m_refText.at(0)=='#')
1004 {
1005 m_refText = m_refText.right(m_refText.length()-1);
1006 }
1007 if (resolveLink(parser->context.context,stripKnownExtensions(target),
1008 parser->context.inSeeBlock,&compound,anchor,
1009 parser->context.lang,parser->context.prefix))
1010 {
1011 m_anchor = anchor;
1012 if (compound && compound->isLinkable())
1013 {
1014 m_file = compound->getOutputFileBase();
1015 m_ref = compound->getReference();
1016 }
1017 else if (compound && compound->definitionType()==Definition::TypeFile &&
1018 (toFileDef(compound))->generateSourceFile()
1019 ) // undocumented file that has source code we can link to
1020 {
1021 m_file = compound->getSourceFileBase();
1022 m_ref = compound->getReference();
1023 }
1024 return;
1025 }
1026
1027 // bogus link target
1028 warn_doc_error(parser->context.fileName,parser->tokenizer.getLineNr(),"unable to resolve link to '{}' for \\link command",
1029 target);
1030}
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:106
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:2734

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 1033 of file docnode.cpp.

1034{
1035 AUTO_TRACE();
1036 QCString result;
1037 auto ns = AutoNodeStack(parser(),thisVariant());
1038
1039 Token tok = parser()->tokenizer.lex();
1040 while (!tok.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF))
1041 {
1042 if (!parser()->defaultHandleToken(thisVariant(),tok,children(),FALSE))
1043 {
1044 switch (tok.value())
1045 {
1046 case TokenRetval::TK_COMMAND_AT:
1047 // fall through
1048 case TokenRetval::TK_COMMAND_BS:
1049 switch (Mappers::cmdMapper->map(parser()->context.token->name))
1050 {
1052 if (isJavaLink)
1053 {
1054 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"'{{@link...' ended with '{:c}{}' command",
1055 tok.command_to_char(),parser()->context.token->name);
1056 }
1057 goto endlink;
1058 default:
1059 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Illegal command '{:c}{}' as part of a \\link",
1060 tok.command_to_char(),parser()->context.token->name);
1061 break;
1062 }
1063 break;
1064 case TokenRetval::TK_SYMBOL:
1065 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unsupported symbol '{}' found as part of a \\link",
1066 parser()->context.token->name);
1067 break;
1068 case TokenRetval::TK_HTMLTAG:
1069 if (parser()->context.token->name!="see" || !isXmlLink)
1070 {
1071 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected xml/html command {} found as part of a \\link",
1072 parser()->context.token->name);
1073 }
1074 goto endlink;
1075 case TokenRetval::TK_LNKWORD:
1076 case TokenRetval::TK_WORD:
1077 if (isJavaLink) // special case to detect closing }
1078 {
1079 QCString w = parser()->context.token->name;
1080 int p = 0;
1081 if (w=="}")
1082 {
1083 goto endlink;
1084 }
1085 else if ((p=w.find('}'))!=-1)
1086 {
1087 int l = static_cast<int>(w.length());
1088 children().append<DocWord>(parser(),thisVariant(),w.left(p));
1089 if (p<l-1) // something left after the } (for instance a .)
1090 {
1091 result=w.right(l-p-1);
1092 }
1093 goto endlink;
1094 }
1095 }
1097 break;
1098 default:
1099 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected token {}",tok.to_string());
1100 break;
1101 }
1102 }
1103 tok = parser()->tokenizer.lex();
1104 }
1105 if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
1106 {
1107 warn_doc_error(parser()->context.fileName,
1108 parser()->tokenizer.getLineNr(),
1109 "Unexpected end of comment while inside link command");
1110 }
1111endlink:
1112
1113 if (children().empty()) // no link text
1114 {
1115 children().append<DocWord>(parser(),thisVariant(),m_refText);
1116 }
1117
1119 return result;
1120}
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:48
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:1405
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 773 of file docnode.h.

773{ return m_relPath; }

References m_relPath.

Referenced by HtmlDocVisitor::operator()().

Member Data Documentation

◆ m_anchor

QCString DocLink::m_anchor
private

Definition at line 781 of file docnode.h.

Referenced by anchor().

◆ m_file

QCString DocLink::m_file
private

Definition at line 778 of file docnode.h.

Referenced by DocLink(), and file().

◆ m_ref

QCString DocLink::m_ref
private

Definition at line 780 of file docnode.h.

Referenced by DocLink(), and ref().

◆ m_refText

QCString DocLink::m_refText
private

Definition at line 782 of file docnode.h.

Referenced by DocLink(), and parse().

◆ m_relPath

QCString DocLink::m_relPath
private

Definition at line 779 of file docnode.h.

Referenced by DocLink(), and relPath().


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