Logo ROOT  
Reference Guide
TDocDirective.h
Go to the documentation of this file.
1 // @(#)root/html:$Id$
2 // Author: Axel Naumann 2007-01-25
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TDocDirective
13 #define ROOT_TDocDirective
14 
15 ////////////////////////////////////////////////////////////////////////////
16 // //
17 // TDocDirective //
18 // //
19 // Special treatment of comments, like HTML source, a macro, or latex. //
20 // //
21 ////////////////////////////////////////////////////////////////////////////
22 
23 #include "TNamed.h"
24 
25 
26 class TClass;
27 class TDocParser;
28 class TDocOutput;
29 class THtml;
30 class TLatex;
31 class TMacro;
32 class TVirtualPad;
33 
34 class TDocDirective: public TNamed {
35 protected:
36  TDocParser* fDocParser; // parser invoking this handler
37  THtml* fHtml; // parser's THtml object
38  TDocOutput* fDocOutput; // parser invoking this handler
39  TString fParameters; // parameters to the directive
40  Int_t fCounter; // counter to generate unique names, -1 to ignore
41 
42  virtual void AddParameter(const TString& /*name*/, const char* /*value*/ = 0) {}
43 
45  TDocDirective(const char* name):
46  TNamed(name, ""), fDocParser(0), fHtml(0), fDocOutput(0), fCounter(-1) {};
47  virtual ~TDocDirective() {}
48 
49  const char* GetName() const { return TNamed::GetName(); }
50  void GetName(TString& name) const;
51  TDocParser* GetDocParser() const { return fDocParser; }
52  TDocOutput* GetDocOutput() const { return fDocOutput; }
53  THtml* GetHtml() const { return fHtml; }
54  const char* GetOutputDir() const;
55 
56  void SetParser(TDocParser* parser);
57  void SetParameters(const char* params);
58  void SetTag(const char* tag) { SetTitle(tag); }
59  void SetCounter(Int_t count) { fCounter = count; }
60  virtual void DeleteOutputFiles(const char* ext) const;
61 
62 public:
63  // get the tag ending this directive
64  virtual const char* GetEndTag() const = 0;
65 
66  // add a line to the directive's text
67  virtual void AddLine(const TSubString& line) = 0;
68 
69  // retrieve the result (replacement) of the directive; return false if invalid
70  virtual Bool_t GetResult(TString& result) = 0;
71 
72  // Delete output for the parser's current class or module.
73  virtual void DeleteOutput() const {}
74 
75  friend class TDocParser;
76 
77  ClassDef(TDocDirective, 0); // THtml directive handler
78 };
79 
81 private:
82  TString fText; // HTML text to be kept
83  Bool_t fVerbatim; // whether we are in a <pre></pre> block
84 public:
86  virtual ~TDocHtmlDirective() {}
87 
88  virtual void AddLine(const TSubString& line);
89  virtual const char* GetEndTag() const { return "end_html"; }
90  virtual Bool_t GetResult(TString& result);
91 
92  ClassDef(TDocHtmlDirective, 0); // Handler for "Begin_Html"/"End_Html" for raw HTML in documentation comments
93 };
94 
96 private:
97  TMacro* fMacro; // macro to be executed
98  Bool_t fNeedGraphics; // if set, we cannot switch to batch mode
99  Bool_t fShowSource; // whether a source tab should be created
100  Bool_t fIsFilename; // whether the directive is a failename to be executed
101 
102  virtual void AddParameter(const TString& name, const char* value = 0);
104 
105 public:
107  TDocDirective("MACRO"), fMacro(0), fNeedGraphics(kFALSE),
109  virtual ~TDocMacroDirective();
110 
111  virtual void AddLine(const TSubString& line);
112  virtual const char* GetEndTag() const { return "end_macro"; }
113  virtual Bool_t GetResult(TString& result);
114  // Delete output for the parser's current class or module.
115  virtual void DeleteOutput() const { DeleteOutputFiles(".gif"); }
116 
117  static void SubProcess(const TString& what, const TString& out);
118 
119  ClassDef(TDocMacroDirective, 0); // Handler for "Begin_Macro"/"End_Macro" for code that is executed and that can generate an image for documentation
120 };
121 
123 protected:
124  TMacro* fLatex; // collection of lines
125  Int_t fFontSize; // fontsize for current latex block, in pixels
126  TString fSeparator; // column separator, often "="
127  Bool_t fSepIsRegexp; // whether fSeparator is a regexp expression
128  TString fAlignment; // column alignment: 'l' for justify left, 'c' for center, 'r' for right
129  TVirtualPad* fBBCanvas; // canvas for bounding box determination
130 
131  virtual void CreateLatex(const char* filename);
132  virtual void AddParameter(const TString& name, const char* value = 0);
133  virtual void GetBoundingBox(TLatex& latex, const char* text, Float_t& width, Float_t& height);
134 
135 public:
137  TDocDirective("LATEX"), fLatex(0), fFontSize(16),
138  fSepIsRegexp(kFALSE), fBBCanvas(0) {};
139  virtual ~TDocLatexDirective();
140 
141  virtual void AddLine(const TSubString& line);
142  virtual const char* GetEndTag() const {return "end_latex";}
143 
144  const char* GetAlignment() const {return fAlignment;}
145  const char* GetSeparator() const {return fSeparator;}
147  Int_t GetFontSize() const {return fFontSize;}
148  TList* GetListOfLines() const;
149 
150  virtual Bool_t GetResult(TString& result);
151  // Delete output for the parser's current class or module.
152  virtual void DeleteOutput() const { DeleteOutputFiles(".gif"); }
153 
154  ClassDef(TDocLatexDirective, 0); // Handler for "Begin_Latex"/"End_Latex" to generate an image from latex
155 };
156 
157 #endif // ROOT_TDocDirective
TDocDirective::GetResult
virtual Bool_t GetResult(TString &result)=0
TDocDirective::TDocDirective
TDocDirective()
Definition: TDocDirective.h:44
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TDocDirective::GetHtml
THtml * GetHtml() const
Definition: TDocDirective.h:53
TDocLatexDirective::fSeparator
TString fSeparator
Definition: TDocDirective.h:126
TDocDirective::AddLine
virtual void AddLine(const TSubString &line)=0
TDocDirective::fCounter
Int_t fCounter
Definition: TDocDirective.h:40
TDocDirective::~TDocDirective
virtual ~TDocDirective()
Definition: TDocDirective.h:47
TDocDirective::SetParser
void SetParser(TDocParser *parser)
Set the parser, and fDocOutput, fHtml from that.
Definition: TDocDirective.cxx:150
TDocLatexDirective::fFontSize
Int_t fFontSize
Definition: TDocDirective.h:125
TDocLatexDirective::GetFontSize
Int_t GetFontSize() const
Definition: TDocDirective.h:147
TDocDirective::GetOutputDir
const char * GetOutputDir() const
Get the directory for documentation output.
Definition: TDocDirective.cxx:97
TNamed.h
TDocDirective::fDocParser
TDocParser * fDocParser
Definition: TDocDirective.h:36
Float_t
float Float_t
Definition: RtypesCore.h:57
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TDocHtmlDirective::GetResult
virtual Bool_t GetResult(TString &result)
Set result to the HTML code that was passed in via AddLine().
Definition: TDocDirective.cxx:220
TDocDirective::DeleteOutputFiles
virtual void DeleteOutputFiles(const char *ext) const
Delete all output generated by the directive beginning with Name() and ending with ext.
Definition: TDocDirective.cxx:53
TDocMacroDirective::DeleteOutput
virtual void DeleteOutput() const
Definition: TDocDirective.h:115
TDocMacroDirective::GetResult
virtual Bool_t GetResult(TString &result)
Get the result (i.e.
Definition: TDocDirective.cxx:430
TDocParser
Definition: TDocParser.h:44
TLatex
Definition: TLatex.h:18
TDocLatexDirective::~TDocLatexDirective
virtual ~TDocLatexDirective()
Destructor.
Definition: TDocDirective.cxx:611
TDocLatexDirective::GetResult
virtual Bool_t GetResult(TString &result)
convert fLatex to a gif by creating a TLatex, drawing it on a temporary canvas, and saving that to a ...
Definition: TDocDirective.cxx:829
TDocDirective::GetEndTag
virtual const char * GetEndTag() const =0
TDocMacroDirective::~TDocMacroDirective
virtual ~TDocMacroDirective()
Destructor.
Definition: TDocDirective.cxx:251
TString
Definition: TString.h:136
TDocHtmlDirective::AddLine
virtual void AddLine(const TSubString &line)
Add a line of HTML.
Definition: TDocDirective.cxx:169
TDocLatexDirective::GetListOfLines
TList * GetListOfLines() const
Get the list of lines as TObjStrings.
Definition: TDocDirective.cxx:819
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TDocLatexDirective::fLatex
TMacro * fLatex
Definition: TDocDirective.h:124
text
TText * text
Definition: entrylist_figure1.C:10
TDocLatexDirective::fAlignment
TString fAlignment
Definition: TDocDirective.h:128
bool
TDocLatexDirective::fSepIsRegexp
Bool_t fSepIsRegexp
Definition: TDocDirective.h:127
TDocMacroDirective::AddParameter
virtual void AddParameter(const TString &name, const char *value=0)
Setting fNeedGraphics if name is "GUI", setting fShowSource if name is "SOURCE".
Definition: TDocDirective.cxx:553
TDocLatexDirective::GetSeparator
const char * GetSeparator() const
Definition: TDocDirective.h:145
TDocLatexDirective::AddLine
virtual void AddLine(const TSubString &line)
Add a latex line.
Definition: TDocDirective.cxx:622
TDocHtmlDirective
Definition: TDocDirective.h:80
TDocDirective::fDocOutput
TDocOutput * fDocOutput
Definition: TDocDirective.h:38
THtml
Definition: THtml.h:40
TSubString
Definition: TString.h:82
TDocDirective
Definition: TDocDirective.h:34
TDocDirective::fParameters
TString fParameters
Definition: TDocDirective.h:39
TDocDirective::TDocDirective
TDocDirective(const char *name)
Definition: TDocDirective.h:45
TDocLatexDirective::SeparatorIsRegexp
Bool_t SeparatorIsRegexp() const
Definition: TDocDirective.h:146
TDocLatexDirective::GetEndTag
virtual const char * GetEndTag() const
Definition: TDocDirective.h:142
TDocHtmlDirective::~TDocHtmlDirective
virtual ~TDocHtmlDirective()
Definition: TDocDirective.h:86
TNamed
Definition: TNamed.h:29
TDocDirective::fHtml
THtml * fHtml
Definition: TDocDirective.h:37
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TDocLatexDirective::CreateLatex
virtual void CreateLatex(const char *filename)
Create a gif file named filename from a latex expression in fLatex.
Definition: TDocDirective.cxx:645
TDocDirective::SetParameters
void SetParameters(const char *params)
Given a string containing parameters in params, we call AddParameter() for each of them.
Definition: TDocDirective.cxx:115
TDocMacroDirective::TDocMacroDirective
TDocMacroDirective()
Definition: TDocDirective.h:106
TDocMacroDirective::SubProcess
static void SubProcess(const TString &what, const TString &out)
Definition: TDocDirective.cxx:258
TDocMacroDirective
Definition: TDocDirective.h:95
TDocMacroDirective::AddLine
virtual void AddLine(const TSubString &line)
Add a macro line.
Definition: TDocDirective.cxx:325
what
static const char * what
Definition: stlLoader.cc:6
TDocLatexDirective
Definition: TDocDirective.h:122
TDocMacroDirective::CreateSubprocessInputFile
TString CreateSubprocessInputFile()
Create the input file for SubProcess().
Definition: TDocDirective.cxx:345
TNamed::SetTitle
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
line
TLine * line
Definition: entrylistblock_figure1.C:235
TDocHtmlDirective::TDocHtmlDirective
TDocHtmlDirective()
Definition: TDocDirective.h:85
TDocDirective::DeleteOutput
virtual void DeleteOutput() const
Definition: TDocDirective.h:73
TMacro
Definition: TMacro.h:31
TDocHtmlDirective::GetEndTag
virtual const char * GetEndTag() const
Definition: TDocDirective.h:89
TDocLatexDirective::TDocLatexDirective
TDocLatexDirective()
Definition: TDocDirective.h:136
TDocOutput
Definition: TDocOutput.h:37
TDocHtmlDirective::fVerbatim
Bool_t fVerbatim
Definition: TDocDirective.h:83
TDocLatexDirective::fBBCanvas
TVirtualPad * fBBCanvas
Definition: TDocDirective.h:129
TDocLatexDirective::GetAlignment
const char * GetAlignment() const
Definition: TDocDirective.h:144
TDocMacroDirective::fShowSource
Bool_t fShowSource
Definition: TDocDirective.h:99
TVirtualPad
Definition: TVirtualPad.h:50
TDocMacroDirective::fMacro
TMacro * fMacro
Definition: TDocDirective.h:97
TClass
Definition: TClass.h:80
TDocLatexDirective::AddParameter
virtual void AddParameter(const TString &name, const char *value=0)
Parse fParameters, setting fFontSize, fAlignment, and fSeparator.
Definition: TDocDirective.cxx:870
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
TDocLatexDirective::GetBoundingBox
virtual void GetBoundingBox(TLatex &latex, const char *text, Float_t &width, Float_t &height)
Determines the bounding box for text as height and width.
Definition: TDocDirective.cxx:804
TDocMacroDirective::fIsFilename
Bool_t fIsFilename
Definition: TDocDirective.h:100
TDocDirective::SetTag
void SetTag(const char *tag)
Definition: TDocDirective.h:58
TDocLatexDirective::DeleteOutput
virtual void DeleteOutput() const
Definition: TDocDirective.h:152
TDocDirective::GetDocOutput
TDocOutput * GetDocOutput() const
Definition: TDocDirective.h:52
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:53
TDocDirective::SetCounter
void SetCounter(Int_t count)
Definition: TDocDirective.h:59
TDocDirective::GetName
const char * GetName() const
Returns name of object.
Definition: TDocDirective.h:49
TDocDirective::AddParameter
virtual void AddParameter(const TString &, const char *=0)
Definition: TDocDirective.h:42
TDocHtmlDirective::fText
TString fText
Definition: TDocDirective.h:82
TDocMacroDirective::fNeedGraphics
Bool_t fNeedGraphics
Definition: TDocDirective.h:98
TDocMacroDirective::GetEndTag
virtual const char * GetEndTag() const
Definition: TDocDirective.h:112
TDocDirective::GetDocParser
TDocParser * GetDocParser() const
Definition: TDocDirective.h:51
TList
Definition: TList.h:44
int