Logo ROOT  
Reference Guide
htmlex.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_legacy
3/// This file demonstrates how THtml can document sources.
4///
5/// See the [Users Guide](https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html)
6/// chapter [Automatic HTML Documentation](https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuideChapters/HTMLDoc.pdf), and
7/// [THtml's class documentation](https://root.cern.ch/doc/master/classTHtml.html).
8///
9/// To see this demo script in action start up ROOT and run
10/// ~~~{.cpp}
11/// root [0] .x $(ROOTSYS)/tutorials/htmlex.C+
12/// ~~~
13/// and check the output in `./htmldoc`.
14///
15/// and of course we can put HTML code into comments, too.
16///
17/// \macro_code
18///
19/// \author Axel Naumann
20
21#include "THtml.h"
22
23class THtmlDemo: public TObject {
24public:
25 THtmlDemo(): fHtml(0)
26 {
27 printf("This class is for demonstration purposes only!\n");
28 }
29 ~THtmlDemo() { if (fHtml) delete fHtml; }
30
31 // inline methods can have their documentation in front
32 // of the declaration. DontDoMuch is so short - where
33 // else would one put it?
34 void DontDoMuch() {}
35
36 void Convert()
37 {
38 // Create a "beautified" version of this source file.
39 // It will be called htmldoc/htmlex.C.html.
40
41 GetHtml()->SetSourceDir("$(ROOTSYS)/tutorials");
42 GetHtml()->Convert("htmlex.C", "Example of THtml", "./htmldoc/", "./");
43 }
44
45 void ReferenceDoc()
46 {
47 // This function documents THtmlDemo.
48 // It will create THtmlDemo.html and src/THtmlDemo.cxx.html
49 // - the beautified version of the source file
50
51 GetHtml()->SetSourceDir("$(ROOTSYS)/tutorials");
52 GetHtml()->SetOutputDir("./htmldoc");
53 GetHtml()->MakeIndex("THtmlDemo"); // create ClassIndex.html and the javascript and CSS files
54 GetHtml()->MakeClass("THtmlDemo"); // update the class doc
55 }
56
57 void MakeDocForAllClasses(Bool_t evenForROOT = kFALSE)
58 {
59 // Creates the documentation pages for all classes that have
60 // been loaded, and that are accessible from "./".
61 // If evenForROOT is set, we'll try to document ROOT's classes,
62 // too - you will end up with a copy of ROOT's class reference.
63 // The documentation will end up in the subdirectory htmldoc/.
64
65 if (evenForROOT)
66 GetHtml()->SetSourceDir(".:$(ROOTSYS)");
67 else
68 GetHtml()->SetSourceDir(".");
69 GetHtml()->SetOutputDir("./htmldoc");
70 GetHtml()->MakeAll();
71 }
72
73 void RunAll() {
74 // Show off a bit - do everything we can.
75 MakeDocForAllClasses();
76 ReferenceDoc();
77 Convert();
78 }
79
80protected:
81 THtml* GetHtml()
82 {
83 // Return out THtml object, and create it if it doesn't exist.
84 if (!fHtml) fHtml = new THtml();
85 return fHtml;
86 }
87
88private:
89 Int_t fVeryUselessMember; // This is a very useless member.
90 THtml* fHtml; // our local THtml instance.
91 ClassDef(THtmlDemo, 0); // A demo of THtml.
92};
93
94void htmlex() {
95 THtmlDemo htmldemo;
96 htmldemo.RunAll();
97}
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:326
Definition: THtml.h:40
Mother of all ROOT objects.
Definition: TObject.h:37