Public Member Functions | Private Types | Private Attributes | List of all members
DocRef Class Reference

#include <docparser.h>

Inheritance diagram for DocRef:
CompAccept< DocRef > DocNode

Public Member Functions

 DocRef (DocNode *parent, const QCString &target, const QCString &context)
 
void parse ()
 
Kind kind () const
 
QCString file () const
 
QCString relPath () const
 
QCString ref () const
 
QCString anchor () const
 
QCString targetTitle () const
 
bool hasLinkText () const
 
bool refToAnchor () const
 
bool refToSection () const
 
bool refToTable () const
 
bool isSubPage () const
 
void accept (DocVisitor *v)
 
- Public Member Functions inherited from CompAccept< DocRef >
 CompAccept ()
 
virtual ~CompAccept ()
 
void accept (DocRef *obj, DocVisitor *v)
 
const QList< DocNode > & children () const
 
QList< DocNode > & children ()
 
- Public Member Functions inherited from DocNode
 DocNode ()
 
virtual ~DocNode ()
 
DocNodeparent () const
 
void setParent (DocNode *parent)
 
bool isPreformatted () const
 

Private Types

enum  RefType { Unknown, Anchor, Section, Table }
 

Private Attributes

RefType m_refType
 
bool m_isSubPage
 
QCString m_file
 
QCString m_relPath
 
QCString m_ref
 
QCString m_anchor
 
QCString m_text
 

Additional Inherited Members

- Public Types inherited from DocNode
enum  Kind {
  Kind_Root = 0, Kind_Word = 1, Kind_WhiteSpace = 2, Kind_Para = 3,
  Kind_AutoList = 4, Kind_AutoListItem = 5, Kind_Symbol = 6, Kind_URL = 7,
  Kind_StyleChange = 8, Kind_SimpleSect = 9, Kind_Title = 10, Kind_SimpleList = 11,
  Kind_SimpleListItem = 12, Kind_Section = 13, Kind_Verbatim = 14, Kind_XRefItem = 15,
  Kind_HtmlList = 16, Kind_HtmlListItem = 17, Kind_HtmlDescList = 18, Kind_HtmlDescData = 19,
  Kind_HtmlDescTitle = 20, Kind_HtmlTable = 21, Kind_HtmlRow = 22, Kind_HtmlCell = 23,
  Kind_HtmlCaption = 24, Kind_LineBreak = 25, Kind_HorRuler = 26, Kind_Anchor = 27,
  Kind_IndexEntry = 28, Kind_Internal = 29, Kind_HRef = 30, Kind_Include = 31,
  Kind_IncOperator = 32, Kind_HtmlHeader = 33, Kind_Image = 34, Kind_DotFile = 35,
  Kind_Link = 36, Kind_Ref = 37, Kind_Formula = 38, Kind_SecRefItem = 39,
  Kind_SecRefList = 40, Kind_SimpleSectSep = 41, Kind_LinkedWord = 42, Kind_ParamSect = 43,
  Kind_ParamList = 44, Kind_InternalRef = 45, Kind_Copy = 46, Kind_Text = 47,
  Kind_MscFile = 48, Kind_HtmlBlockQuote = 49, Kind_VhdlFlow = 50, Kind_ParBlock = 51,
  Kind_DiaFile = 52
}
 
- Protected Member Functions inherited from DocNode
void setInsidePreformatted (bool p)
 
- Protected Attributes inherited from CompAccept< DocRef >
QList< DocNodem_children
 
- Protected Attributes inherited from DocNode
DocNodem_parent
 

Detailed Description

Node representing a reference to some item

Definition at line 821 of file docparser.h.

Member Enumeration Documentation

enum DocRef::RefType
private
Enumerator
Unknown 
Anchor 
Section 
Table 

Definition at line 840 of file docparser.h.

Constructor & Destructor Documentation

DocRef::DocRef ( DocNode parent,
const QCString target,
const QCString context 
)

Definition at line 2432 of file docparser.cpp.

