ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/Utils/interface/THtml.h
Revision: 1.1
Committed: Tue Aug 11 23:09:27 2009 UTC (15 years, 8 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a, Mit_011, Mit_010a, HEAD
Branch point for: Mit_025c_branch
Log Message:
Added THtml from ROOT

File Contents

# User Rev Content
1 loizides 1.1 // @(#)root/html:$Id: THtml.h 26944 2008-12-16 10:27:55Z brun $
2     // Author: Nenad Buncic 18/10/95
3    
4     /*************************************************************************
5     * Copyright (C) 1995-2000, 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_THtml
13     #define ROOT_THtml
14    
15    
16     ////////////////////////////////////////////////////////////////////////////
17     // //
18     // THtml //
19     // //
20     // Html generates documentation for all ROOT classes //
21     // using XHTML 1.0 transitional //
22     // //
23     ////////////////////////////////////////////////////////////////////////////
24    
25     #ifndef ROOT_THashList
26     #include "THashList.h"
27     #endif
28    
29     #ifndef ROOT_THashTable
30     #include "THashTable.h"
31     #endif
32    
33     #ifndef ROOT_TExMap
34     #include "TExMap.h"
35     #endif
36    
37     #include <map>
38    
39     class TClass;
40     class TClassDocInfo;
41     class TGClient;
42     class TVirtualMutex;
43    
44     class THtml: public TObject {
45     public:
46     //______________________________________________________________
47     // Helper base class.
48     class THelperBase: public TObject {
49     public:
50     THelperBase(): fHtml(0) {}
51     virtual ~THelperBase();
52     void SetOwner(THtml* html);
53     THtml* GetOwner() const { return fHtml; }
54     private:
55     THtml* fHtml; // object owning the helper
56     ClassDef(THelperBase, 0); // a helper object's base class
57     };
58    
59     //______________________________________________________________
60     // Helper class to translate between classes and their
61     // modules. Can be derived from and thus replaced by
62     // the user; see THtml::SetModuleDefinition().
63     class TModuleDefinition: public THelperBase {
64     public:
65     virtual bool GetModule(TClass* cl, TString& out_modulename) const;
66     ClassDef(TModuleDefinition, 0); // helper class to determine a class's module
67     };
68    
69     //______________________________________________________________
70     // Helper class to translate between classes and their
71     // filenames. Can be derived from and thus replaced by
72     // the user; see THtml::SetFileDefinition().
73     class TFileDefinition: public THelperBase {
74     public:
75     virtual bool GetDeclFileName(const TClass* cl, TString& out_filename, TString& out_fsys) const;
76     virtual bool GetImplFileName(const TClass* cl, TString& out_filename, TString& out_fsys) const;
77     protected:
78     virtual bool GetFileName(const TClass* cl, bool decl, TString& out_filename, TString& out_fsys) const;
79    
80     void SplitClassIntoDirFile(const TString& clname, TString& dir, TString& filename) const;
81     void ExpandSearchPath(TString& path) const;
82     ClassDef(TFileDefinition, 0); // helper class to determine a class's source files
83     };
84    
85     //______________________________________________________________
86     // Helper class to translate between file names and their
87     // version used for documentation. Can be derived from and thus
88     // replaced by the user; see THtml::SetPathDefinition().
89     class TPathDefinition: public THelperBase {
90     public:
91     virtual bool GetMacroPath(const TString& module, TString& out_dir) const;
92     virtual bool GetIncludeAs(TClass* cl, TString& out_include_as) const;
93     virtual bool GetFileNameFromInclude(const char* included, TString& out_fsname) const;
94     virtual bool GetDocDir(const TString& module, TString& doc_dir) const;
95     protected:
96     ClassDef(TPathDefinition, 0); // helper class to determine directory layouts
97     };
98    
99     class TFileSysDir;
100     class TFileSysDB;
101     //______________________________________________________________
102     // Utility class representing a directory entry
103     class TFileSysEntry: public TObject {
104     public:
105     TFileSysEntry(const char* name, TFileSysDir* parent):
106     fName(name), fParent(parent), fLevel(parent ? parent->GetLevel() + 1 : 0) {}
107     const char* GetName() const { return fName; }
108     virtual ULong_t Hash() const { return fName.Hash(); }
109     virtual void GetFullName(TString& fullname, Bool_t asIncluded) const {
110     if (fParent) {
111     fParent->GetFullName(fullname, asIncluded);
112     fullname += "/";
113     } else
114     fullname = "";
115     fullname += fName;
116     }
117    
118     TFileSysDir* GetParent() const { return fParent; }
119     Int_t GetLevel() const { return fLevel; }
120     protected:
121     TString fName; // name of the element
122     TFileSysDir* fParent; // parent directory
123     Int_t fLevel; // level of directory
124     ClassDef(TFileSysEntry, 0); // an entry of the local file system
125     };
126    
127     //______________________________________________________________
128     // Utility class representing a directory
129     class TFileSysDir: public TFileSysEntry {
130     public:
131     TFileSysDir(const char* name, TFileSysDir* parent):
132     TFileSysEntry(name, parent)
133     { fFiles.SetOwner(); fDirs.SetOwner(); }
134     const TList* GetFiles() const { return &fFiles; }
135     const TList* GetSubDirs() const { return &fDirs; }
136    
137     void Recurse(TFileSysDB* db, const char* path);
138    
139     protected:
140     TList fFiles;
141     TList fDirs;
142     ClassDef(TFileSysDir, 0); // an directory of the local file system
143     };
144    
145     //______________________________________________________________
146     // Utility class representing a root directory as specified in
147     // THtml::GetInputPath()
148     class TFileSysRoot: public TFileSysDir {
149     public:
150     TFileSysRoot(const char* name, TFileSysDB* parent):
151     TFileSysDir(name, parent) {}
152     void GetFullName(TString& fullname, Bool_t asIncluded) const {
153     // prepend directory part of THtml::GetInputPath() only
154     // if !asIncluded
155     fullname = "";
156     if (!asIncluded)
157     fullname += fName;
158     }
159    
160     ClassDef(TFileSysRoot, 0); // an root directory of the local file system
161     };
162    
163     //______________________________________________________________
164     // Utility class representing a directory
165     class TFileSysDB: public TFileSysDir {
166     public:
167     TFileSysDB(const char* path, const char* ignore, Int_t maxdirlevel):
168     TFileSysDir(path, 0), fIgnorePath(ignore), fMaxLevel(maxdirlevel)
169     { Fill(); }
170    
171     TExMap& GetMapIno() { return fMapIno; }
172     THashTable& GetEntries() { return fEntries; }
173     const TString& GetIgnore() const { return fIgnorePath; }
174     Int_t GetMaxLevel() const { return fMaxLevel; }
175    
176     protected:
177     void Fill();
178    
179     private:
180     TExMap fMapIno; // inode to TFileSysDir map, to detect softlinks
181     THashTable fEntries; // hash map of all filenames without paths
182     TString fIgnorePath; // regexp of path to ignore while building entry tree
183     Int_t fMaxLevel; // maximum level of directory nesting
184     ClassDef(TFileSysDB, 0); // instance of file system data
185     };
186    
187    
188     //______________________________________________________________
189     // Configuration holder for path related settings
190     struct PathInfo_t {
191     enum EDotAccess {
192     kDotUnknown,
193     kDotFound,
194     kDotNotFound
195     };
196    
197     PathInfo_t():
198     fFoundDot(kDotUnknown),
199     #ifdef R__WIN32
200     fInputPath("./;src/;include/"),
201     #else
202     fInputPath("./:src/:include/"),
203     #endif
204     fIncludePath("include"),
205     // .whatever implicitly ignored, no need to add .svn!
206     fIgnorePath("\\b(include|CVS|test|tutorials|doc|lib|python|demo|freetype-|gdk|libAfterImage|etc|config|build|bin)\\b"),
207     fDocPath("doc"),
208     fMacroPath("macros:."),
209     fOutputDir("htmldoc") {}
210    
211     EDotAccess fFoundDot; // whether dot is accessible
212     TString fInputPath; // directories to look for classes; prepended to Decl/ImplFileName()
213     TString fIncludePath; // directory prefixes (":" delimited) to remove when quoting include files
214     TString fIgnorePath; // regexp pattern for directories to ignore ("\b(CVS|\.svn)\b") for ROOT
215     TString fDocPath; // subdir to check for module documentation ("doc" for ROOT)
216     TString fMacroPath; // subdir of fDocPath for macros run via the Begin/End Macro directive; ("macros" for ROOT)
217     TString fDotDir; // directory of GraphViz's dot binary
218     TString fEtcDir; // directory containing auxiliary files
219     TString fOutputDir; // output directory
220     };
221    
222    
223     public:
224     enum EConvertOutput {
225     kNoOutput, // do not run the source, do not show its output
226     kInterpretedOutput, // interpret the source and show output
227     kCompiledOutput, // run the source through ACLiC and show output
228     kForceOutput = 0x10, // re-generate the output files (canvas PNGs)
229     kSeparateProcessOutput = 0x20 // run the script in a separate process
230     };
231    
232     THtml();
233     virtual ~THtml();
234    
235     static void LoadAllLibs();
236    
237     // Functions to generate documentation
238     void Convert(const char *filename, const char *title,
239     const char *dirname = "", const char *relpath="../",
240     Int_t includeOutput = kNoOutput,
241     const char* context = "");
242     void CreateHierarchy();
243     void MakeAll(Bool_t force=kFALSE, const char *filter="*",
244     int numthreads = 1);
245     void MakeClass(const char *className, Bool_t force=kFALSE);
246     void MakeIndex(const char *filter="*");
247     void MakeTree(const char *className, Bool_t force=kFALSE);
248    
249     // Configuration setters
250     void SetModuleDefinition(const TModuleDefinition& md);
251     void SetFileDefinition(const TFileDefinition& fd);
252     void SetPathDefinition(const TPathDefinition& pd);
253     void SetProductName(const char* product) { fProductName = product; }
254     void SetOutputDir(const char *dir) { fPathInfo.fOutputDir = dir; }
255     void SetInputDir(const char *dir);
256     void SetEtcDir(const char* dir) { fPathInfo.fEtcDir = dir; }
257     void SetDocPath(const char* path) { fPathInfo.fDocPath = path; }
258     void SetDotDir(const char* dir) { fPathInfo.fDotDir = dir; fPathInfo.fFoundDot = PathInfo_t::kDotUnknown; }
259     void SetRootURL(const char* url) { fLinkInfo.fROOTURL = url; }
260     void SetLibURL(const char* lib, const char* url) { fLinkInfo.fLibURLs[lib] = url; }
261     void SetXwho(const char *xwho) { fLinkInfo.fXwho = xwho; }
262     void SetMacroPath(const char* path) {fPathInfo.fMacroPath = path;}
263     void AddMacroPath(const char* path);
264     void SetCounterFormat(const char* format) { fCounterFormat = format; }
265     void SetClassDocTag(const char* tag) { fDocSyntax.fClassDocTag = tag; }
266     void SetAuthorTag(const char* tag) { fDocSyntax.fAuthorTag = tag; }
267     void SetLastUpdateTag(const char* tag) { fDocSyntax.fLastUpdateTag = tag; }
268     void SetCopyrightTag(const char* tag) { fDocSyntax.fCopyrightTag = tag; }
269     void SetHeader(const char* file) { fOutputStyle.fHeader = file; }
270     void SetFooter(const char* file) { fOutputStyle.fFooter = file; }
271     void SetHomepage(const char* url) { fLinkInfo.fHomepage = url; }
272     void SetSearchStemURL(const char* url) { fLinkInfo.fSearchStemURL = url; }
273     void SetSearchEngine(const char* url) { fLinkInfo.fSearchEngine = url; }
274     void SetViewCVS(const char* url) { fLinkInfo.fViewCVS = url; }
275     void SetWikiURL(const char* url) { fLinkInfo.fWikiURL = url; }
276     void SetCharset(const char* charset) { fOutputStyle.fCharset = charset; }
277     void SetDocStyle(const char* style) { fDocSyntax.fDocStyle = style; }
278    
279     // Configuration getters
280     const TModuleDefinition& GetModuleDefinition() const;
281     const TFileDefinition& GetFileDefinition() const;
282     const TPathDefinition& GetPathDefinition() const;
283     const TString& GetProductName() const { return fProductName; }
284     const TString& GetInputPath() const { return fPathInfo.fInputPath; }
285     const TString& GetOutputDir(Bool_t createDir = kTRUE) const;
286     virtual const char* GetEtcDir() const;
287     const TString& GetModuleDocPath() const { return fPathInfo.fDocPath; }
288     const TString& GetDotDir() const { return fPathInfo.fDotDir; }
289     const char* GetURL(const char* lib = 0) const;
290     const TString& GetXwho() const { return fLinkInfo.fXwho; }
291     const TString& GetMacroPath() const { return fPathInfo.fMacroPath; }
292     const char* GetCounterFormat() const { return fCounterFormat; }
293     const TString& GetClassDocTag() const { return fDocSyntax.fClassDocTag; }
294     const TString& GetAuthorTag() const { return fDocSyntax.fAuthorTag; }
295     const TString& GetLastUpdateTag() const { return fDocSyntax.fLastUpdateTag; }
296     const TString& GetCopyrightTag() const { return fDocSyntax.fCopyrightTag; }
297     const TString& GetHeader() const { return fOutputStyle.fHeader; }
298     const TString& GetFooter() const { return fOutputStyle.fFooter; }
299     const TString& GetHomepage() const { return fLinkInfo.fHomepage; }
300     const TString& GetSearchStemURL() const { return fLinkInfo.fSearchStemURL; }
301     const TString& GetSearchEngine() const { return fLinkInfo.fSearchEngine; }
302     const TString& GetViewCVS() const { return fLinkInfo.fViewCVS; }
303     const TString& GetWikiURL() const { return fLinkInfo.fWikiURL; }
304     const TString& GetCharset() const { return fOutputStyle.fCharset; }
305     const TString& GetDocStyle() const { return fDocSyntax.fDocStyle; }
306    
307     // Functions that should only be used by TDocOutput etc.
308     Bool_t CopyFileFromEtcDir(const char* filename) const;
309     virtual void CreateAuxiliaryFiles() const;
310     virtual TClass* GetClass(const char *name) const;
311     const char* GetCounter() const { return fCounter; }
312     void GetModuleMacroPath(const TString& module, TString& out_path) const { GetPathDefinition().GetMacroPath(module, out_path); }
313     virtual bool GetDeclFileName(TClass* cl, Bool_t filesys, TString& out_name) const;
314     void GetDerivedClasses(TClass* cl, std::map<TClass*, Int_t>& derived) const;
315     static const char* GetDirDelimiter() {
316     // ";" on windows, ":" everywhere else
317     #ifdef R__WIN32
318     return ";";
319     #else
320     return ":";
321     #endif
322     }
323     virtual bool GetImplFileName(TClass* cl, Bool_t filesys, TString& out_name) const;
324     virtual void GetHtmlFileName(TClass *classPtr, TString& filename) const;
325     virtual const char* GetHtmlFileName(const char* classname) const;
326     TList* GetLibraryDependencies() { return &fDocEntityInfo.fLibDeps; }
327     void SortListOfModules() { fDocEntityInfo.fModules.Sort(); }
328     const TList* GetListOfModules() const { return &fDocEntityInfo.fModules; }
329     const TList* GetListOfClasses() const { return &fDocEntityInfo.fClasses; }
330     TFileSysDB* GetLocalFiles() const { if (!fLocalFiles) SetLocalFiles(); return fLocalFiles; }
331     TVirtualMutex* GetMakeClassMutex() const { return fMakeClassMutex; }
332     virtual void GetModuleNameForClass(TString& module, TClass* cl) const;
333     const PathInfo_t& GetPathInfo() const { return fPathInfo; }
334     Bool_t HaveDot();
335     void HelperDeleted(THelperBase* who);
336     static Bool_t IsNamespace(const TClass*cl);
337     void SetDeclFileName(TClass* cl, const char* filename);
338     void SetFoundDot(Bool_t found = kTRUE);
339     void SetImplFileName(TClass* cl, const char* filename);
340     void SetBatch(Bool_t batch = kTRUE) { fBatch = batch; }
341     Bool_t IsBatch() const { return fBatch; }
342     // unused
343     void ReplaceSpecialChars(std::ostream&, const char*) {
344     Error("ReplaceSpecialChars",
345     "Removed, call TDocOutput::ReplaceSpecialChars() instead!"); }
346     void SetEscape(char /*esc*/ ='\\') {} // for backward comp
347    
348     protected:
349     struct DocSyntax_t {
350     TString fClassDocTag; // tag for class documentation
351     TString fAuthorTag; // tag for author
352     TString fLastUpdateTag; // tag for last update
353     TString fCopyrightTag; // tag for copyright
354     TString fDocStyle; // doc style (only "Doc++" has special treatment)
355     };
356    
357     struct LinkInfo_t {
358     TString fXwho; // URL for name lookup
359     TString fROOTURL; // Root URL for ROOT's reference guide for libs that are not in fLibURLs
360     std::map<std::string, TString> fLibURLs; // URL for documentation of external libraries
361     TString fHomepage; // URL of homepage
362     TString fSearchStemURL; // URL stem used to build search URL
363     TString fSearchEngine; // link to search engine
364     TString fViewCVS; // link to ViewCVS; %f is replaced by the filename (no %f: it's appended)
365     TString fWikiURL; // URL stem of class's wiki page, %c replaced by mangled class name (no %c: appended)
366     };
367    
368     struct OutputStyle_t {
369     TString fHeader; // header file name
370     TString fFooter; // footerer file name
371     TString fCharset; // Charset for doc pages
372     };
373    
374     struct DocEntityInfo_t {
375     TString fClassFilter; // filter used for buidling known classes
376     THashList fClasses; // known classes
377     THashList fModules; // known modules
378     THashList fLibDeps; // Library dependencies
379     };
380    
381     protected:
382     virtual void CreateJavascript() const;
383     virtual void CreateStyleSheet() const;
384     void CreateListOfTypes();
385     void CreateListOfClasses(const char* filter);
386     virtual bool GetDeclImplFileName(TClass* cl, bool filesys, bool decl, TString& out_name) const;
387     void MakeClass(void* cdi, Bool_t force=kFALSE);
388     TClassDocInfo *GetNextClass();
389     void SetLocalFiles() const;
390    
391     static void *MakeClassThreaded(void* info);
392    
393     protected:
394     TString fCounter; // counter string
395     TString fCounterFormat; // counter printf-like format
396     TString fProductName; // name of the product to document
397     TIter *fThreadedClassIter; // fClasses iterator for MakeClassThreaded
398     Int_t fThreadedClassCount; // counter of processed classes for MakeClassThreaded
399     TVirtualMutex *fMakeClassMutex; // Mutex for MakeClassThreaded
400     TGClient *fGClient; // gClient, cached and queried through CINT
401     DocSyntax_t fDocSyntax; // doc syntax configuration
402     LinkInfo_t fLinkInfo; // link (URL) configuration
403     OutputStyle_t fOutputStyle; // output style configuration
404     mutable PathInfo_t fPathInfo; // path configuration
405     DocEntityInfo_t fDocEntityInfo; // data for documented entities
406     mutable TPathDefinition *fPathDef; // object translating classes to module names
407     mutable TModuleDefinition *fModuleDef; // object translating classes to module names
408     mutable TFileDefinition* fFileDef; // object translating classes to file names
409     mutable TFileSysDB *fLocalFiles; // files found locally for a given source path
410     Bool_t fBatch; // Whether to enable GUI output
411    
412     ClassDef(THtml,0) //Convert class(es) into HTML file(s)
413     };
414    
415     R__EXTERN THtml *gHtml;
416    
417     #endif