1 /******************************************************************************
6 * Copyright (C) 1997-2015 by Dimitri van Heesch.
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation under the terms of the GNU General Public License is hereby
10 * granted. No representations are made about the suitability of this software
11 * for any purpose. It is provided "as is" without express or implied warranty.
12 * See the GNU General Public License for more details.
14 * Documents produced by Doxygen are derivative works derived from the
15 * input used in their production; they are not affected by this license.
27 #include "docvisitor.h"
28 #include "htmlattrib.h"
36 //---------------------------------------------------------------------------
39 /*! Main entry point for the documentation parser.
40 * @param fileName File in which the documentation block is found (or the
41 * name of the example file in case isExample is TRUE).
42 * @param startLine Line at which the documentation block is found.
43 * @param context Class or namespace to which this block belongs.
44 * @param md Member definition to which the documentation belongs.
46 * @param input String representation of the documentation block.
47 * @param indexWords Indicates whether or not words should be put in the
49 * @param isExample TRUE if the documentation belongs to an example.
50 * @param exampleName Base name of the example file (0 if isExample is FALSE).
51 * @param singleLine Output should be presented on a single line, so without
52 * starting a new paragraph at the end.
53 * @param linkFromIndex TRUE if the documentation is generated from an
54 * index page. In this case context is not used to determine
55 * the relative path when making a link.
56 * @returns Root node of the abstract syntax tree. Ownership of the
57 * pointer is handed over to the caller.
59 DocRoot *validatingParseDoc(const char *fileName,int startLine,
60 Definition *context, MemberDef *md,
61 const char *input,bool indexWords,
62 bool isExample,const char *exampleName=0,
63 bool singleLine=FALSE,bool linkFromIndex=FALSE);
65 /*! Main entry point for parsing simple text fragments. These
66 * fragments are limited to words, whitespace and symbols.
68 DocText *validatingParseText(const char *input);
70 /*! Searches for section and anchor commands in the input */
71 void docFindSections(const char *input,
74 const char *fileName);
76 //---------------------------------------------------------------------------
78 /** Abstract node interface with type information. */
82 /*! Available node types. */
83 enum Kind { Kind_Root = 0,
88 Kind_AutoListItem = 5,
95 Kind_SimpleListItem = 12,
100 Kind_HtmlListItem = 17,
101 Kind_HtmlDescList = 18,
102 Kind_HtmlDescData = 19,
103 Kind_HtmlDescTitle = 20,
107 Kind_HtmlCaption = 24,
111 Kind_IndexEntry = 28,
115 Kind_IncOperator = 32,
116 Kind_HtmlHeader = 33,
122 Kind_SecRefItem = 39,
123 Kind_SecRefList = 40,
124 Kind_SimpleSectSep = 41,
125 Kind_LinkedWord = 42,
128 Kind_InternalRef = 45,
132 Kind_HtmlBlockQuote = 49,
137 /*! Creates a new node */
138 DocNode() : m_parent(0), m_insidePre(FALSE) {}
140 /*! Destroys a node. */
141 virtual ~DocNode() {}
143 /*! Returns the kind of node. Provides runtime type information */
144 virtual Kind kind() const = 0;
146 /*! Returns the parent of this node or 0 for the root node. */
147 DocNode *parent() const { return m_parent; }
149 /*! Sets a new parent for this node. */
150 void setParent(DocNode *parent) { m_parent = parent; }
152 /*! Acceptor function for node visitors. Part of the visitor pattern.
153 * @param v Abstract visitor.
155 virtual void accept(DocVisitor *v) = 0;
157 /*! Returns TRUE iff this node is inside a preformatted section */
158 bool isPreformatted() const { return m_insidePre; }
161 /*! Sets whether or not this item is inside a preformatted section */
162 void setInsidePreformatted(bool p) { m_insidePre = p; }
169 /** Default accept implementation for compound nodes in the abstract
172 template<class T> class CompAccept
175 CompAccept() { m_children.setAutoDelete(TRUE); }
176 virtual ~CompAccept() {}
177 void accept(T *obj, DocVisitor *v)
180 QListIterator<DocNode> cli(m_children);
182 for (cli.toFirst();(n=cli.current());++cli) n->accept(v);
185 const QList<DocNode> &children() const { return m_children; }
186 QList<DocNode> &children() { return m_children; }
189 QList<DocNode> m_children;
193 /** Node representing a word
195 class DocWord : public DocNode
198 DocWord(DocNode *parent,const QCString &word);
199 QCString word() const { return m_word; }
200 Kind kind() const { return Kind_Word; }
201 void accept(DocVisitor *v) { v->visit(this); }
207 /** Node representing a word that can be linked to something
209 class DocLinkedWord : public DocNode
212 DocLinkedWord(DocNode *parent,const QCString &word,
213 const QCString &ref,const QCString &file,
214 const QCString &anchor,const QCString &tooltip);
215 QCString word() const { return m_word; }
216 Kind kind() const { return Kind_LinkedWord; }
217 QCString file() const { return m_file; }
218 QCString relPath() const { return m_relPath; }
219 QCString ref() const { return m_ref; }
220 QCString anchor() const { return m_anchor; }
221 QCString tooltip() const { return m_tooltip; }
222 void accept(DocVisitor *v) { v->visit(this); }
233 /** Node representing an URL (or email address) */
234 class DocURL : public DocNode
237 DocURL(DocNode *parent,const QCString &url,bool isEmail) :
238 m_url(url), m_isEmail(isEmail) { m_parent=parent; }
239 QCString url() const { return m_url; }
240 Kind kind() const { return Kind_URL; }
241 void accept(DocVisitor *v) { v->visit(this); }
242 bool isEmail() const { return m_isEmail; }
249 /** Node representing a line break */
250 class DocLineBreak : public DocNode
253 DocLineBreak(DocNode *parent) { m_parent=parent; }
254 Kind kind() const { return Kind_LineBreak; }
255 void accept(DocVisitor *v) { v->visit(this); }
260 /** Node representing a horizonal ruler */
261 class DocHorRuler : public DocNode
264 DocHorRuler(DocNode *parent) { m_parent = parent; }
265 Kind kind() const { return Kind_HorRuler; }
266 void accept(DocVisitor *v) { v->visit(this); }
271 /** Node representing an anchor */
272 class DocAnchor : public DocNode
275 DocAnchor(DocNode *parent,const QCString &id,bool newAnchor);
276 Kind kind() const { return Kind_Anchor; }
277 QCString anchor() const { return m_anchor; }
278 QCString file() const { return m_file; }
279 void accept(DocVisitor *v) { v->visit(this); }
286 /** Node representing a citation of some bibliographic reference */
287 class DocCite : public DocNode
290 DocCite(DocNode *parent,const QCString &target,const QCString &context);
291 Kind kind() const { return Kind_Ref; }
292 QCString file() const { return m_file; }
293 QCString relPath() const { return m_relPath; }
294 QCString ref() const { return m_ref; }
295 QCString anchor() const { return m_anchor; }
296 QCString text() const { return m_text; }
297 void accept(DocVisitor *v) { v->visit(this); }
308 /** Node representing a style change */
309 class DocStyleChange : public DocNode
312 enum Style { Bold = (1<<0),
318 Superscript = (1<<6),
319 Preformatted = (1<<7),
324 DocStyleChange(DocNode *parent,uint position,Style s,bool enable,
325 const HtmlAttribList *attribs=0) :
326 m_position(position), m_style(s), m_enable(enable)
327 { m_parent = parent; if (attribs) m_attribs=*attribs; }
328 Kind kind() const { return Kind_StyleChange; }
329 Style style() const { return m_style; }
330 const char *styleString() const;
331 bool enable() const { return m_enable; }
332 uint position() const { return m_position; }
333 void accept(DocVisitor *v) { v->visit(this); }
334 const HtmlAttribList &attribs() const { return m_attribs; }
340 HtmlAttribList m_attribs;
343 /** Node representing a special symbol */
344 class DocSymbol : public DocNode
347 enum SymType { Sym_Unknown = -1,
348 Sym_nbsp, Sym_iexcl, Sym_cent, Sym_pound, Sym_curren,
349 Sym_yen, Sym_brvbar, Sym_sect, Sym_uml, Sym_copy,
350 Sym_ordf, Sym_laquo, Sym_not, Sym_shy, Sym_reg,
351 Sym_macr, Sym_deg, Sym_plusmn, Sym_sup2, Sym_sup3,
352 Sym_acute, Sym_micro, Sym_para, Sym_middot, Sym_cedil,
353 Sym_sup1, Sym_ordm, Sym_raquo, Sym_frac14, Sym_frac12,
354 Sym_frac34, Sym_iquest, Sym_Agrave, Sym_Aacute, Sym_Acirc,
355 Sym_Atilde, Sym_Auml, Sym_Aring, Sym_AElig, Sym_Ccedil,
356 Sym_Egrave, Sym_Eacute, Sym_Ecirc, Sym_Euml, Sym_Igrave,
357 Sym_Iacute, Sym_Icirc, Sym_Iuml, Sym_ETH, Sym_Ntilde,
358 Sym_Ograve, Sym_Oacute, Sym_Ocirc, Sym_Otilde, Sym_Ouml,
359 Sym_times, Sym_Oslash, Sym_Ugrave, Sym_Uacute, Sym_Ucirc,
360 Sym_Uuml, Sym_Yacute, Sym_THORN, Sym_szlig, Sym_agrave,
361 Sym_aacute, Sym_acirc, Sym_atilde, Sym_auml, Sym_aring,
362 Sym_aelig, Sym_ccedil, Sym_egrave, Sym_eacute, Sym_ecirc,
363 Sym_euml, Sym_igrave, Sym_iacute, Sym_icirc, Sym_iuml,
364 Sym_eth, Sym_ntilde, Sym_ograve, Sym_oacute, Sym_ocirc,
365 Sym_otilde, Sym_ouml, Sym_divide, Sym_oslash, Sym_ugrave,
366 Sym_uacute, Sym_ucirc, Sym_uuml, Sym_yacute, Sym_thorn,
367 Sym_yuml, Sym_fnof, Sym_Alpha, Sym_Beta, Sym_Gamma,
368 Sym_Delta, Sym_Epsilon, Sym_Zeta, Sym_Eta, Sym_Theta,
369 Sym_Iota, Sym_Kappa, Sym_Lambda, Sym_Mu, Sym_Nu,
370 Sym_Xi, Sym_Omicron, Sym_Pi, Sym_Rho, Sym_Sigma,
371 Sym_Tau, Sym_Upsilon, Sym_Phi, Sym_Chi, Sym_Psi,
372 Sym_Omega, Sym_alpha, Sym_beta, Sym_gamma, Sym_delta,
373 Sym_epsilon, Sym_zeta, Sym_eta, Sym_theta, Sym_iota,
374 Sym_kappa, Sym_lambda, Sym_mu, Sym_nu, Sym_xi,
375 Sym_omicron, Sym_pi, Sym_rho, Sym_sigmaf, Sym_sigma,
376 Sym_tau, Sym_upsilon, Sym_phi, Sym_chi, Sym_psi,
377 Sym_omega, Sym_thetasym, Sym_upsih, Sym_piv, Sym_bull,
378 Sym_hellip, Sym_prime, Sym_Prime, Sym_oline, Sym_frasl,
379 Sym_weierp, Sym_image, Sym_real, Sym_trade, Sym_alefsym,
380 Sym_larr, Sym_uarr, Sym_rarr, Sym_darr, Sym_harr,
381 Sym_crarr, Sym_lArr, Sym_uArr, Sym_rArr, Sym_dArr,
382 Sym_hArr, Sym_forall, Sym_part, Sym_exist, Sym_empty,
383 Sym_nabla, Sym_isin, Sym_notin, Sym_ni, Sym_prod,
384 Sym_sum, Sym_minus, Sym_lowast, Sym_radic, Sym_prop,
385 Sym_infin, Sym_ang, Sym_and, Sym_or, Sym_cap,
386 Sym_cup, Sym_int, Sym_there4, Sym_sim, Sym_cong,
387 Sym_asymp, Sym_ne, Sym_equiv, Sym_le, Sym_ge,
388 Sym_sub, Sym_sup, Sym_nsub, Sym_sube, Sym_supe,
389 Sym_oplus, Sym_otimes, Sym_perp, Sym_sdot, Sym_lceil,
390 Sym_rceil, Sym_lfloor, Sym_rfloor, Sym_lang, Sym_rang,
391 Sym_loz, Sym_spades, Sym_clubs, Sym_hearts, Sym_diams,
392 Sym_quot, Sym_amp, Sym_lt, Sym_gt, Sym_OElig,
393 Sym_oelig, Sym_Scaron, Sym_scaron, Sym_Yuml, Sym_circ,
394 Sym_tilde, Sym_ensp, Sym_emsp, Sym_thinsp, Sym_zwnj,
395 Sym_zwj, Sym_lrm, Sym_rlm, Sym_ndash, Sym_mdash,
396 Sym_lsquo, Sym_rsquo, Sym_sbquo, Sym_ldquo, Sym_rdquo,
397 Sym_bdquo, Sym_dagger, Sym_Dagger, Sym_permil, Sym_lsaquo,
398 Sym_rsaquo, Sym_euro,
400 /* doxygen extensions */
403 /* doxygen commands mapped */
404 Sym_BSlash, Sym_At, Sym_Less, Sym_Greater, Sym_Amp,
405 Sym_Dollar, Sym_Hash, Sym_DoubleColon, Sym_Percent, Sym_Pipe,
406 Sym_Quot, Sym_Minus, Sym_Plus, Sym_Dot
408 enum PerlType { Perl_unknown = 0, Perl_string, Perl_char, Perl_symbol, Perl_umlaut,
409 Perl_acute, Perl_grave, Perl_circ, Perl_slash, Perl_tilde,
410 Perl_cedilla, Perl_ring
412 typedef struct PerlSymb {
416 DocSymbol(DocNode *parent,SymType s) :
417 m_symbol(s) { m_parent = parent; }
418 SymType symbol() const { return m_symbol; }
419 Kind kind() const { return Kind_Symbol; }
420 void accept(DocVisitor *v) { v->visit(this); }
421 static SymType decodeSymbol(const QCString &symName);
427 /** Node representing some amount of white space */
428 class DocWhiteSpace : public DocNode
431 DocWhiteSpace(DocNode *parent,const QCString &chars) :
432 m_chars(chars) { m_parent = parent; }
433 Kind kind() const { return Kind_WhiteSpace; }
434 QCString chars() const { return m_chars; }
435 void accept(DocVisitor *v) { v->visit(this); }
440 /** Node representing a verbatim, unparsed text fragment */
441 class DocVerbatim : public DocNode
444 enum Type { Code, HtmlOnly, ManOnly, LatexOnly, RtfOnly, XmlOnly, Verbatim, Dot, Msc, DocbookOnly, PlantUML };
445 DocVerbatim(DocNode *parent,const QCString &context,
446 const QCString &text, Type t,bool isExample,
447 const QCString &exampleFile,bool isBlock=FALSE,const QCString &lang=QCString());
448 Kind kind() const { return Kind_Verbatim; }
449 Type type() const { return m_type; }
450 QCString text() const { return m_text; }
451 QCString context() const { return m_context; }
452 void accept(DocVisitor *v) { v->visit(this); }
453 bool isExample() const { return m_isExample; }
454 QCString exampleFile() const { return m_exampleFile; }
455 QCString relPath() const { return m_relPath; }
456 QCString language() const { return m_lang; }
457 bool isBlock() const { return m_isBlock; }
458 bool hasCaption() const { return !m_children.isEmpty(); }
459 QCString width() const { return m_width; }
460 QCString height() const { return m_height; }
461 const QList<DocNode> &children() const { return m_children; }
462 QList<DocNode> &children() { return m_children; }
463 void setText(const QCString &t) { m_text=t; }
464 void setWidth(const QCString &w) { m_width=w; }
465 void setHeight(const QCString &h) { m_height=h; }
472 QCString m_exampleFile;
478 QList<DocNode> m_children;
482 /** Node representing an included text block from file */
483 class DocInclude : public DocNode
486 enum Type { Include, DontInclude, VerbInclude, HtmlInclude, LatexInclude,
487 IncWithLines, Snippet , IncludeDoc, SnippetDoc, SnipWithLines};
488 DocInclude(DocNode *parent,const QCString &file,
489 const QCString context, Type t,
490 bool isExample,const QCString exampleFile,
491 const QCString blockId) :
492 m_file(file), m_context(context), m_type(t),
493 m_isExample(isExample), m_exampleFile(exampleFile),
494 m_blockId(blockId) { m_parent = parent; }
495 Kind kind() const { return Kind_Include; }
496 QCString file() const { return m_file; }
497 QCString extension() const { int i=m_file.findRev('.');
499 return m_file.right(m_file.length()-i);
503 Type type() const { return m_type; }
504 QCString text() const { return m_text; }
505 QCString context() const { return m_context; }
506 QCString blockId() const { return m_blockId; }
507 bool isExample() const { return m_isExample; }
508 QCString exampleFile() const { return m_exampleFile; }
509 void accept(DocVisitor *v) { v->visit(this); }
518 QCString m_exampleFile;
522 /** Node representing a include/dontinclude operator block */
523 class DocIncOperator : public DocNode
526 enum Type { Line, SkipLine, Skip, Until };
527 DocIncOperator(DocNode *parent,Type t,const QCString &pat,
528 const QCString &context,bool isExample,const QCString &exampleFile) :
529 m_type(t), m_pattern(pat), m_context(context),
530 m_isFirst(FALSE), m_isLast(FALSE),
531 m_isExample(isExample), m_exampleFile(exampleFile) { m_parent = parent; }
532 Kind kind() const { return Kind_IncOperator; }
533 Type type() const { return m_type; }
534 QCString text() const { return m_text; }
535 QCString pattern() const { return m_pattern; }
536 QCString context() const { return m_context; }
537 void accept(DocVisitor *v) { v->visit(this); }
538 bool isFirst() const { return m_isFirst; }
539 bool isLast() const { return m_isLast; }
540 void markFirst(bool v=TRUE) { m_isFirst = v; }
541 void markLast(bool v=TRUE) { m_isLast = v; }
542 bool isExample() const { return m_isExample; }
543 QCString exampleFile() const { return m_exampleFile; }
544 QCString includeFileName() const { return m_includeFileName; }
555 QCString m_exampleFile;
556 QCString m_includeFileName;
559 /** Node representing an item of a cross-referenced list */
560 class DocFormula : public DocNode
563 DocFormula(DocNode *parent,int id);
564 Kind kind() const { return Kind_Formula; }
565 QCString name() const { return m_name; }
566 QCString text() const { return m_text; }
567 QCString relPath() const { return m_relPath; }
568 int id() const { return m_id; }
569 void accept(DocVisitor *v) { v->visit(this); }
570 bool isInline() { return m_text.length()>0 ? m_text.at(0)!='\\' : TRUE; }
579 /** Node representing an entry in the index. */
580 class DocIndexEntry : public DocNode
583 DocIndexEntry(DocNode *parent,Definition *scope,MemberDef *md)
584 : m_scope(scope), m_member(md){ m_parent = parent; }
585 Kind kind() const { return Kind_IndexEntry; }
587 Definition *scope() const { return m_scope; }
588 MemberDef *member() const { return m_member; }
589 QCString entry() const { return m_entry; }
590 void accept(DocVisitor *v) { v->visit(this); }
598 //-----------------------------------------------------------------------
600 /** Node representing a copy of documentation block. */
601 class DocCopy : public DocNode
604 DocCopy(DocNode *parent,const QCString &link,bool copyBrief,bool copyDetails)
606 m_copyBrief(copyBrief), m_copyDetails(copyDetails) { m_parent = parent; }
607 Kind kind() const { return Kind_Copy; }
608 QCString link() const { return m_link; }
609 void accept(DocVisitor * /*v*/) { /*CompAccept<DocCopy>::accept(this,v);*/ }
610 void parse(QList<DocNode> &children);
618 /** Node representing an auto List */
619 class DocAutoList : public CompAccept<DocAutoList>, public DocNode
622 DocAutoList(DocNode *parent,int indent,bool isEnumList,int depth);
623 Kind kind() const { return Kind_AutoList; }
624 bool isEnumList() const { return m_isEnumList; }
625 int indent() const { return m_indent; }
626 int depth() const { return m_depth; }
627 void accept(DocVisitor *v) { CompAccept<DocAutoList>::accept(this,v); }
636 /** Node representing an item of a auto list */
637 class DocAutoListItem : public CompAccept<DocAutoListItem>, public DocNode
640 DocAutoListItem(DocNode *parent,int indent,int num);
641 Kind kind() const { return Kind_AutoListItem; }
642 int itemNumber() const { return m_itemNum; }
643 void accept(DocVisitor *v) { CompAccept<DocAutoListItem>::accept(this,v); }
653 /** Node representing a simple section title */
654 class DocTitle : public CompAccept<DocTitle>, public DocNode
657 DocTitle(DocNode *parent) { m_parent = parent; }
659 void parseFromString(const QCString &title);
660 Kind kind() const { return Kind_Title; }
661 void accept(DocVisitor *v) { CompAccept<DocTitle>::accept(this,v); }
666 /** Node representing an item of a cross-referenced list */
667 class DocXRefItem : public CompAccept<DocXRefItem>, public DocNode
670 DocXRefItem(DocNode *parent,int id,const char *key);
671 Kind kind() const { return Kind_XRefItem; }
672 QCString file() const { return m_file; }
673 QCString anchor() const { return m_anchor; }
674 QCString title() const { return m_title; }
675 QCString relPath() const { return m_relPath; }
676 QCString key() const { return m_key; }
677 void accept(DocVisitor *v) { CompAccept<DocXRefItem>::accept(this,v); }
689 /** Node representing an image */
690 class DocImage : public CompAccept<DocImage>, public DocNode
693 enum Type { Html, Latex, Rtf, DocBook };
694 DocImage(DocNode *parent,const HtmlAttribList &attribs,
695 const QCString &name,Type t,const QCString &url=QCString());
696 Kind kind() const { return Kind_Image; }
697 Type type() const { return m_type; }
698 QCString name() const { return m_name; }
699 bool hasCaption() const { return !m_children.isEmpty(); }
700 QCString width() const { return m_width; }
701 QCString height() const { return m_height; }
702 QCString relPath() const { return m_relPath; }
703 QCString url() const { return m_url; }
704 const HtmlAttribList &attribs() const { return m_attribs; }
705 void accept(DocVisitor *v) { CompAccept<DocImage>::accept(this,v); }
709 HtmlAttribList m_attribs;
718 /** Node representing a dot file */
719 class DocDotFile : public CompAccept<DocDotFile>, public DocNode
722 DocDotFile(DocNode *parent,const QCString &name,const QCString &context);
724 Kind kind() const { return Kind_DotFile; }
725 QCString name() const { return m_name; }
726 QCString file() const { return m_file; }
727 QCString relPath() const { return m_relPath; }
728 bool hasCaption() const { return !m_children.isEmpty(); }
729 QCString width() const { return m_width; }
730 QCString height() const { return m_height; }
731 QCString context() const { return m_context; }
732 void accept(DocVisitor *v) { CompAccept<DocDotFile>::accept(this,v); }
742 /** Node representing a msc file */
743 class DocMscFile : public CompAccept<DocMscFile>, public DocNode
746 DocMscFile(DocNode *parent,const QCString &name,const QCString &context);
748 Kind kind() const { return Kind_MscFile; }
749 QCString name() const { return m_name; }
750 QCString file() const { return m_file; }
751 QCString relPath() const { return m_relPath; }
752 bool hasCaption() const { return !m_children.isEmpty(); }
753 QCString width() const { return m_width; }
754 QCString height() const { return m_height; }
755 QCString context() const { return m_context; }
756 void accept(DocVisitor *v) { CompAccept<DocMscFile>::accept(this,v); }
766 /** Node representing a dia file */
767 class DocDiaFile : public CompAccept<DocDiaFile>, public DocNode
770 DocDiaFile(DocNode *parent,const QCString &name,const QCString &context);
772 Kind kind() const { return Kind_DiaFile; }
773 QCString name() const { return m_name; }
774 QCString file() const { return m_file; }
775 QCString relPath() const { return m_relPath; }
776 bool hasCaption() const { return !m_children.isEmpty(); }
777 QCString width() const { return m_width; }
778 QCString height() const { return m_height; }
779 QCString context() const { return m_context; }
780 void accept(DocVisitor *v) { CompAccept<DocDiaFile>::accept(this,v); }
790 /** Node representing a VHDL flow chart */
791 class DocVhdlFlow : public CompAccept<DocVhdlFlow>, public DocNode
794 DocVhdlFlow(DocNode *parent);
796 Kind kind() const { return Kind_VhdlFlow; }
797 bool hasCaption() { return !m_children.isEmpty(); }
798 void accept(DocVisitor *v) { CompAccept<DocVhdlFlow>::accept(this,v); }
802 /** Node representing a link to some item */
803 class DocLink : public CompAccept<DocLink>, public DocNode
806 DocLink(DocNode *parent,const QCString &target);
807 QCString parse(bool,bool isXmlLink=FALSE);
808 Kind kind() const { return Kind_Link; }
809 QCString file() const { return m_file; }
810 QCString relPath() const { return m_relPath; }
811 QCString ref() const { return m_ref; }
812 QCString anchor() const { return m_anchor; }
813 void accept(DocVisitor *v) { CompAccept<DocLink>::accept(this,v); }
823 /** Node representing a reference to some item */
824 class DocRef : public CompAccept<DocRef>, public DocNode
827 DocRef(DocNode *parent,const QCString &target,const QCString &context);
829 Kind kind() const { return Kind_Ref; }
830 QCString file() const { return m_file; }
831 QCString relPath() const { return m_relPath; }
832 QCString ref() const { return m_ref; }
833 QCString anchor() const { return m_anchor; }
834 QCString targetTitle() const { return m_text; }
835 bool hasLinkText() const { return !m_children.isEmpty(); }
836 bool refToAnchor() const { return m_refType==Anchor; }
837 bool refToSection() const { return m_refType==Section; }
838 bool refToTable() const { return m_refType==Table; }
839 bool isSubPage() const { return m_isSubPage; }
840 void accept(DocVisitor *v) { CompAccept<DocRef>::accept(this,v); }
843 enum RefType { Unknown, Anchor, Section, Table };
853 /** Node representing an internal reference to some item */
854 class DocInternalRef : public CompAccept<DocInternalRef>, public DocNode
857 DocInternalRef(DocNode *parent,const QCString &target);
859 Kind kind() const { return Kind_Ref; }
860 QCString file() const { return m_file; }
861 QCString relPath() const { return m_relPath; }
862 QCString anchor() const { return m_anchor; }
863 void accept(DocVisitor *v) { CompAccept<DocInternalRef>::accept(this,v); }
871 /** Node representing a Hypertext reference */
872 class DocHRef : public CompAccept<DocHRef>, public DocNode
875 DocHRef(DocNode *parent,const HtmlAttribList &attribs,const QCString &url,
876 const QCString &relPath) :
877 m_attribs(attribs), m_url(url), m_relPath(relPath) { m_parent = parent; }
879 QCString url() const { return m_url; }
880 QCString relPath() const { return m_relPath; }
881 Kind kind() const { return Kind_HRef; }
882 void accept(DocVisitor *v) { CompAccept<DocHRef>::accept(this,v); }
883 const HtmlAttribList &attribs() const { return m_attribs; }
886 HtmlAttribList m_attribs;
891 /** Node Html heading */
892 class DocHtmlHeader : public CompAccept<DocHtmlHeader>, public DocNode
895 DocHtmlHeader(DocNode *parent,const HtmlAttribList &attribs,int level) :
896 m_level(level), m_attribs(attribs) { m_parent = parent; }
897 int level() const { return m_level; }
898 Kind kind() const { return Kind_HtmlHeader; }
899 const HtmlAttribList &attribs() const { return m_attribs; }
900 void accept(DocVisitor *v) { CompAccept<DocHtmlHeader>::accept(this,v); }
905 HtmlAttribList m_attribs;
908 /** Node representing a Html description item */
909 class DocHtmlDescTitle : public CompAccept<DocHtmlDescTitle>, public DocNode
912 DocHtmlDescTitle(DocNode *parent,const HtmlAttribList &attribs) :
913 m_attribs(attribs) { m_parent = parent; }
914 Kind kind() const { return Kind_HtmlDescTitle; }
915 const HtmlAttribList &attribs() const { return m_attribs; }
916 void accept(DocVisitor *v) { CompAccept<DocHtmlDescTitle>::accept(this,v); }
920 HtmlAttribList m_attribs;
923 /** Node representing a Html description list */
924 class DocHtmlDescList : public CompAccept<DocHtmlDescList>, public DocNode
927 DocHtmlDescList(DocNode *parent,const HtmlAttribList &attribs) :
928 m_attribs(attribs) { m_parent = parent; }
929 Kind kind() const { return Kind_HtmlDescList; }
930 const HtmlAttribList &attribs() const { return m_attribs; }
931 void accept(DocVisitor *v) { CompAccept<DocHtmlDescList>::accept(this,v); }
935 HtmlAttribList m_attribs;
938 /** Node representing a normal section */
939 class DocSection : public CompAccept<DocSection>, public DocNode
942 DocSection(DocNode *parent,int level,const QCString &id) :
943 m_level(level), m_id(id) { m_parent = parent; }
944 Kind kind() const { return Kind_Section; }
945 int level() const { return m_level; }
946 QCString title() const { return m_title; }
947 QCString anchor() const { return m_anchor; }
948 QCString id() const { return m_id; }
949 QCString file() const { return m_file; }
950 void accept(DocVisitor *v) { CompAccept<DocSection>::accept(this,v); }
961 /** Node representing a reference to a section */
962 class DocSecRefItem : public CompAccept<DocSecRefItem>, public DocNode
965 DocSecRefItem(DocNode *parent,const QCString &target) :
966 m_target(target) { m_parent = parent; }
967 Kind kind() const { return Kind_SecRefItem; }
968 QCString target() const { return m_target; }
969 QCString file() const { return m_file; }
970 QCString anchor() const { return m_anchor; }
971 void accept(DocVisitor *v) { CompAccept<DocSecRefItem>::accept(this,v); }
980 /** Node representing a list of section references */
981 class DocSecRefList : public CompAccept<DocSecRefList>, public DocNode
984 DocSecRefList(DocNode *parent) { m_parent = parent; }
986 Kind kind() const { return Kind_SecRefList; }
987 void accept(DocVisitor *v) { CompAccept<DocSecRefList>::accept(this,v); }
992 /** Node representing an internal section of documentation */
993 class DocInternal : public CompAccept<DocInternal>, public DocNode
996 DocInternal(DocNode *parent) { m_parent = parent; }
998 Kind kind() const { return Kind_Internal; }
999 void accept(DocVisitor *v) { CompAccept<DocInternal>::accept(this,v); }
1004 /** Node representing an block of paragraphs */
1005 class DocParBlock : public CompAccept<DocParBlock>, public DocNode
1008 DocParBlock(DocNode *parent) { m_parent = parent; }
1010 Kind kind() const { return Kind_ParBlock; }
1011 void accept(DocVisitor *v) { CompAccept<DocParBlock>::accept(this,v); }
1017 /** Node representing a simple list */
1018 class DocSimpleList : public CompAccept<DocSimpleList>, public DocNode
1021 DocSimpleList(DocNode *parent) { m_parent = parent; }
1022 Kind kind() const { return Kind_SimpleList; }
1023 void accept(DocVisitor *v) { CompAccept<DocSimpleList>::accept(this,v); }
1029 /** Node representing a Html list */
1030 class DocHtmlList : public CompAccept<DocHtmlList>, public DocNode
1033 enum Type { Unordered, Ordered };
1034 DocHtmlList(DocNode *parent,const HtmlAttribList &attribs,Type t) :
1035 m_type(t), m_attribs(attribs) { m_parent = parent; }
1036 Kind kind() const { return Kind_HtmlList; }
1037 Type type() const { return m_type; }
1038 void accept(DocVisitor *v) { CompAccept<DocHtmlList>::accept(this,v); }
1039 const HtmlAttribList &attribs() const { return m_attribs; }
1045 HtmlAttribList m_attribs;
1048 /** Node representing a simple section */
1049 class DocSimpleSect : public CompAccept<DocSimpleSect>, public DocNode
1054 Unknown, See, Return, Author, Authors, Version, Since, Date,
1055 Note, Warning, Copyright, Pre, Post, Invar, Remark, Attention, User, Rcs
1057 DocSimpleSect(DocNode *parent,Type t);
1058 virtual ~DocSimpleSect();
1059 Kind kind() const { return Kind_SimpleSect; }
1060 Type type() const { return m_type; }
1061 QCString typeString() const;
1062 void accept(DocVisitor *v);
1063 int parse(bool userTitle,bool needsSeparator);
1066 void appendLinkWord(const QCString &word);
1073 /** Node representing a separator between two simple sections of the
1076 class DocSimpleSectSep : public DocNode
1079 DocSimpleSectSep(DocNode *parent) { m_parent = parent; }
1080 Kind kind() const { return Kind_SimpleSectSep; }
1081 void accept(DocVisitor *v) { v->visit(this); }
1086 /** Node representing a parameter section */
1087 class DocParamSect : public CompAccept<DocParamSect>, public DocNode
1089 friend class DocParamList;
1093 Unknown, Param, RetVal, Exception, TemplateParam
1097 In=1, Out=2, InOut=3, Unspecified=0
1099 DocParamSect(DocNode *parent,Type t)
1100 : m_type(t), m_hasInOutSpecifier(FALSE), m_hasTypeSpecifier(FALSE)
1101 { m_parent = parent; }
1102 int parse(const QCString &cmdName,bool xmlContext,Direction d);
1103 Kind kind() const { return Kind_ParamSect; }
1104 Type type() const { return m_type; }
1105 void accept(DocVisitor *v) { CompAccept<DocParamSect>::accept(this,v); }
1106 bool hasInOutSpecifier() const { return m_hasInOutSpecifier; }
1107 bool hasTypeSpecifier() const { return m_hasTypeSpecifier; }
1111 bool m_hasInOutSpecifier;
1112 bool m_hasTypeSpecifier;
1115 /** Node representing a paragraph in the documentation tree */
1116 class DocPara : public CompAccept<DocPara>, public DocNode
1119 DocPara(DocNode *parent) :
1120 m_isFirst(FALSE), m_isLast(FALSE) { m_parent = parent; }
1122 Kind kind() const { return Kind_Para; }
1123 bool isEmpty() const { return m_children.isEmpty(); }
1124 void accept(DocVisitor *v) { CompAccept<DocPara>::accept(this,v); }
1125 void markFirst(bool v=TRUE) { m_isFirst=v; }
1126 void markLast(bool v=TRUE) { m_isLast=v; }
1127 bool isFirst() const { return m_isFirst; }
1128 bool isLast() const { return m_isLast; }
1130 int handleCommand(const QCString &cmdName);
1131 int handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &tagHtmlAttribs);
1132 int handleHtmlEndTag(const QCString &tagName);
1133 int handleSimpleSection(DocSimpleSect::Type t,bool xmlContext=FALSE);
1134 int handleXRefItem();
1135 int handleParamSection(const QCString &cmdName,DocParamSect::Type t,
1138 void handleIncludeOperator(const QCString &cmdName,DocIncOperator::Type t);
1139 void handleImage(const QCString &cmdName);
1140 template<class T> void handleFile(const QCString &cmdName);
1141 void handleInclude(const QCString &cmdName,DocInclude::Type t);
1142 void handleLink(const QCString &cmdName,bool isJavaLink);
1144 void handleRef(const QCString &cmdName);
1145 void handleSection(const QCString &cmdName);
1146 void handleInheritDoc();
1147 void handleVhdlFlow();
1148 int handleStartCode();
1149 int handleHtmlHeader(const HtmlAttribList &tagHtmlAttribs,int level);
1151 bool injectToken(int tok,const QCString &tokText);
1154 QCString m_sectionId;
1159 /** Node representing a parameter list. */
1160 class DocParamList : public DocNode
1163 DocParamList(DocNode *parent,DocParamSect::Type t,DocParamSect::Direction d)
1164 : m_type(t), m_dir(d), m_isFirst(TRUE), m_isLast(TRUE)
1165 { m_paragraphs.setAutoDelete(TRUE);
1166 m_params.setAutoDelete(TRUE);
1167 m_paramTypes.setAutoDelete(TRUE);
1170 virtual ~DocParamList() { }
1171 Kind kind() const { return Kind_ParamList; }
1172 const QList<DocNode> ¶meters() { return m_params; }
1173 const QList<DocNode> ¶mTypes() { return m_paramTypes; }
1174 DocParamSect::Type type() const { return m_type; }
1175 DocParamSect::Direction direction() const { return m_dir; }
1176 void markFirst(bool b=TRUE) { m_isFirst=b; }
1177 void markLast(bool b=TRUE) { m_isLast=b; }
1178 bool isFirst() const { return m_isFirst; }
1179 bool isLast() const { return m_isLast; }
1180 void accept(DocVisitor *v)
1183 QListIterator<DocPara> cli(m_paragraphs);
1185 for (cli.toFirst();(n=cli.current());++cli) n->accept(v);
1188 int parse(const QCString &cmdName);
1189 int parseXml(const QCString ¶mName);
1192 QList<DocPara> m_paragraphs;
1193 QList<DocNode> m_params;
1194 QList<DocNode> m_paramTypes;
1195 DocParamSect::Type m_type;
1196 DocParamSect::Direction m_dir;
1201 /** Node representing a simple list item */
1202 class DocSimpleListItem : public DocNode
1205 DocSimpleListItem(DocNode *parent)
1206 { m_paragraph=new DocPara(this); m_parent = parent; }
1208 virtual ~DocSimpleListItem() { delete m_paragraph; }
1209 Kind kind() const { return Kind_SimpleListItem; }
1210 void accept(DocVisitor *v)
1213 m_paragraph->accept(v);
1218 DocPara *m_paragraph;
1221 /** Node representing a HTML list item */
1222 class DocHtmlListItem : public CompAccept<DocHtmlListItem>, public DocNode
1225 DocHtmlListItem(DocNode *parent,const HtmlAttribList &attribs,int num) :
1226 m_attribs(attribs), m_itemNum(num) { m_parent = parent; }
1227 Kind kind() const { return Kind_HtmlListItem; }
1228 int itemNumber() const { return m_itemNum; }
1229 const HtmlAttribList &attribs() const { return m_attribs; }
1230 void accept(DocVisitor *v) { CompAccept<DocHtmlListItem>::accept(this,v); }
1235 HtmlAttribList m_attribs;
1239 /** Node representing a HTML description data */
1240 class DocHtmlDescData : public CompAccept<DocHtmlDescData>, public DocNode
1243 DocHtmlDescData(DocNode *parent) { m_parent = parent; }
1244 Kind kind() const { return Kind_HtmlDescData; }
1245 const HtmlAttribList &attribs() const { return m_attribs; }
1246 void accept(DocVisitor *v) { CompAccept<DocHtmlDescData>::accept(this,v); }
1250 HtmlAttribList m_attribs;
1253 /** Node representing a HTML table cell */
1254 class DocHtmlCell : public CompAccept<DocHtmlCell>, public DocNode
1256 friend class DocHtmlTable;
1258 enum Alignment { Left, Right, Center };
1259 DocHtmlCell(DocNode *parent,const HtmlAttribList &attribs,bool isHeading) :
1260 m_isHeading(isHeading),
1261 m_isFirst(FALSE), m_isLast(FALSE), m_attribs(attribs),
1262 m_rowIdx(-1), m_colIdx(-1) { m_parent = parent; }
1263 bool isHeading() const { return m_isHeading; }
1264 bool isFirst() const { return m_isFirst; }
1265 bool isLast() const { return m_isLast; }
1266 Kind kind() const { return Kind_HtmlCell; }
1267 void accept(DocVisitor *v) { CompAccept<DocHtmlCell>::accept(this,v); }
1268 void markFirst(bool v=TRUE) { m_isFirst=v; }
1269 void markLast(bool v=TRUE) { m_isLast=v; }
1270 const HtmlAttribList &attribs() const { return m_attribs; }
1273 int rowIndex() const { return m_rowIdx; }
1274 int columnIndex() const { return m_colIdx; }
1275 int rowSpan() const;
1276 int colSpan() const;
1277 Alignment alignment() const;
1280 void setRowIndex(int idx) { m_rowIdx = idx; }
1281 void setColumnIndex(int idx) { m_colIdx = idx; }
1285 HtmlAttribList m_attribs;
1290 /** Node representing a HTML table caption */
1291 class DocHtmlCaption : public CompAccept<DocHtmlCaption>, public DocNode
1294 DocHtmlCaption(DocNode *parent,const HtmlAttribList &attribs);
1295 Kind kind() const { return Kind_HtmlCaption; }
1296 void accept(DocVisitor *v) { CompAccept<DocHtmlCaption>::accept(this,v); }
1297 const HtmlAttribList &attribs() const { return m_attribs; }
1299 bool hasCaptionId() const { return m_hasCaptionId; }
1300 QCString file() const { return m_file; }
1301 QCString anchor() const { return m_anchor; }
1304 HtmlAttribList m_attribs;
1305 bool m_hasCaptionId;
1310 /** Node representing a HTML table row */
1311 class DocHtmlRow : public CompAccept<DocHtmlRow>, public DocNode
1313 friend class DocHtmlTable;
1315 DocHtmlRow(DocNode *parent,const HtmlAttribList &attribs) :
1316 m_attribs(attribs), m_visibleCells(-1), m_rowIdx(-1) { m_parent = parent; }
1317 Kind kind() const { return Kind_HtmlRow; }
1318 uint numCells() const { return m_children.count(); }
1319 void accept(DocVisitor *v) { CompAccept<DocHtmlRow>::accept(this,v); }
1320 const HtmlAttribList &attribs() const { return m_attribs; }
1322 int parseXml(bool header);
1323 bool isHeading() const { // a row is a table heading if all cells are marked as such
1325 QListIterator<DocNode> it(m_children);
1327 for (;(n=it.current());++it)
1329 if (n->kind()==Kind_HtmlCell)
1331 heading = heading && ((DocHtmlCell*)n)->isHeading();
1334 return m_children.count()>0 && heading;
1336 void setVisibleCells(int n) { m_visibleCells = n; }
1337 int visibleCells() const { return m_visibleCells; }
1338 int rowIndex() const { return m_rowIdx; }
1341 void setRowIndex(int idx) { m_rowIdx = idx; }
1342 HtmlAttribList m_attribs;
1347 /** Node representing a HTML table */
1348 class DocHtmlTable : public CompAccept<DocHtmlTable>, public DocNode
1351 DocHtmlTable(DocNode *parent,const HtmlAttribList &attribs)
1352 : m_attribs(attribs) { m_caption=0; m_parent = parent; }
1353 ~DocHtmlTable() { delete m_caption; }
1354 Kind kind() const { return Kind_HtmlTable; }
1355 uint numRows() const { return m_children.count(); }
1356 bool hasCaption() { return m_caption!=0; }
1357 const HtmlAttribList &attribs() const { return m_attribs; }
1360 uint numColumns() const { return m_numCols; }
1361 void accept(DocVisitor *v);
1362 DocHtmlCaption *caption() const { return m_caption; }
1363 DocHtmlRow *firstRow() const {
1364 DocNode *n = m_children.getFirst();
1365 if (n && n->kind()==Kind_HtmlRow) return (DocHtmlRow*)n;
1370 void computeTableGrid();
1371 DocHtmlCaption *m_caption;
1372 HtmlAttribList m_attribs;
1376 /** Node representing an HTML blockquote */
1377 class DocHtmlBlockQuote : public CompAccept<DocHtmlBlockQuote>, public DocNode
1380 DocHtmlBlockQuote(DocNode *parent,const HtmlAttribList &attribs)
1381 : m_attribs(attribs) { m_parent = parent; }
1382 Kind kind() const { return Kind_HtmlBlockQuote; }
1384 void accept(DocVisitor *v) { CompAccept<DocHtmlBlockQuote>::accept(this,v); }
1385 const HtmlAttribList &attribs() const { return m_attribs; }
1388 HtmlAttribList m_attribs;
1391 /** Root node of a text fragment */
1392 class DocText : public CompAccept<DocText>, public DocNode
1396 Kind kind() const { return Kind_Text; }
1397 void accept(DocVisitor *v) { CompAccept<DocText>::accept(this,v); }
1399 bool isEmpty() const { return m_children.isEmpty(); }
1402 /** Root node of documentation tree */
1403 class DocRoot : public CompAccept<DocRoot>, public DocNode
1406 DocRoot(bool indent,bool sl) : m_indent(indent), m_singleLine(sl) {}
1407 Kind kind() const { return Kind_Root; }
1408 void accept(DocVisitor *v) { CompAccept<DocRoot>::accept(this,v); }
1410 bool indent() const { return m_indent; }
1411 bool singleLine() const { return m_singleLine; }
1412 bool isEmpty() const { return m_children.isEmpty(); }