2432  :
2434 {
2435  m_parent = parent;
2436  Definition *compound = 0;
2437  QCString anchor;
2438  //printf("DocRef::DocRef(target=%s,context=%s)\n",target.data(),context.data());
2439  ASSERT(!target.isEmpty());
2440  SrcLangExt lang = getLanguageFromFileName(target);
2441  m_relPath = g_relPath;
2442  SectionInfo *sec = Doxygen::sectionDict->find(target);
2443  if (sec==0 && lang==SrcLangExt_Markdown) // lookup as markdown file
2444  {
2446  }
2447  if (sec) // ref to section or anchor
2448  {
2449  PageDef *pd = 0;
2450  if (sec->type==SectionInfo::Page)
2451  {
2452  pd = Doxygen::pageSDict->find(target);
2453  }
2454  m_text = sec->title;
2455  if (m_text.isEmpty()) m_text = sec->label;
2456 
2457  m_ref = sec->ref;
2459  if (sec->type==SectionInfo::Anchor)
2460  {
2461  m_refType = Anchor;
2462  }
2463  else if (sec->type==SectionInfo::Table)
2464  {
2465  m_refType = Table;
2466  }
2467  else
2468  {
2469  m_refType = Section;
2470  }
2471  m_isSubPage = pd && pd->hasParentPage();
2472  if (sec->type!=SectionInfo::Page || m_isSubPage) m_anchor = sec->label;
2473  //printf("m_text=%s,m_ref=%s,m_file=%s,m_refToAnchor=%d type=%d\n",
2474  // m_text.data(),m_ref.data(),m_file.data(),m_refToAnchor,sec->type);
2475  return;
2476  }
2477  else if (resolveLink(context,target,TRUE,&compound,anchor))
2478  {
2479  bool isFile = compound ?
2480  (compound->definitionType()==Definition::TypeFile ||
2481  compound->definitionType()==Definition::TypePage ? TRUE : FALSE) :
2482  FALSE;
2483  m_text = linkToText(compound?compound->getLanguage():SrcLangExt_Unknown,target,isFile);
2484  m_anchor = anchor;
2485  if (compound && compound->isLinkable()) // ref to compound
2486  {
2487  if (anchor.isEmpty() && /* compound link */
2488  compound->definitionType()==Definition::TypeGroup && /* is group */
2489  ((GroupDef *)compound)->groupTitle() /* with title */
2490  )
2491  {
2492  m_text=((GroupDef *)compound)->groupTitle(); // use group's title as link
2493  }
2494  else if (compound->definitionType()==Definition::TypeMember &&
2495  ((MemberDef*)compound)->isObjCMethod())
2496  {
2497  // Objective C Method
2498  MemberDef *member = (MemberDef*)compound;
2499  bool localLink = g_memberDef ? member->getClassDef()==g_memberDef->getClassDef() : FALSE;
2500  m_text = member->objCMethodName(localLink,g_inSeeBlock);
2501  }
2502 
2503  m_file = compound->getOutputFileBase();
2504  m_ref = compound->getReference();
2505  //printf("isFile=%d compound=%s (%d)\n",isFile,compound->name().data(),
2506  // compound->definitionType());
2507  return;
2508  }
2509  else if (compound && compound->definitionType()==Definition::TypeFile &&
2510  ((FileDef*)compound)->generateSourceFile()
2511  ) // undocumented file that has source code we can link to
2512  {
2513  m_file = compound->getSourceFileBase();
2514  m_ref = compound->getReference();
2515  return;
2516  }
2517  }
2518  m_text = target;
2519  warn_doc_error(g_fileName,doctokenizerYYlineno,"unable to resolve reference to `%s' for \\ref command",
2520  qPrint(target));
2521 }
DocNode * parent() const
Definition: docparser.h:147
static QCString g_fileName
Definition: docparser.cpp:95
QCString anchor() const
Definition: docparser.h:830
virtual bool isLinkable() const =0
virtual QCString getReference() const
bool resolveLink(const char *scName, const char *lr, bool, Definition **resContext, QCString &resAnchor)
Definition: util.cpp:4753
bool isEmpty() const
Definition: qcstring.h:189
SectionType type
Definition: section.h:58
QCString m_relPath
Definition: docparser.h:844
int doctokenizerYYlineno
QCString ref
Definition: section.h:59
const bool FALSE
Definition: qglobal.h:370
QCString label
Definition: section.h:56
static QCString g_relPath
Definition: docparser.cpp:96
void warn_doc_error(const char *file, int line, const char *fmt,...)
Definition: message.cpp:210
RefType m_refType
Definition: docparser.h:841
virtual QCString getOutputFileBase() const =0
SrcLangExt
Definition: types.h:41
virtual DefType definitionType() const =0
bool hasParentPage() const
Definition: pagedef.cpp:89
DocNode * m_parent
Definition: docparser.h:163
QCString m_file
Definition: docparser.h:843
QCString linkToText(SrcLangExt lang, const char *link, bool isFileName)
Definition: util.cpp:4659
virtual QCString getSourceFileBase() const
Definition: definition.cpp:885
static MemberDef * g_memberDef
Definition: docparser.cpp:101
SrcLangExt getLanguage() const
QCString m_anchor
Definition: docparser.h:846
QCString fileName
Definition: section.h:61
static SectionDict * sectionDict
Definition: doxygen.h:117
static PageSDict * pageSDict
Definition: doxygen.h:102
ClassDef * getClassDef() const
Definition: memberdef.cpp:4070
QCString title
Definition: section.h:57
bool m_isSubPage
Definition: docparser.h:842
SrcLangExt getLanguageFromFileName(const QCString fileName)
Definition: util.cpp:7061
QCString m_ref
Definition: docparser.h:845
QCString objCMethodName(bool localLink, bool showStatic) const
Definition: memberdef.cpp:4003
A model of a page symbol.
Definition: pagedef.h:29
static QCString stripKnownExtensions(const char *text)
Definition: docparser.cpp:625
static bool g_inSeeBlock
Definition: docparser.cpp:88
QCString markdownFileNameToId(const QCString &fileName)
Definition: markdown.cpp:2344
T * find(const char *key)
Definition: sortdict.h:232
QCString m_text
Definition: docparser.h:847
const char * qPrint(const char *s)
Definition: qcstring.h:797
const bool TRUE
Definition: qglobal.h:371
#define ASSERT(x)
Definition: qglobal.h:590

