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