Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
26class TClass;
27class TDocParser;
28class TDocOutput;
29class THtml;
30class TLatex;
31class TMacro;
32class TVirtualPad;
33
34class TDocDirective: public TNamed {
35protected:
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
62public:
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
81private:
82 TString fText; // HTML text to be kept
83 Bool_t fVerbatim; // whether we are in a <pre></pre> block
84public:
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
96private:
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
105public:
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
123protected:
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
135public:
137 TDocDirective("LATEX"), fLatex(0), fFontSize(16),
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
const Bool_t kFALSE
Definition RtypesCore.h:101
bool Bool_t
Definition RtypesCore.h:63
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassDef(name, id)
Definition Rtypes.h:325
include TDocParser_001 C image html pict1_TDocParser_001 png width
char name[80]
Definition TGX11.cxx:110
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:80
TDocParser * fDocParser
TDocOutput * fDocOutput
virtual void AddParameter(const TString &, const char *=0)
TDocParser * GetDocParser() const
const char * GetName() const
Returns name of object.
virtual void DeleteOutputFiles(const char *ext) const
Delete all output generated by the directive beginning with Name() and ending with ext.
virtual Bool_t GetResult(TString &result)=0
THtml * GetHtml() const
void SetCounter(Int_t count)
void SetTag(const char *tag)
virtual const char * GetEndTag() const =0
TDocDirective(const char *name)
TString fParameters
void SetParameters(const char *params)
Given a string containing parameters in params, we call AddParameter() for each of them.
TDocOutput * GetDocOutput() const
virtual ~TDocDirective()
virtual void DeleteOutput() const
void SetParser(TDocParser *parser)
Set the parser, and fDocOutput, fHtml from that.
virtual void AddLine(const TSubString &line)=0
const char * GetOutputDir() const
Get the directory for documentation output.
virtual void AddLine(const TSubString &line)
Add a line of HTML.
virtual Bool_t GetResult(TString &result)
Set result to the HTML code that was passed in via AddLine().
virtual const char * GetEndTag() const
virtual ~TDocHtmlDirective()
virtual void CreateLatex(const char *filename)
Create a gif file named filename from a latex expression in fLatex.
Bool_t SeparatorIsRegexp() const
const char * GetSeparator() const
virtual const char * GetEndTag() const
virtual ~TDocLatexDirective()
Destructor.
const char * GetAlignment() const
virtual void DeleteOutput() const
virtual void AddLine(const TSubString &line)
Add a latex line.
TList * GetListOfLines() const
Get the list of lines as TObjStrings.
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 ...
virtual void AddParameter(const TString &name, const char *value=0)
Parse fParameters, setting fFontSize, fAlignment, and fSeparator.
Int_t GetFontSize() const
virtual void GetBoundingBox(TLatex &latex, const char *text, Float_t &width, Float_t &height)
Determines the bounding box for text as height and width.
TVirtualPad * fBBCanvas
virtual Bool_t GetResult(TString &result)
Get the result (i.e.
virtual void AddLine(const TSubString &line)
Add a macro line.
virtual const char * GetEndTag() const
virtual ~TDocMacroDirective()
Destructor.
TString CreateSubprocessInputFile()
Create the input file for SubProcess().
virtual void AddParameter(const TString &name, const char *value=0)
Setting fNeedGraphics if name is "GUI", setting fShowSource if name is "SOURCE".
static void SubProcess(const TString &what, const TString &out)
virtual void DeleteOutput() const
Legacy ROOT documentation system.
Definition THtml.h:40
To draw Mathematical Formula.
Definition TLatex.h:18
A doubly linked list.
Definition TList.h:38
Class supporting a collection of lines with C++ code.
Definition TMacro.h:31
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
Basic string class.
Definition TString.h:136
A zero length substring is legal.
Definition TString.h:82
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
TText * text
TLine * line
static const char * what
Definition stlLoader.cc:6