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

Constructor & Destructor Documentation

◆ DocLink()

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

Definition at line 925 of file docnode.cpp.

926{
927 const Definition *compound = nullptr;
928 QCString anchor;
929 m_refText = target;
930 m_relPath = parser->context.relPath;
931 if (!m_refText.isEmpty() && m_refText.at(0)=='#')
932 {
933 m_refText = m_refText.right(m_refText.length()-1);
934 }
935 if (resolveLink(parser->context.context,stripKnownExtensions(target),parser->context.inSeeBlock,&compound,anchor,parser->context.prefix))
936 {
938 if (compound && compound->isLinkable())
939 {
940 m_file = compound->getOutputFileBase();
941 m_ref = compound->getReference();
942 }
943 else if (compound && compound->definitionType()==Definition::TypeFile &&
944 (toFileDef(compound))->generateSourceFile()
945 ) // undocumented file that has source code we can link to
946 {
947 m_file = compound->getSourceFileBase();
948 m_ref = compound->getReference();
949 }
950 return;
951 }
952
953 // bogus link target
954 warn_doc_error(parser->context.fileName,parser->tokenizer.getLineNr(),"unable to resolve link to '%s' for \\link command",
955 qPrint(target));
956}
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:1892
#define warn_doc_error(file, line, fmt,...)
Definition message.h:74
const char * qPrint(const char *s)
Definition qcstring.h:661
bool resolveLink(const QCString &scName, const QCString &lr, bool, const Definition **resContext, QCString &resAnchor, const QCString &prefix)
Definition util.cpp:3126

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

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

744{ return m_relPath; }

References m_relPath.

Referenced by HtmlDocVisitor::operator()().

Member Data Documentation

◆ m_anchor

QCString DocLink::m_anchor
private

Definition at line 752 of file docnode.h.

Referenced by anchor().

◆ m_file

QCString DocLink::m_file
private

Definition at line 749 of file docnode.h.

Referenced by DocLink(), and file().

◆ m_ref

QCString DocLink::m_ref
private

Definition at line 751 of file docnode.h.

Referenced by DocLink(), and ref().

◆ m_refText

QCString DocLink::m_refText
private

Definition at line 753 of file docnode.h.

Referenced by DocLink(), and parse().

◆ m_relPath

QCString DocLink::m_relPath
private

Definition at line 750 of file docnode.h.

Referenced by DocLink(), and relPath().


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