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 }
 
- Protected Member Functions inherited from DocNode
void setInsidePreformatted (bool p)
 

Detailed Description

Node representing a link to some item.

Definition at line 752 of file docnode.h.

Constructor & Destructor Documentation

◆ DocLink()

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

Definition at line 932 of file docnode.cpp.

933{
934 const Definition *compound = nullptr;
935 QCString anchor;
936 m_refText = target;
937 m_relPath = parser->context.relPath;
938 if (!m_refText.isEmpty() && m_refText.at(0)=='#')
939 {
940 m_refText = m_refText.right(m_refText.length()-1);
941 }
942 if (resolveLink(parser->context.context,stripKnownExtensions(target),
943 parser->context.inSeeBlock,&compound,anchor,
944 parser->context.lang,parser->context.prefix))
945 {
947 if (compound && compound->isLinkable())
948 {
949 m_file = compound->getOutputFileBase();
950 m_ref = compound->getReference();
951 }
952 else if (compound && compound->definitionType()==Definition::TypeFile &&
953 (toFileDef(compound))->generateSourceFile()
954 ) // undocumented file that has source code we can link to
955 {
956 m_file = compound->getSourceFileBase();
957 m_ref = compound->getReference();
958 }
959 return;
960 }
961
962 // bogus link target
963 warn_doc_error(parser->context.fileName,parser->tokenizer.getLineNr(),"unable to resolve link to '{}' for \\link command",
964 target);
965}
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:140
DocParser * parser()
Definition docnode.h:97
DocNodeVariant * parent()
Definition docnode.h:89
static QCString stripKnownExtensions(const QCString &text)
Definition docnode.cpp:103
FileDef * toFileDef(Definition *d)
Definition filedef.cpp:1894
#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:3185

References anchor(), Definition::definitionType(), DocCompoundNode::DocCompoundNode(), Definition::getReference(), Definition::getSourceFileBase(), if(), 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 968 of file docnode.cpp.

969{
970 AUTO_TRACE();
971 QCString result;
972 auto ns = AutoNodeStack(parser(),thisVariant());
973
974 Token tok = parser()->tokenizer.lex();
975 while (!tok.is_any_of(TokenRetval::TK_NONE, TokenRetval::TK_EOF))
976 {
977 if (!parser()->defaultHandleToken(thisVariant(),tok,children(),FALSE))
978 {
979 switch (tok.value())
980 {
981 case TokenRetval::TK_COMMAND_AT:
982 // fall through
983 case TokenRetval::TK_COMMAND_BS:
984 switch (Mappers::cmdMapper->map(parser()->context.token->name))
985 {
987 if (isJavaLink)
988 {
989 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"'{{@link...' ended with '{:c}{}' command",
990 tok.command_to_char(),parser()->context.token->name);
991 }
992 goto endlink;
993 default:
994 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Illegal command '{:c}{}' as part of a \\link",
995 tok.command_to_char(),parser()->context.token->name);
996 break;
997 }
998 break;
999 case TokenRetval::TK_SYMBOL:
1000 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unsupported symbol '{}' found as part of a \\link",
1001 parser()->context.token->name);
1002 break;
1003 case TokenRetval::TK_HTMLTAG:
1004 if (parser()->context.token->name!="see" || !isXmlLink)
1005 {
1006 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected xml/html command {} found as part of a \\link",
1007 parser()->context.token->name);
1008 }
1009 goto endlink;
1010 case TokenRetval::TK_LNKWORD:
1011 case TokenRetval::TK_WORD:
1012 if (isJavaLink) // special case to detect closing }
1013 {
1014 QCString w = parser()->context.token->name;
1015 int p = 0;
1016 if (w=="}")
1017 {
1018 goto endlink;
1019 }
1020 else if ((p=w.find('}'))!=-1)
1021 {
1022 int l = static_cast<int>(w.length());
1023 children().append<DocWord>(parser(),thisVariant(),w.left(p));
1024 if (p<l-1) // something left after the } (for instance a .)
1025 {
1026 result=w.right(l-p-1);
1027 }
1028 goto endlink;
1029 }
1030 }
1032 break;
1033 default:
1034 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"Unexpected token {}",tok.to_string());
1035 break;
1036 }
1037 }
1038 tok = parser()->tokenizer.lex();
1039 }
1040 if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF))
1041 {
1042 warn_doc_error(parser()->context.fileName,
1043 parser()->tokenizer.getLineNr(),
1044 "Unexpected end of comment while inside link command");
1045 }
1046endlink:
1047
1048 if (children().empty()) // no link text
1049 {
1050 children().append<DocWord>(parser(),thisVariant(),m_refText);
1051 }
1052
1054 return result;
1055}
DocNodeList & children()
Definition docnode.h:142
DocNodeVariant * thisVariant()
Definition docnode.h:92
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:153
QCString right(size_t len) const
Definition qcstring.h:219
QCString left(size_t len) const
Definition qcstring.h:214
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:46
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:1393
TokenInfo * token
Definition docparser_p.h:92
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 758 of file docnode.h.

758{ return m_relPath; }

References m_relPath.

Referenced by HtmlDocVisitor::operator()().

Member Data Documentation

◆ m_anchor

QCString DocLink::m_anchor
private

Definition at line 766 of file docnode.h.

Referenced by anchor().

◆ m_file

QCString DocLink::m_file
private

Definition at line 763 of file docnode.h.

Referenced by DocLink(), and file().

◆ m_ref

QCString DocLink::m_ref
private

Definition at line 765 of file docnode.h.

Referenced by DocLink(), and ref().

◆ m_refText

QCString DocLink::m_refText
private

Definition at line 767 of file docnode.h.

Referenced by DocLink(), and parse().

◆ m_relPath

QCString DocLink::m_relPath
private

Definition at line 764 of file docnode.h.

Referenced by DocLink(), and relPath().


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