forked from cxx-hep/root-cern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTDocDirective.h
156 lines (123 loc) · 6.06 KB
/
TDocDirective.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// @(#)root/html:$Id$
// Author: Axel Naumann 2007-01-25
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TDocDirective
#define ROOT_TDocDirective
////////////////////////////////////////////////////////////////////////////
// //
// TDocDirective //
// //
// Special treatment of comments, like HTML source, a macro, or latex. //
// //
////////////////////////////////////////////////////////////////////////////
#ifndef ROOT_TNamed
#include "TNamed.h"
#endif
class TClass;
class TDocParser;
class TDocOutput;
class THtml;
class TLatex;
class TMacro;
class TVirtualPad;
class TDocDirective: public TNamed {
protected:
TDocParser* fDocParser; // parser invoking this handler
THtml* fHtml; // parser's THtml object
TDocOutput* fDocOutput; // parser invoking this handler
TString fParameters; // parameters to the directive
Int_t fCounter; // counter to generate unique names, -1 to ignore
virtual void AddParameter(const TString& /*name*/, const char* /*value*/ = 0) {}
TDocDirective() {}
TDocDirective(const char* name):
TNamed(name, ""), fDocParser(0), fHtml(0), fDocOutput(0), fCounter(-1) {};
virtual ~TDocDirective() {}
const char* GetName() const { return TNamed::GetName(); }
void GetName(TString& name) const;
TDocParser* GetDocParser() const { return fDocParser; }
TDocOutput* GetDocOutput() const { return fDocOutput; }
THtml* GetHtml() const { return fHtml; }
const char* GetOutputDir() const;
void SetParser(TDocParser* parser);
void SetParameters(const char* params);
void SetTag(const char* tag) { SetTitle(tag); }
void SetCounter(Int_t count) { fCounter = count; }
virtual void DeleteOutputFiles(const char* ext) const;
public:
// get the tag ending this directive
virtual const char* GetEndTag() const = 0;
// add a line to the directive's text
virtual void AddLine(const TSubString& line) = 0;
// retrieve the result (replacement) of the directive; return false if invalid
virtual Bool_t GetResult(TString& result) = 0;
// Delete output for the parser's current class or module.
virtual void DeleteOutput() const {}
friend class TDocParser;
ClassDef(TDocDirective, 0); // THtml directive handler
};
class TDocHtmlDirective: public TDocDirective {
private:
TString fText; // HTML text to be kept
Bool_t fVerbatim; // whether we are in a <pre></pre> block
public:
TDocHtmlDirective(): TDocDirective("HTML"), fVerbatim(kFALSE) {}
virtual ~TDocHtmlDirective() {}
virtual void AddLine(const TSubString& line);
virtual const char* GetEndTag() const { return "end_html"; }
virtual Bool_t GetResult(TString& result);
ClassDef(TDocHtmlDirective, 0); // Handler for "Begin_Html"/"End_Html" for raw HTML in documentation comments
};
class TDocMacroDirective: public TDocDirective {
private:
TMacro* fMacro; // macro to be executed
Bool_t fNeedGraphics; // if set, we cannot switch to batch mode
Bool_t fShowSource; // whether a source tab should be created
Bool_t fIsFilename; // whether the directive is a failename to be executed
virtual void AddParameter(const TString& name, const char* value = 0);
public:
TDocMacroDirective():
TDocDirective("MACRO"), fMacro(0), fNeedGraphics(kFALSE),
fShowSource(kFALSE), fIsFilename(kTRUE) {};
virtual ~TDocMacroDirective();
virtual void AddLine(const TSubString& line);
virtual const char* GetEndTag() const { return "end_macro"; }
virtual Bool_t GetResult(TString& result);
// Delete output for the parser's current class or module.
virtual void DeleteOutput() const { DeleteOutputFiles(".gif"); }
ClassDef(TDocMacroDirective, 0); // Handler for "Begin_Macro"/"End_Macro" for code that is executed and that can generate an image for documentation
};
class TDocLatexDirective: public TDocDirective {
protected:
TMacro* fLatex; // collection of lines
Int_t fFontSize; // fontsize for current latex block, in pixels
TString fSeparator; // column separator, often "="
Bool_t fSepIsRegexp; // whether fSeparator is a regexp expression
TString fAlignment; // column alignment: 'l' for justify left, 'c' for center, 'r' for right
TVirtualPad* fBBCanvas; // canvas for bounding box determination
virtual void CreateLatex(const char* filename);
virtual void AddParameter(const TString& name, const char* value = 0);
virtual void GetBoundingBox(TLatex& latex, const char* text, Float_t& width, Float_t& height);
public:
TDocLatexDirective():
TDocDirective("LATEX"), fLatex(0), fFontSize(16),
fSepIsRegexp(kFALSE), fBBCanvas(0) {};
virtual ~TDocLatexDirective();
virtual void AddLine(const TSubString& line);
virtual const char* GetEndTag() const {return "end_latex";}
const char* GetAlignment() const {return fAlignment;}
const char* GetSeparator() const {return fSeparator;}
Bool_t SeparatorIsRegexp() const {return fSepIsRegexp;}
Int_t GetFontSize() const {return fFontSize;}
TList* GetListOfLines() const;
virtual Bool_t GetResult(TString& result);
// Delete output for the parser's current class or module.
virtual void DeleteOutput() const { DeleteOutputFiles(".gif"); }
ClassDef(TDocLatexDirective, 0); // Handler for "Begin_Latex"/"End_Latex" to generate an image from latex
};
#endif // ROOT_TDocDirective