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

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

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

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