Member Function Documentation

void DocRef::accept ( DocVisitor v)
inlinevirtual

Acceptor function for node visitors. Part of the visitor pattern.

Parameters
vAbstract visitor.

Implements DocNode.

Definition at line 837 of file docparser.h.

837 { CompAccept<DocRef>::accept(this,v); }
void accept(T *obj, DocVisitor *v)
Definition: docparser.h:177
QCString DocRef::anchor ( ) const
inline

Definition at line 830 of file docparser.h.

830 { return m_anchor; }
QCString m_anchor
Definition: docparser.h:846
QCString DocRef::file ( ) const
inline

Definition at line 827 of file docparser.h.

827 { return m_file; }
QCString m_file
Definition: docparser.h:843
bool DocRef::hasLinkText ( ) const
inline

Definition at line 832 of file docparser.h.

832 { return !m_children.isEmpty(); }
QList< DocNode > m_children
Definition: docparser.h:189
bool isEmpty() const
Definition: qlist.h:67
bool DocRef::isSubPage ( ) const
inline

Definition at line 836 of file docparser.h.

836 { return m_isSubPage; }
bool m_isSubPage
Definition: docparser.h:842
Kind DocRef::kind ( ) const
inlinevirtual

Returns the kind of node. Provides runtime type information

Implements DocNode.

Definition at line 826 of file docparser.h.

826 { return Kind_Ref; }
void DocRef::parse ( )

Definition at line 2552 of file docparser.cpp.

