@@ -27,9 +27,12 @@ string gFileName; // Input file name
27
27
string gLineString ; // Current line (as a string) in the current input file
28
28
string gImageName ; // Current image name
29
29
string gMacroName ; // Current macro name
30
+ string gOutputName ; // File containing std::out
30
31
string gCwd ; // Current working directory
31
32
string gOutDir ; // Output directory
32
33
int gShowSource ; // True if the source code should be shown
34
+ int gShowOutput ; // True if the output should be shown
35
+ int gShowImage ; // True if the image should be shown
33
36
34
37
// //////////////////////////////////////////////////////////////////////////////
35
38
// / Filter ROOT tutorials for Doxygen.
@@ -40,6 +43,8 @@ int main(int argc, char *argv[])
40
43
41
44
gFileName = argv[1 ];
42
45
gShowSource = 0 ;
46
+ gShowOutput = 0 ;
47
+ gShowImage = 0 ;
43
48
44
49
// Retrieve the output directory
45
50
gOutDir = getenv (" TUTORIALS_OUTPUT_DIRECTORY" );
@@ -52,30 +57,41 @@ int main(int argc, char *argv[])
52
57
FILE *m = 0 ;
53
58
54
59
// Extract the macro name
55
- int i1 = gFileName .rfind (' /' )+1 ;
56
- int i2 = gFileName .rfind (' C' );
57
- gMacroName = gFileName .substr (i1,i2-i1+1 );
60
+ int i1 = gFileName .rfind (' /' )+1 ;
61
+ int i2 = gFileName .rfind (' C' );
62
+ gMacroName = gFileName .substr (i1,i2-i1+1 );
63
+ gImageName = StringFormat (" %s.png" , gMacroName .c_str ()); // Image name
64
+ gOutputName = StringFormat (" %s.out" , gMacroName .c_str ()); // output name
58
65
59
66
// Parse the source and generate the image if needed
60
67
while (fgets (gLine ,255 ,f)) {
61
68
gLineString = gLine ;
62
69
63
70
// \macro_image found
64
71
if (gLineString .find (" \\ macro_image" ) != string::npos) {
65
- gImageName = StringFormat (" %s.png" , gMacroName .c_str ()); // Image name
66
72
ExecuteCommand (StringFormat (" root -l -b -q \" makeimage.cxx(\\\" %s\\\" ,\\\" %s\\\" ,\\\" %s\\\" )\" " ,
67
73
gFileName .c_str (), gImageName .c_str (), gOutDir .c_str ()));
68
74
ReplaceAll (gLineString , " \\ macro_image" ,
69
75
StringFormat (" \\ image html %s" ,gImageName .c_str ()));
70
-
76
+ gShowImage = 1 ;
77
+ remove (gOutputName .c_str ());
71
78
}
72
79
73
80
// \macro_code found
74
81
if (gLineString .find (" \\ macro_code" ) != string::npos) {
75
82
gShowSource = 1 ;
76
83
m = fopen (StringFormat (" %s/html/%s" ,gOutDir .c_str (),gMacroName .c_str ()).c_str (), " w" );
77
84
ReplaceAll (gLineString , " \\ macro_code" ,
85
+ StringFormat (" \\ include %s" ,gOutputName .c_str ()));
86
+ }
87
+
88
+ // \macro_output found
89
+ if (gLineString .find (" \\ macro_output" ) != string::npos) {
90
+ ExecuteCommand (StringFormat (" root -l -b -q %s" , gFileName .c_str ()).c_str ());
91
+ rename (gOutputName .c_str (), StringFormat (" %s/html/%s" ,gOutDir .c_str (), gOutputName .c_str ()).c_str ());
92
+ ReplaceAll (gLineString , " \\ macro_output" ,
78
93
StringFormat (" \\ include %s" ,gMacroName .c_str ()));
94
+ gShowOutput = 1 ;
79
95
}
80
96
81
97
// \author is the last comment line.
@@ -87,6 +103,7 @@ int main(int argc, char *argv[])
87
103
if (m && gShowSource == 2 ) fprintf (m," %s" ,gLineString .c_str ());
88
104
}
89
105
}
106
+
90
107
if (m) fclose (m);
91
108
fclose (f);
92
109
return 0 ;
@@ -99,7 +116,7 @@ int main(int argc, char *argv[])
99
116
void ExecuteCommand (string command)
100
117
{
101
118
int o = dup (fileno (stdout));
102
- freopen (" stdout.dat " ," a" ,stdout);
119
+ freopen (gOutputName . c_str () ," a" ,stdout);
103
120
system (command.c_str ());
104
121
dup2 (o,fileno (stdout));
105
122
close (o);
0 commit comments