00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_THtml
00013 #define ROOT_THtml
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef ROOT_THashList
00026 #include "THashList.h"
00027 #endif
00028
00029 #ifndef ROOT_THashTable
00030 #include "THashTable.h"
00031 #endif
00032
00033 #ifndef ROOT_TExMap
00034 #include "TExMap.h"
00035 #endif
00036
00037 #include <map>
00038
00039 class TClass;
00040 class TClassDocInfo;
00041 class TGClient;
00042 class TVirtualMutex;
00043
00044 class THtml: public TObject {
00045 public:
00046
00047
00048 class THelperBase: public TObject {
00049 public:
00050 THelperBase(): fHtml(0) {}
00051 virtual ~THelperBase();
00052 void SetOwner(THtml* html);
00053 THtml* GetOwner() const { return fHtml; }
00054 private:
00055 THtml* fHtml;
00056 ClassDef(THelperBase, 0);
00057 };
00058
00059 class TFileSysEntry;
00060
00061
00062
00063
00064
00065 class TModuleDefinition: public THelperBase {
00066 public:
00067 virtual bool GetModule(TClass* cl, TFileSysEntry* fse, TString& out_modulename) const;
00068 ClassDef(TModuleDefinition, 0);
00069 };
00070
00071
00072
00073
00074
00075 class TFileDefinition: public THelperBase {
00076 public:
00077 virtual bool GetDeclFileName(const TClass* cl, TString& out_filename, TString& out_fsys,
00078 TFileSysEntry** fse = 0) const;
00079 virtual bool GetImplFileName(const TClass* cl, TString& out_filename, TString& out_fsys,
00080 TFileSysEntry** fse = 0) const;
00081 protected:
00082 virtual bool GetFileName(const TClass* cl, bool decl, TString& out_filename, TString& out_fsys,
00083 TFileSysEntry** fse = 0) const;
00084 TString MatchFileSysName(TString& filename, TFileSysEntry** fse = 0) const;
00085
00086 void SplitClassIntoDirFile(const TString& clname, TString& dir, TString& filename) const;
00087 void NormalizePath(TString& path) const;
00088 void ExpandSearchPath(TString& path) const;
00089 ClassDef(TFileDefinition, 0);
00090 };
00091
00092
00093
00094
00095
00096 class TPathDefinition: public THelperBase {
00097 public:
00098 virtual bool GetMacroPath(const TString& module, TString& out_dir) const;
00099 virtual bool GetIncludeAs(TClass* cl, TString& out_include_as) const;
00100 virtual bool GetFileNameFromInclude(const char* included, TString& out_fsname) const;
00101 virtual bool GetDocDir(const TString& module, TString& doc_dir) const;
00102 protected:
00103 ClassDef(TPathDefinition, 0);
00104 };
00105
00106 class TFileSysDir;
00107 class TFileSysDB;
00108
00109
00110 class TFileSysEntry: public TObject {
00111 public:
00112 TFileSysEntry(const char* name, TFileSysDir* parent):
00113 fName(name), fParent(parent), fLevel(parent ? parent->GetLevel() + 1 : 0) {}
00114 const char* GetName() const { return fName; }
00115 virtual ULong_t Hash() const { return fName.Hash(); }
00116 virtual void GetFullName(TString& fullname, Bool_t asIncluded) const {
00117 if (fParent) {
00118 fParent->GetFullName(fullname, asIncluded);
00119 if (fullname[0])
00120 fullname += "/";
00121 } else
00122 fullname = "";
00123 fullname += fName;
00124 }
00125
00126 TFileSysDir* GetParent() const { return fParent; }
00127 Int_t GetLevel() const { return fLevel; }
00128 protected:
00129 TString fName;
00130 TFileSysDir* fParent;
00131 Int_t fLevel;
00132 ClassDef(TFileSysEntry, 0);
00133 };
00134
00135
00136
00137 class TFileSysDir: public TFileSysEntry {
00138 public:
00139 TFileSysDir(const char* name, TFileSysDir* parent):
00140 TFileSysEntry(name, parent)
00141 { fFiles.SetOwner(); fDirs.SetOwner(); }
00142 const TList* GetFiles() const { return &fFiles; }
00143 const TList* GetSubDirs() const { return &fDirs; }
00144
00145 void Recurse(TFileSysDB* db, const char* path);
00146
00147 protected:
00148 TList fFiles;
00149 TList fDirs;
00150 ClassDef(TFileSysDir, 0);
00151 };
00152
00153
00154
00155
00156 class TFileSysRoot: public TFileSysDir {
00157 public:
00158 TFileSysRoot(const char* name, TFileSysDB* parent):
00159 TFileSysDir(name, parent) {}
00160 void GetFullName(TString& fullname, Bool_t asIncluded) const {
00161
00162
00163 fullname = "";
00164 if (!asIncluded)
00165 fullname += fName;
00166 }
00167
00168 ClassDef(TFileSysRoot, 0);
00169 };
00170
00171
00172
00173 class TFileSysDB: public TFileSysDir {
00174 public:
00175 TFileSysDB(const char* path, const char* ignore, Int_t maxdirlevel):
00176 TFileSysDir(path, 0), fEntries(1009, 5), fIgnorePath(ignore), fMaxLevel(maxdirlevel)
00177 { Fill(); }
00178
00179 TExMap& GetMapIno() { return fMapIno; }
00180 THashTable& GetEntries() { return fEntries; }
00181 const TString& GetIgnore() const { return fIgnorePath; }
00182 Int_t GetMaxLevel() const { return fMaxLevel; }
00183
00184 protected:
00185 void Fill();
00186
00187 private:
00188 TExMap fMapIno;
00189 THashTable fEntries;
00190 TString fIgnorePath;
00191 Int_t fMaxLevel;
00192 ClassDef(TFileSysDB, 0);
00193 };
00194
00195
00196
00197
00198 struct PathInfo_t {
00199 enum EDotAccess {
00200 kDotUnknown,
00201 kDotFound,
00202 kDotNotFound
00203 };
00204
00205 PathInfo_t():
00206 fFoundDot(kDotUnknown),
00207 #ifdef R__WIN32
00208 fInputPath("./;src/;include/"),
00209 #else
00210 fInputPath("./:src/:include/"),
00211 #endif
00212 fIncludePath("include"),
00213
00214 fIgnorePath("\\b(include|CVS|test|tutorials|doc|lib|python|demo|freetype-|gdk|libAfterImage|etc|config|build|bin)\\b"),
00215 fDocPath("doc"),
00216 fMacroPath("macros:."),
00217 fOutputDir("htmldoc") {}
00218
00219 EDotAccess fFoundDot;
00220 TString fInputPath;
00221 TString fIncludePath;
00222 TString fIgnorePath;
00223 TString fDocPath;
00224 TString fMacroPath;
00225 TString fDotDir;
00226 TString fEtcDir;
00227 TString fOutputDir;
00228 };
00229
00230
00231 public:
00232 enum EConvertOutput {
00233 kNoOutput,
00234 kInterpretedOutput,
00235 kCompiledOutput,
00236 kForceOutput = 0x10,
00237 kSeparateProcessOutput = 0x20
00238 };
00239
00240 THtml();
00241 virtual ~THtml();
00242
00243 static void LoadAllLibs();
00244
00245
00246 void Convert(const char *filename, const char *title,
00247 const char *dirname = "", const char *relpath="../",
00248 Int_t includeOutput = kNoOutput,
00249 const char* context = "");
00250 void CreateHierarchy();
00251 void MakeAll(Bool_t force=kFALSE, const char *filter="*",
00252 int numthreads = 1);
00253 void MakeClass(const char *className, Bool_t force=kFALSE);
00254 void MakeIndex(const char *filter="*");
00255 void MakeTree(const char *className, Bool_t force=kFALSE);
00256
00257
00258 void SetModuleDefinition(const TModuleDefinition& md);
00259 void SetFileDefinition(const TFileDefinition& fd);
00260 void SetPathDefinition(const TPathDefinition& pd);
00261 void SetProductName(const char* product) { fProductName = product; }
00262 void SetOutputDir(const char *dir);
00263 void SetInputDir(const char *dir);
00264 void SetSourceDir(const char *dir) { SetInputDir(dir); }
00265 void SetIncludePath(const char* dir) { fPathInfo.fIncludePath = dir; }
00266 void SetEtcDir(const char* dir) { fPathInfo.fEtcDir = dir; }
00267 void SetDocPath(const char* path) { fPathInfo.fDocPath = path; }
00268 void SetDotDir(const char* dir) { fPathInfo.fDotDir = dir; fPathInfo.fFoundDot = PathInfo_t::kDotUnknown; }
00269 void SetRootURL(const char* url) { fLinkInfo.fROOTURL = url; }
00270 void SetLibURL(const char* lib, const char* url) { fLinkInfo.fLibURLs[lib] = url; }
00271 void SetXwho(const char *xwho) { fLinkInfo.fXwho = xwho; }
00272 void SetMacroPath(const char* path) {fPathInfo.fMacroPath = path;}
00273 void AddMacroPath(const char* path);
00274 void SetCounterFormat(const char* format) { fCounterFormat = format; }
00275 void SetClassDocTag(const char* tag) { fDocSyntax.fClassDocTag = tag; }
00276 void SetAuthorTag(const char* tag) { fDocSyntax.fAuthorTag = tag; }
00277 void SetLastUpdateTag(const char* tag) { fDocSyntax.fLastUpdateTag = tag; }
00278 void SetCopyrightTag(const char* tag) { fDocSyntax.fCopyrightTag = tag; }
00279 void SetHeader(const char* file) { fOutputStyle.fHeader = file; }
00280 void SetFooter(const char* file) { fOutputStyle.fFooter = file; }
00281 void SetHomepage(const char* url) { fLinkInfo.fHomepage = url; }
00282 void SetSearchStemURL(const char* url) { fLinkInfo.fSearchStemURL = url; }
00283 void SetSearchEngine(const char* url) { fLinkInfo.fSearchEngine = url; }
00284 void SetViewCVS(const char* url) { fLinkInfo.fViewCVS = url; }
00285 void SetWikiURL(const char* url) { fLinkInfo.fWikiURL = url; }
00286 void SetCharset(const char* charset) { fOutputStyle.fCharset = charset; }
00287 void SetDocStyle(const char* style) { fDocSyntax.fDocStyle = style; }
00288
00289
00290 const TModuleDefinition& GetModuleDefinition() const;
00291 const TFileDefinition& GetFileDefinition() const;
00292 const TPathDefinition& GetPathDefinition() const;
00293 const TString& GetProductName() const { return fProductName; }
00294 const TString& GetInputPath() const { return fPathInfo.fInputPath; }
00295 const TString& GetOutputDir(Bool_t createDir = kTRUE) const;
00296 virtual const char* GetEtcDir() const;
00297 const TString& GetModuleDocPath() const { return fPathInfo.fDocPath; }
00298 const TString& GetDotDir() const { return fPathInfo.fDotDir; }
00299 const char* GetURL(const char* lib = 0) const;
00300 const TString& GetXwho() const { return fLinkInfo.fXwho; }
00301 const TString& GetMacroPath() const { return fPathInfo.fMacroPath; }
00302 const char* GetCounterFormat() const { return fCounterFormat; }
00303 const TString& GetClassDocTag() const { return fDocSyntax.fClassDocTag; }
00304 const TString& GetAuthorTag() const { return fDocSyntax.fAuthorTag; }
00305 const TString& GetLastUpdateTag() const { return fDocSyntax.fLastUpdateTag; }
00306 const TString& GetCopyrightTag() const { return fDocSyntax.fCopyrightTag; }
00307 const TString& GetHeader() const { return fOutputStyle.fHeader; }
00308 const TString& GetFooter() const { return fOutputStyle.fFooter; }
00309 const TString& GetHomepage() const { return fLinkInfo.fHomepage; }
00310 const TString& GetSearchStemURL() const { return fLinkInfo.fSearchStemURL; }
00311 const TString& GetSearchEngine() const { return fLinkInfo.fSearchEngine; }
00312 const TString& GetViewCVS() const { return fLinkInfo.fViewCVS; }
00313 const TString& GetWikiURL() const { return fLinkInfo.fWikiURL; }
00314 const TString& GetCharset() const { return fOutputStyle.fCharset; }
00315 const TString& GetDocStyle() const { return fDocSyntax.fDocStyle; }
00316
00317
00318 Bool_t CopyFileFromEtcDir(const char* filename) const;
00319 virtual void CreateAuxiliaryFiles() const;
00320 virtual TClass* GetClass(const char *name) const;
00321 const char* ShortType(const char *name) const;
00322 const char* GetCounter() const { return fCounter; }
00323 void GetModuleMacroPath(const TString& module, TString& out_path) const { GetPathDefinition().GetMacroPath(module, out_path); }
00324 virtual bool GetDeclFileName(TClass* cl, Bool_t filesys, TString& out_name) const;
00325 void GetDerivedClasses(TClass* cl, std::map<TClass*, Int_t>& derived) const;
00326 static const char* GetDirDelimiter() {
00327
00328 #ifdef R__WIN32
00329 return ";";
00330 #else
00331 return ":";
00332 #endif
00333 }
00334 virtual bool GetImplFileName(TClass* cl, Bool_t filesys, TString& out_name) const;
00335 virtual void GetHtmlFileName(TClass *classPtr, TString& filename) const;
00336 virtual const char* GetHtmlFileName(const char* classname) const;
00337 TList* GetLibraryDependencies() { return &fDocEntityInfo.fLibDeps; }
00338 void SortListOfModules() { fDocEntityInfo.fModules.Sort(); }
00339 const TList* GetListOfModules() const { return &fDocEntityInfo.fModules; }
00340 const TList* GetListOfClasses() const { return &fDocEntityInfo.fClasses; }
00341 TFileSysDB* GetLocalFiles() const { if (!fLocalFiles) SetLocalFiles(); return fLocalFiles; }
00342 TVirtualMutex* GetMakeClassMutex() const { return fMakeClassMutex; }
00343 virtual void GetModuleNameForClass(TString& module, TClass* cl) const;
00344 const PathInfo_t& GetPathInfo() const { return fPathInfo; }
00345 Bool_t HaveDot();
00346 void HelperDeleted(THelperBase* who);
00347 static Bool_t IsNamespace(const TClass*cl);
00348 void SetDeclFileName(TClass* cl, const char* filename);
00349 void SetFoundDot(Bool_t found = kTRUE);
00350 void SetImplFileName(TClass* cl, const char* filename);
00351 void SetBatch(Bool_t batch = kTRUE) { fBatch = batch; }
00352 Bool_t IsBatch() const { return fBatch; }
00353
00354 void ReplaceSpecialChars(std::ostream&, const char*) {
00355 Error("ReplaceSpecialChars",
00356 "Removed, call TDocOutput::ReplaceSpecialChars() instead!"); }
00357 void SetEscape(char ='\\') {}
00358
00359 protected:
00360 struct DocSyntax_t {
00361 TString fClassDocTag;
00362 TString fAuthorTag;
00363 TString fLastUpdateTag;
00364 TString fCopyrightTag;
00365 TString fDocStyle;
00366 };
00367
00368 struct LinkInfo_t {
00369 TString fXwho;
00370 TString fROOTURL;
00371 std::map<std::string, TString> fLibURLs;
00372 TString fHomepage;
00373 TString fSearchStemURL;
00374 TString fSearchEngine;
00375 TString fViewCVS;
00376 TString fWikiURL;
00377 };
00378
00379 struct OutputStyle_t {
00380 TString fHeader;
00381 TString fFooter;
00382 TString fCharset;
00383 };
00384
00385 struct DocEntityInfo_t {
00386 DocEntityInfo_t(): fClasses(503, 3) {}
00387 TString fClassFilter;
00388 THashList fClasses;
00389 mutable THashList fShortClassNames;
00390 THashList fModules;
00391 THashList fLibDeps;
00392 };
00393
00394 protected:
00395 virtual void CreateJavascript() const;
00396 virtual void CreateStyleSheet() const;
00397 void CreateListOfTypes();
00398 void CreateListOfClasses(const char* filter);
00399 virtual bool GetDeclImplFileName(TClass* cl, bool filesys, bool decl, TString& out_name) const;
00400 void MakeClass(void* cdi, Bool_t force=kFALSE);
00401 TClassDocInfo *GetNextClass();
00402 void SetLocalFiles() const;
00403
00404 static void *MakeClassThreaded(void* info);
00405
00406 protected:
00407 TString fCounter;
00408 TString fCounterFormat;
00409 TString fProductName;
00410 TIter *fThreadedClassIter;
00411 Int_t fThreadedClassCount;
00412 TVirtualMutex *fMakeClassMutex;
00413 TGClient *fGClient;
00414 DocSyntax_t fDocSyntax;
00415 LinkInfo_t fLinkInfo;
00416 OutputStyle_t fOutputStyle;
00417 mutable PathInfo_t fPathInfo;
00418 DocEntityInfo_t fDocEntityInfo;
00419 mutable TPathDefinition *fPathDef;
00420 mutable TModuleDefinition *fModuleDef;
00421 mutable TFileDefinition* fFileDef;
00422 mutable TFileSysDB *fLocalFiles;
00423 Bool_t fBatch;
00424
00425 ClassDef(THtml,0)
00426 };
00427
00428 R__EXTERN THtml *gHtml;
00429
00430 #endif