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 ~TDocDirective() override {}
48
49 const char* GetName() const override { 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
71
72 // Delete output for the parser's current class or module.
73 virtual void DeleteOutput() const {}
74
75 friend class TDocParser;
76
77 ClassDefOverride(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 ~TDocHtmlDirective() override {}
87
88 void AddLine(const TSubString& line) override;
89 const char* GetEndTag() const override { return "end_html"; }
90 Bool_t GetResult(TString& result) override;
91
92 ClassDefOverride(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 void AddParameter(const TString& name, const char* value = 0) override;
104
105public:
109 ~TDocMacroDirective() override;
110
111 void AddLine(const TSubString& line) override;
112 const char* GetEndTag() const override { return "end_macro"; }
113 Bool_t GetResult(TString& result) override;
114 // Delete output for the parser's current class or module.
115 void DeleteOutput() const override { DeleteOutputFiles(".gif"); }
116
117 static void SubProcess(const TString& what, const TString& out);
118
119 ClassDefOverride(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 void AddParameter(const TString& name, const char* value = 0) override;
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 ~TDocLatexDirective() override;
140
141 void AddLine(const TSubString& line) override;
142 const char* GetEndTag() const override {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 Bool_t GetResult(TString& result) override;
151 // Delete output for the parser's current class or module.
152 void DeleteOutput() const override { DeleteOutputFiles(".gif"); }
153
154 ClassDefOverride(TDocLatexDirective, 0); // Handler for "Begin_Latex"/"End_Latex" to generate an image from latex
155};
156
157#endif // ROOT_TDocDirective
bool Bool_t
Definition RtypesCore.h:63
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:110
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
TDocParser * fDocParser
TDocOutput * fDocOutput
virtual void AddParameter(const TString &, const char *=0)
TDocParser * GetDocParser() const
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)
~TDocDirective() override
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 void DeleteOutput() const
void SetParser(TDocParser *parser)
Set the parser, and fDocOutput, fHtml from that.
virtual void AddLine(const TSubString &line)=0
const char * GetName() const override
Returns name of object.
const char * GetOutputDir() const
Get the directory for documentation output.
Bool_t GetResult(TString &result) override
Set result to the HTML code that was passed in via AddLine().
~TDocHtmlDirective() override
void AddLine(const TSubString &line) override
Add a line of HTML.
const char * GetEndTag() const override
virtual void CreateLatex(const char *filename)
Create a gif file named filename from a latex expression in fLatex.
Bool_t SeparatorIsRegexp() const
void DeleteOutput() const override
Bool_t GetResult(TString &result) override
convert fLatex to a gif by creating a TLatex, drawing it on a temporary canvas, and saving that to a ...
const char * GetSeparator() const
const char * GetEndTag() const override
void AddParameter(const TString &name, const char *value=0) override
Parse fParameters, setting fFontSize, fAlignment, and fSeparator.
void AddLine(const TSubString &line) override
Add a latex line.
const char * GetAlignment() const
TList * GetListOfLines() const
Get the list of lines as TObjStrings.
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
~TDocLatexDirective() override
Destructor.
~TDocMacroDirective() override
Destructor.
void DeleteOutput() const override
const char * GetEndTag() const override
TString CreateSubprocessInputFile()
Create the input file for SubProcess().
static void SubProcess(const TString &what, const TString &out)
void AddLine(const TSubString &line) override
Add a macro line.
void AddParameter(const TString &name, const char *value=0) override
Setting fNeedGraphics if name is "GUI", setting fShowSource if name is "SOURCE".
Bool_t GetResult(TString &result) override
Get the result (i.e.
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
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Basic string class.
Definition TString.h:139
A zero length substring is legal.
Definition TString.h:85
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
TLine * line
static const char * what
Definition stlLoader.cc:5