2553 {
2554  g_nodeStack.push(this);
2555  DBG(("DocRef::parse() start\n"));
2556 
2557  int tok;
2558  while ((tok=doctokenizerYYlex()))
2559  {
2560  if (!defaultHandleToken(this,tok,m_children))
2561  {
2562  switch (tok)
2563  {
2564  case TK_COMMAND:
2565  warn_doc_error(g_fileName,doctokenizerYYlineno,"Illegal command %s as part of a \\ref",
2566  qPrint(g_token->name));
2567  break;
2568  case TK_SYMBOL:
2569  warn_doc_error(g_fileName,doctokenizerYYlineno,"Unsupported symbol %s found",
2570  qPrint(g_token->name));
2571  break;
2572  case TK_HTMLTAG:
2573  break;
2574  default:
2575  warn_doc_error(g_fileName,doctokenizerYYlineno,"Unexpected token %s",
2576  tokToString(tok));
2577  break;
2578  }
2579  }
2580  }
2581 
2582  if (m_children.isEmpty() && !m_text.isEmpty())
2583  {
2590  }
2591 
2593 
2594  DocNode *n=g_nodeStack.pop();
2595  ASSERT(n==this);
2596 }
static QCString g_fileName
Definition: docparser.cpp:95
QList< DocNode > m_children
Definition: docparser.h:189
bool isEmpty() const
Definition: qcstring.h:189
static void flattenParagraphs(DocNode *root, QList< DocNode > &children)
Definition: docparser.cpp:2523
#define DBG(x)
Definition: docparser.cpp:59
int doctokenizerYYlineno
const bool FALSE
Definition: qglobal.h:370
void warn_doc_error(const char *file, int line, const char *fmt,...)
Definition: message.cpp:210
static QStack< DocNode > g_nodeStack
Definition: docparser.cpp:91
TokenInfo * g_token
int doctokenizerYYlex(void)
void push(const type *d)
Definition: qstack.h:58
bool isEmpty() const
Definition: qlist.h:67
static bool g_insideHtmlLink
Definition: docparser.cpp:90
static void handlePendingStyleCommands(DocNode *parent, QList< DocNode > &children)
Definition: docparser.cpp:957
std::void_t< T > n
type * pop()
Definition: qstack.h:59
static void docParserPopContext(bool keepParamInfo=FALSE)
Definition: docparser.cpp:191
static void docParserPushContext(bool saveParamInfo=TRUE)
Definition: docparser.cpp:148
static bool defaultHandleToken(DocNode *parent, int tok, QList< DocNode > &children, bool handleWord=TRUE)
Definition: docparser.cpp:1331
QCString name
Definition: doctokenizer.h:77
const char * tokToString(int token)
static int internalValidatingParseDoc(DocNode *parent, QList< DocNode > &children, const QCString &doc)
Definition: docparser.cpp:1713
QCString m_text
Definition: docparser.h:847
const char * qPrint(const char *s)
Definition: qcstring.h:797
const bool TRUE
Definition: qglobal.h:371
#define ASSERT(x)
Definition: qglobal.h:590
QCString DocRef::ref ( ) const
inline

Definition at line 829 of file docparser.h.

829 { return m_ref; }
QCString m_ref
Definition: docparser.h:845
bool DocRef::refToAnchor ( ) const
inline

Definition at line 833 of file docparser.h.

833 { return m_refType==Anchor; }
RefType m_refType
Definition: docparser.h:841
bool DocRef::refToSection ( ) const
inline

Definition at line 834 of file docparser.h.

834 { return m_refType==Section; }
RefType m_refType
Definition: docparser.h:841
bool DocRef::refToTable ( ) const
inline

Definition at line 835 of file docparser.h.

835 { return m_refType==Table; }
RefType m_refType
Definition: docparser.h:841
QCString DocRef::relPath ( ) const
inline

Definition at line 828 of file docparser.h.

828 { return m_relPath; }
QCString m_relPath
Definition: docparser.h:844
QCString DocRef::targetTitle ( ) const
inline

Definition at line 831 of file docparser.h.

831 { return m_text; }
QCString m_text
Definition: docparser.h:847

Member Data Documentation

QCString DocRef::m_anchor
private

Definition at line 846 of file docparser.h.

QCString DocRef::m_file
private

Definition at line 843 of file docparser.h.

bool DocRef::m_isSubPage
private

Definition at line 842 of file docparser.h.

QCString DocRef::m_ref
private

Definition at line 845 of file docparser.h.

RefType DocRef::m_refType
private

Definition at line 841 of file docparser.h.

QCString DocRef::m_relPath
private

Definition at line 844 of file docparser.h.

QCString DocRef::m_text
private

Definition at line 847 of file docparser.h.


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